DEV Community

Cover image for Building Data Infrastructure for 50K Queries per Second and Still Making Room for New Features
ruth mhlanga
ruth mhlanga

Posted on

Building Data Infrastructure for 50K Queries per Second and Still Making Room for New Features

The Problem We Were Actually Solving

At this scale, our system would start to choke on any additional changes to the data model or query patterns. We were essentially at a standstill, unable to innovate or even meet the growing demand for more personalized recommendations. Our team's solution, codenamed "Veltrix," would need to handle more than just raw query volume – it had to enable the team to build new features and models that would scale seamlessly alongside the data.

What We Tried First (And Why It Failed)

We first attempted to build out our existing warehouse using a standard incremental load architecture. This meant that we'd load a few days' worth of new data into the warehouse overnight, and then run batch queries against that data to generate the reports and analytics that our business users needed. This approach, however, exposed a critical flaw: whenever we changed our data model, the batch queries broke and required manual intervention to fix. We tried to mitigate this by introducing a new data quality pipeline that could catch any errors and prevent them from propagating downstream. But as the complexity of our data model grew, so did the likelihood of new errors, and the team's manual fixing times ballooned.

The Architecture Decision

We eventually realized that batch processing wasn't the right fit for our use case. We decided to switch our warehouse over to a streaming architecture, using a distributed event store like Kafka to handle the raw data ingest. This allowed us to build event-sourced microservices that could publish and subscribe to stream data in real-time. On top of this foundation, we built out a new batchless ETL stack that would process the stream data in real-time and load it into the warehouse. This change gave us a lot more flexibility to change the data model without affecting the queries, and eliminated the problem of manual fixing times.

What The Numbers Said After

After implementing the new architecture, we saw a 40% reduction in query latency, and a 75% decrease in manual fixing times. Our customers were much happier, and the business team was able to move forward with new feature development. We also measured a 25% decrease in warehouse costs due to the elimination of batch query overhead. But perhaps the most telling metric was the number of changes to the data model that we could safely deploy without breaking the queries – it went from 10% of change requests being blocked to above 90% being deployable without issue.

What I Would Do Differently

In hindsight, I wish we had taken a more incremental approach to deploying the new architecture. We went from 0% to 100% streaming in a single, chaotic sprint that cost us a lot of time and sweat. I would encourage other teams to take a more measured approach and rollout changes to production gradually, using techniques like canary releases to ensure that the change doesn't break the entire system.

Top comments (0)