---
title: "What today's software owes to Bronze Age clocks"
description: "Leaky buckets, descended from Bronze Age water clocks, remain a cheap admission-control mechanism: a bucket stores only its last level and timestamp, so its current level can be computed lazily as max(0, level_then − drain_rate × elapsed)."
url: "https://swe.quest/articles/what-today-s-software-owes-to-bronze-age-clocks-f1c84fb59510a8bf"
canonical: "https://planetscale.com/blog/leaky-buckets-in-software-explained"
source: "PlanetScale"
published: "2026-10-07"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 8
tags: ["resilience","postgres","api-design","algorithms"]
---

# What today's software owes to Bronze Age clocks

A post on [PlanetScale](https://swe.quest/sources/planetscale.md), published 2026-10-07, 8 min read, Deep dive. Original: [https://planetscale.com/blog/leaky-buckets-in-software-explained](https://planetscale.com/blog/leaky-buckets-in-software-explained)

## Summary

Leaky buckets, descended from Bronze Age water clocks, remain a cheap admission-control mechanism: a bucket stores only its last level and timestamp, so its current level can be computed lazily as max(0, level\_then − drain\_rate × elapsed). Shopify's GraphQL API shows the pattern in practice, charging an estimated query cost up front and refunding or charging the difference afterward. Postgres and MySQL lack built-in admission control, unlike Oracle Resource Manager and SQL Server Resource Governor, so PlanetScale's Database Traffic Control adds token-bucket resource budgets to Postgres. Each budget has a server-share refill rate, a burst limit in whole-server seconds, a per-query limit and a maximum concurrent workers setting, with costs estimated from query plans and history. PlanetScale recommends running a new budget in warning mode before switching it to blocking.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Resilience](https://swe.quest/tags/resilience.md) (Distributed systems)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [API design](https://swe.quest/tags/api-design.md) (Backend & APIs)
- [Algorithms](https://swe.quest/tags/algorithms.md) (Architecture & design)

## Prerequisites

- rate limiting basics
- Postgres query execution ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))

## Keywords

leaky bucket, token bucket, Database Traffic Control, PlanetScale, Shopify GraphQL Admin API, Oracle Database Resource Manager, SQL Server Resource Governor

## Related posts

- [Introducing DBArena: open, reproducible benchmarks for hosted Postgres](https://swe.quest/articles/introducing-dbarena-open-reproducible-benchmarks-for-hosted-postgres-fcea976f1f3d4cee.md): Supabase · 2026-10-30 · Medium · 4 min read · PostgreSQL, Performance engineering, Cloud platforms, Cost optimization
  DBArena publishes open, reproducible benchmarks of hosted Postgres, starting with Supabase Postgres (heap and OrioleDB), Amazon RDS and Google Cloud SQL across up to seven vCPU-matched tiers on Postgres 17 with default configs.
- [PGKeeper: Building the bouncer we needed for Postgres](https://swe.quest/articles/pgkeeper-building-the-bouncer-we-needed-for-postgres-b0a410376e101175.md): Figma · 2026-05-04 · Medium · 19 min read · PostgreSQL, Resilience, Go, Databases, Scaling
  Figma replaced PgBouncer with PGKeeper, a Go service built on PGX that sits between its DBProxy router and each Postgres instance.
- [Beyond synthetic testing: Capturing and replaying real database workloads at Airbnb](https://swe.quest/articles/beyond-synthetic-testing-capturing-and-replaying-real-database-workloads-at-ad8d4a3a0c1cef6e.md): Airbnb Engineering · 2026-10-06 · Medium · 11 min read · MySQL, Testing, Capacity planning, Performance engineering, Databases
  Airbnb replaced fragmented per-language client-side query logging with a client-agnostic capture point in ProxySQL, so real production MySQL traffic can be replayed offline.
- [Interning at incident.io: rate limiting, resiliently](https://swe.quest/articles/interning-at-incident-io-rate-limiting-resiliently-703eb65d0ab42974.md): incident.io · 2026-09-02 · Medium · 10 min read · Resilience, Algorithms, Kubernetes, Engineering culture
  incident.io made its rate limiter keep working when its Valkey backing store (Google Cloud Memorystore) is unavailable, instead of failing open.
- [We replaced Redis with MySQL for inventory reservations—and it scaled](https://swe.quest/articles/we-replaced-redis-with-mysql-for-inventory-reservations-and-it-scaled-2f8fab4ab3565f02.md): Shopify Engineering · 2026-05-12 · Medium · 10 min read · MySQL, E-commerce, Concurrency, Scaling, Performance engineering
  Shopify moved checkout inventory reservations from Redis to MySQL by modeling one row per sellable unit and using SELECT ...

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
