Making fast APIs: lessons learned from 40 years of SQL
- Give consumers full access over what to fetch, and don’t tie them to pre-determined data fields.
- Emulate SQL’s EXPLAIN method & let users know how exactly the database will execute their query. Then they can see what may be slowing things down and correct it themselves.
- If impossible to offer full access, optimize your API for common access patterns.
- Make it easy for users to fetch all the data they need in one go, rather than looping multiple requests.
- Design the API to cache data locally.
- Design the API to study access logs and prefetch relevant data accordingly as this impacts the perceived speed of fetching without changing throughput.
- Learnings from the NoSQL movement: model data structure on data access patterns; and that users want consistency more than the fastest (or the slowest) speeds possible.
Full post here, 10 mins read