The challenge
The department’s flagship survey platform was designed to gather responses from tens of millions of residents. A smaller pre-campaign trial surfaced reliability concerns that the team needed to address before a planned national push. On the eve of the full rollout, demand spiked to 26 million user journeys in a day and stayed elevated for four weeks. To stay ahead of the load the team kept over-provisioning ECS capacity, yet latency still crept past 150 ms and DynamoDB costs surged. The mandate was clear: make the application leaner, faster, and cheaper, without compromising the citizen experience.
What we did
We embedded with the client’s engineers and mapped the end-to-end request journey using AWS X-Ray, complementing traces with deep-dive local profiling of the Python and Flask layers. That evidence surfaced three hotspots: redundant DynamoDB reads, inefficient serialisation of survey payloads sourced from JSON metadata files, and chatty inter-service calls within the API tier.
- •Refactored the request lifecycle to cache immutable survey metadata stored in JSON files as well as eliminating thousands of unnecessary DynamoDB queries per minute.
- •Optimised Flask blueprints and response streaming so the platform moved data once, not three times, between middleware layers.
- •Right-sized ECS task definitions and autoscaling policies to match the newly efficient workload profile, using profiling dashboards to guide confident reductions.
Together, these changes cut the average request duration from 150 ms to just 60 ms and unlocked 2.5× more throughput from every container.
The outcome
Faster code meant fewer servers. At peak, the platform previously needed 45 ECS tasks (each 2 vCPU/4 GiB) running on c5.xlarge-backed EC2 instances to absorb 301 requests per second. After optimisation the same traffic sailed through just 18 tasks, a 60% reduction in compute. That efficiency uplift let the team dial back their on-demand footprint while comfortably meeting the four-week surge in demand.
Instead of sweating escalating cloud bills, the department can now reinvest a sizeable share of its former infrastructure spend into citizen-facing improvements, confident that their ECS estate scales in line with genuine demand.
Those efficiencies freed budget for new citizen-facing features, while AWS X-Ray and our bespoke profiling playbooks left the in-house team with the observability muscle to keep iterating confidently.
Ready to transform your platform’s performance?
We specialise in squeezing every millisecond out of cloud-native applications so you can serve more users with less spend.