Question

Difficulty: Very hardCost-Optimized Database Design and Capacity Planning

A smart grid utility company collects hourly electricity consumption metrics from 7.27.2 million smart meters. Each meter sends a 1 KB write payload once per hour, distributed evenly throughout the day, establishing a highly predictable baseline rate. However, during grid maintenance or unexpected outages, up to 33 million smart meters simultaneously send status updates, causing sudden, unpredictable ingestion spikes of up to 100,000100,000 writes/second that last for less than 5 minutes. The company wants to minimize overall database and ingestion costs while ensuring no data is throttled or lost.

Which architecture meets these requirements most cost-effectively?

  1. Configure the Amazon DynamoDB table in provisioned capacity mode with Auto Scaling to handle the steady baseline. Buffer the incoming meter payloads using an Amazon SQS queue, and consume messages using AWS Lambda to write to the table at a controlled rate.Answer
  2. B
    Configure the Amazon DynamoDB table in provisioned capacity mode with Auto Scaling enabled, setting the maximum write capacity to 100,000100,000 WCUs to dynamically handle anomaly events.
  3. C
    Configure the Amazon DynamoDB table in provisioned capacity mode with Auto Scaling, and use a partition key composed of the current timestamp to ensure sequential order when writing anomalies directly to the table.
  4. D
    Deploy an Amazon RDS for PostgreSQL Multi-AZ DB instance to store the data, and configure the smart meters to route write spikes to read replicas during grid anomaly events to prevent overloading the primary DB instance.

Answer

Configure the Amazon DynamoDB table in provisioned capacity mode with Auto Scaling to handle the steady baseline. Buffer the incoming meter payloads using an Amazon SQS queue, and consume messages using AWS Lambda to write to the table at a controlled rate.
The correct architecture uses an Amazon SQS queue to buffer the high-volume ingestion spikes, decoupling the ingestion layer from the database layer. This allows the DynamoDB table to be provisioned for the steady baseline rate (2,0002,000 WCUs), saving significant costs compared to DynamoDB On-Demand capacity mode or provisioning for the peak capacity of 100,000100,000 WCUs. AWS Lambda consumes from the queue and writes to DynamoDB at a controlled rate, ensuring no writes are lost or throttled.

Step-by-Step Solution

1
Analyze the baseline and peak workload characteristics.
Baseline requires 2,0002,000 WCUs (since 7.27.2 million writes per hour is 2,0002,000 writes/sec, and 1 KB requires 1 WCU). Peak requires 100,000100,000 WCUs but lasts for less than 5 minutes.
Understanding the workload helps evaluate the cost tradeoffs of different capacity planning strategies.
2
Compare the costs of DynamoDB capacity modes.
On-demand capacity mode for 172.8172.8 million daily writes costs $216\approx \$216/day ($6,480\approx \$6,480/month). Provisioned capacity mode for the baseline of 2,0002,000 WCUs costs $31.20\approx \$31.20/day ($936\approx \$936/month).
To achieve cost-optimization, provisioned capacity is preferred for the high steady baseline, provided spikes can be handled without throttling.
3
Evaluate buffering mechanisms to handle the short-duration spikes.
An Amazon SQS queue can absorb the sudden 100,000100,000 writes/sec write spikes. An AWS Lambda function can pull from SQS and write to DynamoDB at a throttled, controlled pace.
Decoupling with SQS flattens the ingestion curve, allowing the database to be provisioned for baseline throughput without throttling or data loss.

Key Concept

Decoupling architectures to flatten ingestion spikes and optimize database provisioned capacity costs.
Rate this question