Backend Scalability: Caching, Queues and Read Replicas
Backend scalability for growing Indian products: when to add indexes, caching, background queues and read replicas, in the order that costs least.
Summary of this article
- Defines backend scalability and explains why measuring slow endpoints should come before adding infrastructure.
- Explains how indexes, query fixes and connection limits give the biggest early gains at the lowest cost.
- Describes cache-aside caching with Redis, including TTLs, invalidation and eviction settings.
- Covers background queues for slow work, with retries and idempotent jobs.
- Explains PostgreSQL read replicas, replication lag and which reads can safely use them, with a scaling-order table and a description of how Arham Technology approaches scaling.
Summarised by AI from the full article. Check figures and prices against the article before you act on them.

Quick answer
Backend scalability means your API stays fast as traffic and data grow. Fix slow queries and indexes first, then add caching for repeated reads, move slow work such as emails and webhooks into background queues, and add read replicas only when one database cannot serve reads. Measure each step before adding the next.
Key takeaways
- Measure first: find the slowest endpoints and queries before adding any new infrastructure.
- Fix indexes, N+1 queries and unbounded lists before caching, because a cache on top of a slow query only hides the problem.
- Cache repeated reads with a TTL and delete the key when the data changes, and never cache per-user data under a shared key.
- Move emails, invoices, webhooks and reports out of the request into a queue with retries, and make each job safe to run twice.
- Add a read replica only after caching and tuning, and route reads that need fresh data to the primary.
On this page
- What is backend scalability?
- How do you find the real bottleneck?
- Why fix queries and indexes before anything else?
- When does caching help, and how should you do it?
- Which work should move into background queues?
- When should you add a read replica?
- In what order should you scale your backend?
- How Arham Technology approaches backend scalability
- Next step
A flash sale, a WhatsApp campaign or a viral reel can send ten times your normal traffic in an hour. If your API slows down or your checkout times out at that moment, you lose the sales you paid to attract. Planning for backend scalability means knowing what to fix first, so you spend on the right thing instead of rebuilding everything.
This guide covers the practical order for Indian product teams: measure, tune the database, add caching, move slow work into queues, and only then add read replicas. Each step is cheaper and less risky than the next.
What is backend scalability?
Backend scalability is the ability of your API, server and database to handle more users and data without slower responses or failures. It is solved one bottleneck at a time, and the right fix depends on where your system is actually slow.
Two ideas help:
- Vertical scaling means a bigger server with more CPU and memory. It is quick and often enough for a long time.
- Horizontal scaling means more servers behind a load balancer. It needs stateless application servers, so sessions and files must live in shared storage rather than on one machine.
Most teams that feel "we need to scale" actually have a few slow queries and some work that should not happen inside the request. Start there.
How do you find the real bottleneck?
Measure response time per endpoint and query time per database call before you change anything. Without numbers, teams add caches and servers that do not touch the real problem.
Collect these basics:
- Response time at the 95th percentile per route, not just the average.
- Slowest database queries, using your database's slow query log or statistics views.
- Error and timeout rate during peak hours.
- CPU, memory and connection counts for the app server and database.
- Queue backlog size, once you have background jobs.
Then run a load test on your two or three most important paths, such as login, product listing and checkout, at the traffic you expect for your next campaign. This tells you which limit you hit first.
Why fix queries and indexes before anything else?
Fixing indexes and query patterns usually gives the largest gain for the least money, so do it before adding any new service. A single missing index can turn a millisecond lookup into a full table scan as data grows.
Check these in order:
- Missing indexes on columns used in
WHERE,JOINandORDER BY. Use your database's explain output to confirm an index is used. - N+1 queries, where a list of 50 orders triggers 50 extra queries for customers. Load related data in one query or a join.
- Unbounded lists. Add pagination and a maximum page size to every list endpoint. Our guide to REST API design best practices covers pagination and filtering.
- Selecting everything. Fetch only the columns you return.
- Connection limits. Each app instance opens database connections, and a database allows a limited number. Use a connection pool with sensible limits so that adding app servers does not exhaust the database.
If your data model itself is the issue, revisit your database choice using our comparison of PostgreSQL, MySQL and MongoDB.
When does caching help, and how should you do it?
Caching helps when the same data is read much more often than it changes. A cache stores a copy of the result in fast memory, so repeated requests skip the database.
The most common pattern is cache-aside. Redis documents it like this: the application reads from Redis first, falls back to the database on a miss, writes the result back with a time-to-live (TTL), and invalidates the key when the data is updated.
Good candidates and risky ones:
| Data | Cache it? | Notes |
|---|---|---|
| Product catalogue, categories, pricing tables | Yes | Short TTL, delete the key on edit |
| Public pages and API responses for all users | Yes | Also consider a CDN in front |
| Site settings, feature flags | Yes | Long TTL with explicit invalidation |
| Cart, wallet balance, order status | Careful | Stale data hurts trust, so keep TTL very short or skip |
| Anything personal to one user | Careful | Include the user ID in the key, never share keys |
Follow these rules:
- Always set a TTL, so a missed invalidation fixes itself.
- Delete or update the key after every write to that data.
- Plan for stampedes. When a popular key expires, hundreds of requests can hit the database together. Use a short lock or refresh the key slightly before it expires.
- Choose an eviction policy on purpose. Redis suggests
allkeys-lruas a good default when a subset of keys is read far more than the rest. - Measure the hit rate. A cache with a low hit rate adds complexity without helping.
Which work should move into background queues?
Move any task the user does not need to wait for into a queue, so the request returns quickly and the work happens in a separate worker. A queue is a list of jobs that workers process at their own pace.
Typical jobs to move out of the request:
- Sending email, SMS and WhatsApp notifications
- Generating GST invoices and PDF reports
- Processing uploaded images and files
- Calling slow third-party APIs and retrying failed webhooks
- Syncing data to accounting tools such as Tally or to a CRM
A queue also protects you during spikes: the backlog grows for a few minutes, but the website stays responsive.
Design jobs carefully:
- Make each job idempotent. A job may run twice after a crash or retry, so sending the same invoice number twice should not create two invoices or two charges.
- Retry with backoff. Retry failed jobs a limited number of times with growing delays, then move them to a failed list that someone reviews.
- Keep jobs small and pass IDs, not whole records, so a job reads fresh data when it runs.
- Monitor queue length and job age, and alert when jobs wait too long.
If you use BullMQ with Node.js, the BullMQ production guide says Redis must run with maxmemory-policy set to noeviction, because evicting keys arbitrarily breaks queues. That conflicts with the eviction settings you may want for a cache, so run queues and caches on separate Redis instances. Laravel's queue system offers database and Redis drivers, and the same idempotency rules apply.
When should you add a read replica?
Add a read replica after tuning and caching, when a single database is still limited by read traffic. A read replica is a copy of your primary database that serves read-only queries, which frees the primary to handle writes.
In PostgreSQL, a replica is a hot standby that accepts read-only connections while it replays changes streamed from the primary. Streaming replication is asynchronous by default, so there is a small delay. The PostgreSQL documentation describes this as typically under one second when the standby can keep up, and says data on the standby is eventually consistent with the primary.
That delay decides which reads can use a replica:
- Safe for replicas: reports, dashboards, search pages, product listings and admin analytics.
- Keep on the primary: a user's own data right after they change it, payment confirmation and stock checks during checkout.
Other points to plan for:
- Monitor lag on the primary, using the byte difference between the current write position and the replica's replay position, and alert if it keeps growing.
- Expect cancelled queries. Long-running queries on a replica can conflict with incoming changes and be cancelled, so keep replica queries short or run heavy reports on a dedicated replica.
- Send writes only to the primary and route reads in your data layer, not scattered through the code.
Managed databases from major cloud providers offer replicas as a setting, which removes much of the setup work. A replica adds a monthly infrastructure cost, so check it against what tuning and caching can still give you.
In what order should you scale your backend?
Scale in the order that gives the most benefit for the least complexity. Use this table as a guide:
| Step | Action | Typical effect | Added complexity |
|---|---|---|---|
| 1 | Measure slow routes and queries | Shows the real bottleneck | Low |
| 2 | Fix indexes, N+1 queries and pagination | Often the biggest gain | Low |
| 3 | Tune connection pooling | Prevents database connection errors | Low |
| 4 | Add caching for repeated reads | Cuts database load on hot data | Medium |
| 5 | Move slow work to queues | Faster responses and spike protection | Medium |
| 6 | Scale app servers horizontally | More request capacity | Medium |
| 7 | Add read replicas | More read capacity | Higher |
| 8 | Split services or shard data | Only for clear, measured limits | Highest |
Infrastructure costs vary a lot by cloud provider, region and traffic, so get an estimate for your own setup rather than relying on generic figures. As a rough project-experience range, steps 1 to 5 are often a few weeks of engineering effort for a typical product, and they delay the need for much larger spending.
How Arham Technology approaches backend scalability
Our backend development service treats scale as part of the design, not a late rescue. For each project we follow the same process:
- Domain and threat sketch: we map the entities, the busiest workflows and the failure cases, such as a sale day or a webhook storm.
- Contract first: API contracts include pagination, filters and error formats, so clients cannot request unbounded data.
- Core services build: the main workflows ship with indexes, tests around critical rules and structured logs.
- Integration and load reality: external systems get retries and idempotency, and key paths are exercised under the load you expect.
- Runbook handover: deploy steps, migration notes and incident basics are documented for your team.
We build in Node.js, TypeScript, PostgreSQL, MongoDB and Redis, and in Laravel where it fits. For subscription products, the same patterns apply to billing jobs and tenant data, which our SaaS development service covers in more detail. Security belongs in the same plan, and our API security checklist shows the rate limits and logging that protect a busy API.
Next step
Start with measurement: list your five slowest endpoints and your five slowest queries, then fix the cheapest causes first. If you want a second opinion, see our backend development service or contact us with your current stack and traffic expectations, and we will suggest a practical scaling plan.
Frequently asked questions
What is backend scalability?
Backend scalability is the ability of your server, API and database to handle more users, requests and data without slowing down or failing. It is usually achieved in stages: tuning queries, caching, background jobs, and then scaling the database. It is about removing the next bottleneck, not about copying a large company's architecture.
When should I add caching to my backend?
Add caching when the same data is read far more often than it changes and your database is the slow part. Product lists, settings, pricing tables and public pages are common examples. First check that the underlying query is indexed, because caching a badly written query only delays the problem.
Do I need Redis for a background queue?
Not always. Redis-based queues such as BullMQ are popular in Node.js, and Laravel supports Redis, database and other queue drivers. A database-backed queue can be enough at low volume. Choose Redis when you need higher throughput, delayed jobs and dashboards, and keep queue data on a Redis instance that never evicts keys.
Are PostgreSQL read replicas always up to date?
No. PostgreSQL streaming replication is asynchronous by default, so a replica can be slightly behind the primary. The documentation describes this delay as typically under one second when the replica keeps up. Read data that must be fresh, such as a just-placed order, from the primary.
Should a small startup use microservices to scale?
Usually no. A well-structured single backend with a tuned database, a cache and a queue handles far more traffic than most Indian startups see in their first years. Microservices add deployment and debugging cost. Split a service out only when a clear, measured need justifies it.
How do I know my backend is hitting its limits?
Look for rising response times at the 95th percentile, database CPU staying high, growing queue backlogs, connection errors and timeouts during campaigns or sales. Track these with logs and basic metrics before problems reach customers, and load test key paths before an expected traffic spike.
Want Backend Development done right?
Get a free consultation and a clear plan โ scope, timeline and cost โ from our Mumbai team.



