FAST APIS WHICH CONNECT THE DOTS OF YOUR SOFTWARE
Gaurav Sharma
Flexi Roundtables: Top 1% Leaders - 60+ Unicorns ?? have been part of Flexi Roundtables | Flexi Analyst - Build your community with Top Analyst of the world ?? | Ex- Accenture ?? | GCC Enabler
SQL could definitely be considered one of the first APIs. 40 years of database design, implementation, and access has a lot to teach about how consumers request and use data.
For whom we need to design fast API?
Yes, Users is the answer.
Remember that we Users are very impatient creatures. We all want things to happen immediately, and will seek out alternative API services if the performance is too bad.
First we should know Latency and Througput.
Latency means time waiting for the data and Throughput means amount of raw data.
Wonder How it works? check this out:
https://github.com/colin-scott/interactive_latencies
so, we know who is the winner? Yes u are right its the API with minimum latency. NANOSECONDS.
Can it be possible with SQL or NOSQL?
See am fan of both, but when I talk about consistency, simple and pattern I love NOSQL. We made the site 31bhog.com with NOSQL. Rather than being tied to a traditional structure of tables, NoSQL process structure data in a way which reflects how the user is accessing it. If the user is getting key/value pairs, a key/value store makes sense. Likewise, if the user is retrieving a bunch of graph data, use a data store that is able to easily handle graph data.
Here we go with my Tips:
- Never make humans wait, be it the end-user or the developer. Prioritize latency over throughput.
- 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