Chapter 6. Scaling APIs

Making sure your API scales both in terms of use cases and load is critical for its success. In this section, we cover the following scaling best practices and tips to help ensure that your API is future-proof:

  • Scaling throughput

  • Evolving API design

  • Paginating APIs

  • Rate-limiting APIs

  • Developer SDKs

When you are building an API that other people depend on, availability and reliability are important. You want to ensure that it never goes down and that it continues to load fast for its users. However, your API can suddenly experience a surge in usage. That can affect the quality of your service or even bring your own application down, if the application relies on your APIs.

To scale your API by supporting an increased number of API calls, there are many things you can do at the application level. Database query optimization, sharding databases, adding missing indexes, utilizing caching, doing expensive operations asynchronously, writing efficient code, and tuning web servers help in increasing the throughput and decreasing the latency. All of these things are very important and you should do them. We cover these topics only briefly in the first section of this chapter, given that they are covered more extensively in other books about web application performance.

Beyond these optimizations, there is another set of changes that are frequently overlooked and can significantly help in scaling APIs. There are ways in which you can develop your API design, ...

Get Designing Web APIs now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.