Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Canva Engineering 11 min read Case study mediumAdept

Worker Backpressure (Part 1)

Canva added Worker Backpressure to its shared queue library: each worker records success/failure outcomes, a pluggable controller maintains a backoff factor (0.0 to 1.0) against a failure-rate set point, and the factor scales down how many messages the worker may poll and process concurrently. Everything runs locally with no coordinator, at a cost of two arithmetic operations per cycle. In a 4-hour multi-spike cloud outage the DLQ grew by one message. In a 32.5-hour quota overload, 1.8M failed attempts produced only 22 DLQ messages, against an estimated 16,000+ without backpressure. The tradeoffs are reduced throughput for saturated workers and reliance on a single success/failure signal, with latency and in-flight signals planned as future additions.

Assumes: message queues and workersdead letter queuescircuit breakers and backoff

Related posts

  • Enhancing Distributed System Load Shedding with TCP Congestion Control Algorithm

    Zalando Engineering mediumAdept

    Zalando's customer communication platform applies TCP-style AIMD (Additive Increase Multiplicative Decrease) congestion control at its ingestion point to shed load and prioritize critical messages. The Stream Consumer pulls events from Nakadi and watches RabbitMQ publish latency (P50) and publish errors as congestion signals. Each event type's throttle adjusts its consumption rate independently: higher-priority types increase faster and decrease less (e.g. +15/−20% for P1 vs +5/−60% for P3), so no central coordination is needed. After six months in production, order confirmations keep stable processing times while commercial messages absorb delays. RabbitMQ queues stay small, and backlog remains in Nakadi, where low-priority events can be discarded in an emergency.

  • Thundering herd of circuit breakers

    Zalando Engineering mediumAdept

    A client's circuit breaker stayed open for hours because its half-open probes hit a service that the HPA had scaled down to three pods. The sparse probes succeeded, the breaker closed, and the withheld traffic arrived at once, queued for over 100 ms per request, timed out and re-opened the breaker. Each cycle lasted only about three seconds, too short for CPU-averaged autoscaling to notice. Zalando found the cycle by exporting OpenTelemetry traces as CSV into a bespoke uPlot visualizer that plots hundreds of traces at once. Suggested fixes are autoscaling on queue depth or concurrency, longer or heavier half-open probes, pre-scaling before the breaker closes, load shedding, and propagating cancellations.

  • What is WAL backpressure, and why does ClickHouse Managed Postgres need it?

    ClickHouse hardMaster

    ClickHouse Managed Postgres prevents WAL-full PANICs, which happen when writes outpace archiving to object storage, by throttling client write bandwidth with the cgroup v2 I/O controller. A systemd timer counts pending WAL segments every 15 seconds and applies tiered write caps of 80%, 50% and 20% of provisioned disk throughput at 100, 500 and 1,000 segments. Processes are sorted by process title into an immune cgroup (archiver, checkpointer, WAL writer, logger) and a throttled one (client backends), and reads are never capped. In a pgbench test with a rate-limited archive_command, the backlog peaked at 3,433 segments (53 GiB), the disk never passed 33% full, and the backlog drained in under four minutes once storage recovered. One caveat: WAL-heavy workloads see throughput cut much more than WAL production, which fell only about 10%.

  • Leveraging Go Worker Pools to Scale Server-side Data Sharing

    Shopify Engineering mediumAdept

    Shopify's Server Pixels service, a Go pipeline that consumes over a billion customer events per day from Kafka, fell behind on consumer lag because it spawned an unbounded number of goroutines to process and produce event batches. Replacing that with a fixed-size worker pool fed by a jobs channel, built on a reusable Worker interface and shut down gracefully with context cancellation and WaitGroups, bounded resource use. Throughput per pod rose from 7.75k to 12.9k events/sec with 15 workers, 19.3k with 50, and 21k after further tuning, a 170% gain. That headroom carried the service through a 46k events/sec peak during BFCM 2021.

  • Upgrade to Puma 7 and Unlock the Power of Fair Scheduled Keep-alive

    Heroku Engineering mediumAdept

    Puma 6 and earlier let a single keep-alive connection monopolize a thread for up to 10 requests via the "fast inline" loop originally built for HTTP pipelining, so under overload about one in ten requests waited roughly 10x longer while later keep-alive requests cut the line. Puma 7 fixes this by requeuing pipelined and keep-alive requests at the back of the queue and removing the wait_until_not_full block on the accept loop. To keep load balanced across workers, it extends wait_for_less_busy_worker with a proportional sleep, so busier workers wait longer before accepting. Capacity is unchanged, but overload delay is now spread fairly; upgrading to 7.1.0+ is recommended, especially for Heroku Router 2.0 users who disabled keep-alives.

The quest for software engineering knowledge.

Look:
Layout: