System DesignData Pipelines

Designing a Real-Time Data Pipeline for 50k QPS Using CDC

Build a data pipeline using change data capture to handle 50k QPS. The challenge: maintaining low latency and data consistency under load.

Aug 17, 20264 min readOriginal analysis
Fig. 01 — Architecture
Data flows from user devices through Kinesis to Debezium, processed by Lambda, and stored in DynamoDB.
01

The scenario

A large e-commerce platform is migrating from a batch ETL to a real-time data pipeline to support 50,000 queries per second (QPS) for its recommendation engine. The team has a budget of $50,000/month and consists of 5 engineers. Compliance with GDPR is mandatory, meaning data lineage and user consent tracking are crucial. Failure to maintain real-time updates could lead to stale recommendations, impacting user engagement and sales.

02

Requirements

  • R1Handle 50,000 QPS with 99.9% uptime
  • R2End-to-end latency under 500ms
  • R3Data consistency across multiple regions
  • R4Budget of $50,000 per month
  • R5Compliance with GDPR for data handling
  • R6Real-time update capability (sub-second latency)
03

The design

3.1Data Ingestion

We use Amazon Kinesis for ingesting user interaction data, which provides the scalability needed to handle 50,000 QPS. Kinesis is chosen over Kafka due to its managed nature and ease of integration with other AWS services, reducing operational overhead.

3.2Change Data Capture

Change data capture is implemented with Debezium, running on Amazon MSK. Debezium captures changes from our PostgreSQL databases, ensuring real-time data flow. This choice allows us to minimize data staleness and provides reliable CDC with minimal configuration.

3.3Processing Layer

AWS Lambda functions are used for processing data streams, transforming raw data into a format suitable for the recommendation engine. AWS Glue is considered but rejected due to its higher latency and cost at this scale.

3.4Data Storage

Amazon DynamoDB is used for storing processed data due to its low-latency read/write capabilities and global table support, ensuring data consistency across regions. This is critical for GDPR compliance and real-time analytics.

3.5Monitoring and Compliance

Amazon CloudWatch is employed for monitoring pipeline performance and alerting on anomalies. We also use AWS CloudTrail to ensure compliance with GDPR by tracking data access and modifications.

04

Capacity math

MetricValue
Peak QPS50,000 req/s
Kinesis Throughput100 MBps
Lambda Execution200ms p99
DynamoDB Read/Write10,000 RCU/WCU
05

Trade-offs

Managed vs Self-Hosted

Picked

Managed (AWS)

Passed on

Self-Hosted Kafka

Reduced operational complexity and better integration with AWS ecosystem.

Data Storage

Picked

DynamoDB

Passed on

Amazon RDS

Chosen for its scalability and global table support.

Processing Framework

Picked

AWS Lambda

Passed on

AWS Glue

Lambda offers lower latency and cost at high QPS.

06

Failure modes

What breaksSymptomMitigation
Kinesis OverloadData ingestion lagsAuto-scaling shards based on traffic patterns.
CDC Lag or FailureDelayed data updatesDebezium monitoring and alerting for lag.
Lambda TimeoutIncomplete processingOptimize code and increase timeout settings.

Editor's Verdict

This design uses AWS's managed services to keep operational overhead low while ensuring compliance and scalability. It opts for straightforward technologies like Kinesis and DynamoDB, which are well-understood and reliable at scale. As the system scales beyond 10x, the team may need to consider more granular shard management in Kinesis and explore cost optimizations in Lambda invocations. One common pitfall is under-provisioning read/write capacities in DynamoDB, leading to unexpected throttling—ensure capacity aligns with peak demands.

Related Data Pipelines coverage

One design a week

The next blueprint lands Tuesday.

Plus the week's AI/ML data engineering news, curated. Free.