Table of Contents
A scalable API is the one which fuels business growth by efficient management of demands and traffic. Resources are managed efficiently, speed up launch of products and services and lowers the costs.
The traditional way of developing software is long gone as we live in an interconnected digital landscape. The architecture of applications is drastically changed and monolithic applications are replaced by API first based architected applications.
API based applications are scalable, flexible, resiliency and performance driven. API or application programming interface acts as a bridge between two applications for communication. APIs deliver data or services without you knowing what is going on in the background and how your request is serviced.
In today’s article we will learn about how to build scalable APIs in the cloud, what are the key ingredients of scalability.

Building Scalable APIs
Building a scalable API requires many considerations at the design stage itself. Let’s look at them more in detail in this section.
Stateless Architecture
A stateless architecture dictates a scenario where servers need not to remember previous request details. Each request is handled independently as a new transaction irrespective of previous state making systems more scalable, reliable and easy to manage.
Session state is not maintained and requests are distributed across servers. Systems become more resilient as they do not rely on previous session data. If the server fails the new server will resume the session without impacting end user experience. Server load is reduced as stateless requests can be easily cached.
API Versioning
API Versioning lets you update your API without impacting end user experience as versioning lets you implement backward compatibility. End users can upgrade systems at their own pace and developers can simultaneously maintain multiple versions. Existing functionality is not touched upon and developers can add new features or provide fixes. Versioning helps to understand and track what versions customers are using and deal effectively with compatibility issues if any.
Rate Limiting
To protect systems against abuse, overload and ensure fair resource allocation rate limiting feature limits on how many requests clients can make in a stipulated timeframe. Different rate limiting strategies can be implemented such as a fixed window where requests are limited to a fixed number for a specific duration such as 1000 requests in an hour. Sliding window technique will adjust time limits on a rolling time window. Token bucket algorithm based rate limit gives each request a token to consume. Leaky bucket allows requests to be added to the bucket until it overflows and then requests are dropped.
Database Optimization Techniques
For efficient data management we will also look at database optimization techniques here to reduce query times and improve performance.
- Indexing – is done for faster retrieval of data
- Query optimisation – Non-essential load on database servers is reduced is SQL queries are efficiently designed
- Normalization and de-normalization – organizing data into related tables reduces redundancy and dependence. Avoid complex joints to improve read efficiencies by de-normalization.
- Partitioning – large table is divided into smaller manageable tables
- Using stored procedures – execution of series of SQL statements
- Database sharding – to improve scalability and performance data is distributed across databases
- Hardware resources optimization – right hardware sizing to ensure the database server has enough resources to handle workloads in an efficient manner.
- Database maintenance – ongoing periodic maintenance of databases is required to maintain performance
- Connection pooling – reusing existing connections to reduce overhead of creating new database connections

Caching Strategies
Caching strategies help in improving performance and applications efficiency as data used frequency is stored and reused.
- Cache-aside – data is available in cache or not is first checked before servicing the request
- Write-through-caching – data is written to database and cache simultaneously to be in sync
- Write back caching – data is written to cache and then in background cache writes data to database
- Read through caching- data is extracted from cache instead of storage or DB. If data is not in cache, it is fetched from database by cache and request is serviced
- Distributed caching – Cache is spread across servers or nodes
- Content delivery framework (CDN) caching – static content is stored near to edge servers for faster response to end users
Pagination Technique
Pagination technique allows data to be divided into manageable chunks to reduce large data transfer requests overhead.
- Offset based pagination – starting point and a limit point to retrieve only specific records at a time
- Cursor based pagination – cursor tracks the position and retrieves data accordingly
- Page based pagination – page size and page number is mentioned here
- Keyset pagination – similar to cursor based technique but uses combination of indexed columns so as to directly jump to requested data
- Infinite scroll – As user scroll page more data is loaded