Posts about backend
13 posts
-
Circuit breakers: failing fast when a dependency is down
When a downstream service is struggling, waiting on it makes things worse. A circuit breaker stops calling it for a while so both sides can recover.
-
Retrying failed requests with exponential backoff and jitter
A retry loop can rescue a request or take down a struggling service. Here is how to retry with backoff, jitter and a budget so it does the first.
-
Zero-downtime schema migrations with expand and contract
Old and new code run side by side during every deploy. Here is how to change a database schema in small, safe steps so neither version breaks.
-
Graceful shutdown: handling SIGTERM without dropping requests
Every deploy stops your old processes. Here is how to handle SIGTERM so in-flight requests finish, connections close cleanly and users never notice.
-
Structured logging: why your logs should be JSON
Plain text logs are easy to write and hard to search. Here is how structured logs with consistent fields make debugging production services faster.
-
Liveness vs readiness: writing health checks that actually help
What liveness and readiness checks are for, why mixing them up causes restart loops, and how to write health endpoints that tell your platform the truth.
-
Database connection pooling: what it is and how to size it
Why opening a database connection per request hurts, how a connection pool fixes it, and how to choose pool sizes that do not overload your database.
-
Rate limiting APIs with the token bucket algorithm
How the token bucket works, why it handles bursts better than a fixed window, and what to think about when you run it across several servers.
-
HTTP caching basics: Cache-Control and ETags
How browsers and proxies decide when to reuse a response, and how Cache-Control and ETags let your API skip work it has already done.
-
Access tokens and refresh tokens: why APIs use two
A short-lived access token plus a longer-lived refresh token is a common login pattern. Here is what each one does and how to handle them safely.
-
Database indexes, explained without the magic
Indexes fix slow queries but can slow down writes. What they actually do, and how to decide when one is worth it.
-
Idempotent APIs and why retries should be safe
Networks fail in awkward ways. Designing endpoints so that a repeated request does no extra harm is one of the cheapest reliability wins you can get.
-
Typed configuration in FastAPI with pydantic-settings
Load and validate environment variables once, fail fast on bad config, and keep secrets out of your code: a small pattern I use in every FastAPI service.