Key architectural patterns for decoupling bottlenecks, optimizing database connection pooling, and leveraging edge caching under extreme traffic loads.
Scaling a digital platform from handling tens of thousands of requests to tens of millions requires rethinking every layer of the system. Bottlenecks that remain unnoticed during normal operations will cascade catastrophically when traffic surges. In this article we walk through the architecture and techniques we used to take a client platform to 50 million requests per day while keeping p99 latency under 120 milliseconds.
Start With Measurement, Not Guesswork
Before changing a single line of code, we instrumented the platform end to end. Distributed tracing showed exactly where time was spent on every request, and the results surprised the team: the application code itself accounted for less than 15% of latency. The rest came from database round-trips, synchronous calls between services and cold caches.
We defined clear service-level objectives up front:
- p50 latency under 40 ms and p99 under 120 ms for core API routes.
- 99.99% availability measured monthly.
- Error budget alerts long before customers notice a problem.
Decoupling with Event-Driven Architecture
The original system had services calling each other synchronously in long chains. One slow dependency — an email provider, a reporting job — could hold an API request open for seconds. We moved non-critical work onto an event stream.
Commands vs. Events
The API now does only what the user is waiting for, then publishes an event such as OrderPlaced. Independent consumers handle invoices, notifications, analytics and search indexing in the background. Slow downstream dependencies cannot block client-facing API responses.
Idempotency and Retries
Every consumer is idempotent: processing the same event twice has no extra effect. Combined with automatic retries and a dead-letter queue, this turned transient failures from incidents into non-events.
Database Connection Pooling & Edge Caching
Direct database queries on every read request are the most common cause of cloud degradation. Implementing multi-tiered caching with Redis Enterprise and deploying edge workers closer to the end user reduces database load by up to 85%.
Connection Pooling
Hundreds of service instances opening their own database connections exhausted the database long before CPU did. A dedicated connection pooler in transaction mode let 2,000 application workers share around 150 real connections.
Three Layers of Cache
- Edge cache for public, cacheable responses, served from locations close to the user.
- Distributed cache (Redis) for shared data like product catalogues and sessions, with short TTLs and event-driven invalidation.
- In-process cache for tiny, very hot lookups such as feature flags and configuration.
The fastest database query is the one you never have to make.
Autoscaling That Reacts Before Users Do
CPU-based autoscaling reacts too late for sudden spikes. We scale on request rate and queue depth instead, keep a warm buffer of capacity during peak hours, and pre-scale ahead of known events like product launches and marketing emails.
Resilience Patterns
- Timeouts everywhere — no call waits forever.
- Circuit breakers stop hammering a failing dependency and fail fast.
- Bulkheads isolate thread pools so one noisy feature cannot starve the rest.
- Graceful degradation — recommendations can disappear; checkout cannot.
Results
After the migration the platform handled a 12x traffic increase during its biggest sales event with p99 latency of 96 ms, zero downtime and a 38% lower monthly cloud bill thanks to higher cache hit rates and right-sized instances.
Key Takeaways
- Measure first; the real bottleneck is rarely where you expect.
- Move everything the user is not waiting for onto an event stream.
- Pool connections and cache aggressively at the edge, in Redis and in process.
- Scale on demand signals, and design every dependency to fail safely.