Guide
Premium
Intermediate
Real Projects

Load Shedding and Adaptive Concurrency Limits: Degrade Instead of Collapsing

A practical guide to the mechanism that decides whether your service degrades in an orderly way or collapses entirely when the spike arrives: why throughput falls off a cliff exactly when you need it most (goodput versus throughput and congestive collapse), Little’s Law applied to the concurrency limit your service already has even though you never wrote it down, why RPS rate limiting protects you from nothing when per-request cost is variable, the anatomy of a cheap rejection (503 with Retry-After before touching the database, and the per-request log line that sinks you precisely during overload), adaptive limits with AIMD implemented step by step — including the rule of not growing when you are not using the limit, which is what separates a limiter from an ornament — the Netflix and Envoy gradient controller with the minRTT formula and the periodic recalibration trap that fires a burst of 503s every thirty seconds, the queue you cannot see (kernel backlog, somaxconn and the worker pool) tamed with CoDel and adaptive LIFO so you stop serving requests the client already abandoned, criticality-based shedding with reserved budgets so checkout stays alive while analytics goes dark, the correct middleware order, why failing the readiness probe under load turns an overload into a full outage through cascading pod removal, what the client receiving a 503 should do (full-jitter backoff, propagated deadline budget and retries downgraded in criticality, plus a retry budget so you do not amplify), observability with the four metrics that matter, PromQL and Prometheus alerts, and how to validate all of it with k6 in an open model hunting for the saturation point. With production-ready code in Python, TypeScript, YAML and PromQL, eight recurring mistakes, a production checklist, FAQ and glossary.

42 minutes read
Josué García Puig
3 views

Verificando acceso...

Loading comments...

Related Resources

Guía
PREMIUM

API Versioning and Contract Testing: Safe Changes, OpenAPI in CI, Pact, and Retiring Endpoints with Sunset

A practical guide to changing your APIs without breaking the people who consume them: why compatibility rules invert between the request and the response —and why widening a returned enum breaks clients even though you are "only adding"—, the tolerant reader pattern in Pydantic with an escape hatch and a metric, OpenAPI generated from the code and diffed on every pull request with oasdiff (including the git diff --exit-code step without which the whole check is theatre), consumer-driven contract testing with Pact: type matchers instead of literal values, well-designed provider states, version selection with deployed_or_released, and the gate that actually makes it safe, can-i-deploy paired with record-deployment. It also covers rolling this out without stopping the factory using pending and WIP pacts, bi-directional contracts when the provider is a third party, the three versioning strategies with their real operational costs, why versioning the whole API for a single endpoint guarantees nobody migrates, retiring versions with the Deprecation (RFC 9745) and Sunset (RFC 8594) headers plus the migration Link, the per-consumer metric without which no sunset date is ever met, brownouts returning 410 Gone before the final shutdown, and the BACKWARD, FORWARD and FULL compatibility modes for event schemas. With production-ready code in Python, YAML, Bash and PromQL, eight recurring mistakes, a production checklist, FAQ and glossary. It also extends the contract beyond the happy path: errors with RFC 9457 (problem+json), cursor pagination and defaults as part of the contract, the expand/contract pattern for renaming a field across database and API with no maintenance window, governance with Spectral, buf breaking for gRPC and Protobuf, GraphQL schema evolution with @deprecated and real per-field usage, and semantic versioning of generated SDKs. It also covers the contracts that never show up in the schema and break just as hard: outbound webhooks with the version pinned on the subscription, HMAC signing with a timestamp window and key rotation, Idempotency-Key for safe POST retries, the RateLimit and RateLimit-Policy headers —and why lowering a limit is a breaking change—, and OAuth scopes, the blind spot no OpenAPI diff will ever catch.

Guía
PREMIUM

asyncio in Production: Never Block the Event Loop — TaskGroups, Cancellation and Bounded Concurrency

A practical asyncio guide for Python services in production: why blocking the event loop degrades the whole process without raising a single exception, how to catch it by measuring loop lag and with Python 3.14 introspection, structured concurrency with TaskGroup and handling ExceptionGroup via except*, the task the garbage collector makes vanish, timeouts with a deadline budget propagated across services, correct cancellation with cleanup and shield, bounded concurrency with semaphores and backpressured queues, synchronization primitives, and what changes with eager tasks, python -m asyncio pstree and free-threading. With production-ready code and a deployment checklist.

Guía
PREMIUM

Cache-Aside in Production: TTLs, Invalidation, and How to Prevent Cache Stampedes

The complete guide to the cache-aside pattern with Redis: jittered TTLs, correct invalidation, and the three defenses against cache stampedes (distributed lock, single-flight, and XFetch). Expanded with stale-while-revalidate, fail-open and circuit breakers, two-tier caching with RESP3 invalidation, delayed double delete and CDC, hot keys, eviction and memory management, observability with Prometheus, testing, choosing an engine (Redis, Valkey, Memcached), and a complete TypeScript implementation. With production-ready code in Python and TypeScript.