963963Chat Independent coverage of news

Understanding Rate Limiting: Costs, Limits and Trade-offs

By David Kim · · 1165 words
Understanding Rate Limiting: Costs, Limits and Trade-offs

Content Delivery: The interesting number is not the average, it is the 99th percentile. Content Delivery: Adding a cache in front of a slow query is a fix; fixing the query is a cure. Content Delivery: Every abstraction you add is a place where behaviour can differ from intent.

Rate Limiting: The first thing to settle is the failure mode, not the happy path. Rate Limiting: Measurements taken once are anecdotes; you need a baseline that repeats. Rate Limiting: Costs usually concentrate in a small number of operations, so find those first.

Release Process: If a metric has no owner, it will drift until it causes an incident. Release Process: The cheapest optimisation is usually removing work nobody asked for. Release Process: Aggregating at write time trades flexibility for predictable read cost.

API Design: A queue smooths spikes but also hides how far behind you are. API Design: Retries without jitter turn a small outage into a large one. API Design: Separating the reads from the writes buys room to change either side.

For cost controls, the constraint matters more than the feature list. If a metric has no owner, it will drift until it causes an incident. Teams working on cost controls usually discover this the hard way. The cheapest optimisation is usually removing work nobody asked for. Aggregating at write time trades flexibility for predictable read cost. This is most visible in cost controls.

If a metric has no owner, it will drift until it causes an incident. This is most visible in observability. Consider observability specifically. The cheapest optimisation is usually removing work nobody asked for. Observability: Aggregating at write time trades flexibility for predictable read cost.

Consider crawl budget specifically. Serving static bytes is the cheapest thing you can do at the edge. Crawl Budget: A schema is an interface; changing it is a migration, not an edit. Track the denominator as carefully as the numerator. That applies to crawl budget as well.

You can often replace a coordination problem with an idempotency key. That applies to content delivery as well. In practice, content delivery behaves differently: Anything that grows without a bound will eventually hit one. Documentation that is not tested tends to describe the previous version. The same reasoning holds for content delivery.

In practice, data pipelines behaves differently: A queue smooths spikes but also hides how far behind you are. Retries without jitter turn a small outage into a large one. The same reasoning holds for data pipelines. For data pipelines, the constraint matters more than the feature list. Separating the reads from the writes buys room to change either side.

Rate Limiting: The interesting number is not the average, it is the 99th percentile. Rate Limiting: Adding a cache in front of a slow query is a fix; fixing the query is a cure. Rate Limiting: Every abstraction you add is a place where behaviour can differ from intent.

Edge Caching: You can often replace a coordination problem with an idempotency key. Edge Caching: Anything that grows without a bound will eventually hit one. Edge Caching: Documentation that is not tested tends to describe the previous version.

Search Indexing: If a metric has no owner, it will drift until it causes an incident. Search Indexing: The cheapest optimisation is usually removing work nobody asked for. Search Indexing: Aggregating at write time trades flexibility for predictable read cost.

Load Balancing: A design that cannot be rolled back is a design that cannot be changed safely. Load Balancing: Latency budgets are easier to defend when every hop has a stated ceiling. Load Balancing: Caching helps only until the invalidation rules become the bottleneck.

Teams working on schema migration usually discover this the hard way. You can often replace a coordination problem with an idempotency key. Anything that grows without a bound will eventually hit one. This is most visible in schema migration. Consider schema migration specifically. Documentation that is not tested tends to describe the previous version.

The interesting number is not the average, it is the 99th percentile. That applies to log analysis as well. In practice, log analysis behaves differently: Adding a cache in front of a slow query is a fix; fixing the query is a cure. Every abstraction you add is a place where behaviour can differ from intent. The same reasoning holds for log analysis.

If the rollback plan needs a meeting, it is not a rollback plan. The same reasoning holds for storage tiers. For storage tiers, the constraint matters more than the feature list. Small pages that stay small are easier to keep fast than large ones made fast. Teams working on storage tiers usually discover this the hard way. Write the invariant down; otherwise it lives only in someone's memory.

Schema Migration: A queue smooths spikes but also hides how far behind you are. Schema Migration: Retries without jitter turn a small outage into a large one. Schema Migration: Separating the reads from the writes buys room to change either side.

Cost Controls: You can often replace a coordination problem with an idempotency key. Cost Controls: Anything that grows without a bound will eventually hit one. Cost Controls: Documentation that is not tested tends to describe the previous version.

Teams working on api design usually discover this the hard way. Serving static bytes is the cheapest thing you can do at the edge. A schema is an interface; changing it is a migration, not an edit. This is most visible in api design. Consider api design specifically. Track the denominator as carefully as the numerator.

The first thing to settle is the failure mode, not the happy path. This is most visible in storage tiers. Consider storage tiers specifically. Measurements taken once are anecdotes; you need a baseline that repeats. Storage Tiers: Costs usually concentrate in a small number of operations, so find those first.

A design that cannot be rolled back is a design that cannot be changed safely. That applies to schema markup as well. In practice, schema markup behaves differently: Latency budgets are easier to defend when every hop has a stated ceiling. Caching helps only until the invalidation rules become the bottleneck. The same reasoning holds for schema markup.

Periodic jobs should be safe to run twice, because they will be. This is most visible in data pipelines. Consider data pipelines specifically. You rarely need a new component to fix a boundary problem. Data Pipelines: The signal you want is often already logged, just not aggregated.

Monitoring Alerts: Configurations should be reviewable in a diff, not only in a console. Monitoring Alerts: The best time to add an index is before the table gets large. Monitoring Alerts: Failures are usually correlated, so plan for the shared dependency.

Crawl Budget: Serving static bytes is the cheapest thing you can do at the edge. Crawl Budget: A schema is an interface; changing it is a migration, not an edit. Crawl Budget: Track the denominator as carefully as the numerator.

Related reading