tezvyn:

High-throughput serverless stream processing

AI-drafted, machine-checkedSource: interviewadvanced
WHAT IT TESTS

stream design at scale.

OUTLINE

partition by key for per-user ordering, use a sharded log with batched consumers for backpressure, and tune batch size and shards for cost.

RED FLAG

a global FIFO queue or per-event invocation at 100k/sec.

WHAT THIS TESTS This assesses whether you can design a serverless pipeline that handles extreme throughput while preserving per-entity ordering and staying cost-effective, balancing three competing constraints.

A GOOD ANSWER COVERS Use a partitioned, durable log stream such as Kinesis or Kafka rather than a plain queue. Choose the partition key as the user ID so every event for a given user hashes to the same shard; within a shard order is preserved, giving per-user ordering without the bottleneck of global ordering. Consumers read in batches; the log itself buffers events, so backpressure is handled naturally because consumers pull at their sustainable rate and the log retains data until processed. Scale by adding shards, and use a parallelization factor to run multiple concurrent processors per shard only where ordering allows. Control cost by processing in batches instead of one invocation per event, tuning batch size and window to amortize invocation overhead, and right-sizing shard count to the throughput. Send poison records to a DLQ and checkpoint progress so failures resume without reprocessing everything.

COMMON WRONG ANSWERS Proposing a single global FIFO queue, which serializes everything and cannot reach 100,000 per second. Invoking a function per individual event, which is slow and costly. Trying to guarantee total global ordering when only per-user ordering is required. Ignoring checkpointing, so any failure replays the entire stream. Forgetting backpressure entirely and overwhelming downstream stores.

LIKELY FOLLOW-UPS Why partition by user ID specifically? How does batching cut cost? What happens with a hot shard? How do you handle a poison record without blocking its shard?

ONE CONCRETE EXAMPLE Events are written to a 100-shard Kinesis stream keyed by user ID. A consumer reads batches of 500 records per shard, preserving order per user; failed records go to a DLQ and the checkpoint advances past them. Throughput scales with the number of shards while batching keeps the per-event invocation cost low, meeting the 100,000 per second target affordably.

Read the original → cloud.google.com

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.