Building Scalable REST APIs (Part 5): Versioning, Observability and Production Operations
Run REST APIs safely in production with versioning, backward compatibility, SLOs, tracing, structured logs, metrics, deployment safety, deprecation and incident-response patterns.

The hardest part of an API usually starts after launch.
Designing resources, choosing status codes and writing controllers are relatively contained problems. Running an API for years while mobile apps, partners, web clients, scheduled jobs and internal systems all depend on it is where architecture gets tested.
A production API needs to survive four things at once:
- clients you do not deploy at the same time as the server;
- traffic patterns you did not predict;
- failures in systems you do not control;
- change.
This final part of the series is about making change boring.
Backward compatibility is a product feature
Once an API has external consumers, its contract is no longer just an implementation detail.
A seemingly harmless change can break clients:
// Before
{
"total": 12.50
}
// After
{
"total": {
"amount": 12.50,
"currency": "GBP"
}
}
The second shape may be objectively better, but it is still a breaking change.
Other common breaking changes include:
- renaming fields;
- changing a field from nullable to required;
- narrowing accepted enum values;
- changing pagination semantics;
- changing status codes that clients branch on;
- removing fields;
- changing sort order;
- changing an identifier’s format;
- making formerly optional authentication mandatory;
- changing retry behaviour or idempotency guarantees.
The safest API teams develop a habit of asking: could an existing client reasonably depend on this behaviour?
If yes, treat it as contract surface.
Prefer additive evolution
Additive changes are usually easier to roll out safely.
Instead of replacing:
{
"name": "SiteTidy"
}
with a radically different object, add what you need:
{
"name": "SiteTidy",
"legalName": "Example Ltd"
}
Clients that ignore unknown fields continue working.
This only works if your client guidance explicitly says consumers must tolerate additional response properties.
For request bodies, the compatibility direction is different. Servers should be careful when introducing required request fields because older clients cannot send them.
A useful rule of thumb is:
responses: adding optional fields is usually safe
requests: adding required fields is usually breaking
“Usually” matters. Behaviour and validation can still make apparently additive changes disruptive.
Do not version automatically
Versioning is a tool for managing incompatible contracts, not a badge that makes an API professional.
If you can evolve an API compatibly, you often do not need a new version.
When you truly need a breaking change, common strategies include:
/api/v1/orders
/api/v2/orders
or version negotiation through media types/headers.
URI versioning is easy to understand and operate, which is why many public APIs use it. Header/media-type versioning can keep resource URLs cleaner but often adds complexity to debugging, gateways, docs and client tooling.
There is no universal winner. Choose a strategy that your consumers and operations teams can support consistently.
The bigger mistake is creating v2 and leaving v1 alive forever with no owner, no retirement criteria and no telemetry.
Version the contract, not every deployment
Your API may deploy twenty times in a week without changing its public version.
A public API version should represent a compatibility boundary, not a software release number.
Avoid URLs like:
/api/v2026.08.31.4/orders
unless your domain genuinely requires date-versioned snapshots.
Internally, still record the exact application/build version handling each request. That information is invaluable for incident diagnosis.
Deprecation needs evidence, not hope
Before removing an endpoint or version, you need to know who still uses it.
Track usage by:
- route;
- API version;
- client/application ID;
- tenant;
- user agent where useful;
- authentication credential or integration identifier;
- last-seen timestamp.
Then deprecation can be managed deliberately:
announce
-> mark deprecated in docs/schema
-> notify known consumers
-> instrument remaining traffic
-> offer migration guidance
-> set retirement date
-> reduce unknown usage to an acceptable level
-> retire
Do not rely on page views to your API documentation as evidence that clients migrated.
Keep an API inventory
At scale, teams often lose track of what is actually deployed.
Maintain an inventory of:
hostname
environment
API/version
owner
repository
runtime
base path
authentication model
data classification
deprecation status
support contact
This sounds administrative until an incident begins with, “What is legacy-api-2.example.net, and is anyone still using it?”
Inventory is an operational control and a security control.
Observability starts with a request ID
When a user reports that an API request failed, the fastest path to diagnosis is usually a stable identifier that follows that request through the system.
Generate or accept a correlation/request ID according to a controlled policy, return it to the client where useful, and include it in structured logs.
For distributed systems, propagate trace context rather than inventing incompatible per-service identifiers.
A useful log event might contain:
{
"timestamp": "2026-08-31T11:42:17.013Z",
"level": "Information",
"requestId": "01K4...",
"traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
"method": "GET",
"route": "/api/orders/{id}",
"statusCode": 200,
"durationMs": 41,
"tenantId": "tenant_123",
"serviceVersion": "2026.08.31.3"
}
Notice what is not there: bearer token, session cookie, password or entire request body.
Log routes, not high-cardinality URLs
This is a small detail that saves real money.
If you record metrics by raw URL:
/api/orders/100001
/api/orders/100002
/api/orders/100003
you create a new metric dimension for every order.
Record the route template instead:
/api/orders/{id}
The same principle applies to user IDs, request IDs and arbitrary search strings. Metrics systems perform poorly and become expensive when labels have unbounded cardinality.
High-cardinality identifiers belong in logs and traces, not ordinary metric labels.
The four signals that answer most API incidents
For each route or service, monitor at least:
Traffic — how many requests are arriving?
Errors — how many are failing, and how?
Latency — how long are requests taking, especially at tail percentiles?
Saturation — which constrained resource is approaching capacity?
Saturation might mean:
CPU
thread pool
DB connection pool
queue depth
memory
socket pool
disk I/O
downstream concurrency
Average latency is not enough. An API where 95% of requests take 60 ms and 5% take 10 seconds may have an innocent-looking average while users are suffering badly.
Track percentiles such as p50, p95 and p99 where they make operational sense.
Separate client errors from server errors
A spike in 4xx responses means something very different from a spike in 5xx responses.
Even within 4xx, classification matters:
400 validation failure
401 authentication failure
403 authorization failure
404 missing/not-visible resource
409 conflict
412 failed precondition
429 rate limited
A sudden jump in 401 after a release may indicate token validation/configuration trouble. A rise in 429 may mean abusive traffic, a client retry bug or a limit that no longer matches normal usage.
Do not create one dashboard called “API errors” and stop there.
Define SLOs around user-visible outcomes
An uptime target such as 99.9% is meaningless until you define what counts as available.
For an order API, a useful service-level indicator might be:
successful eligible order reads / total eligible order reads
You may exclude caller-caused validation failures from availability, while counting server errors and timeouts.
Latency SLOs should also be tied to meaningful routes or operations. A five-minute export job and a product lookup should not share the same target.
The purpose of an SLO is not to make a dashboard green. It creates a shared definition of acceptable service.
Error budgets make reliability trade-offs explicit
If your SLO permits a certain amount of failure, that allowance is the error budget.
Teams can use it to balance release speed against reliability work.
If the service is comfortably within budget, normal delivery can continue. If it is burning budget rapidly, the team should prioritise reliability, rollback, capacity or defect work.
This is healthier than declaring that every API must be “100% reliable,” which is impossible and leads to arbitrary decision-making when failures occur.
Trace the time, not just the request
A request that takes 1.8 seconds might spend its time like this:
API gateway 20 ms
application queue 80 ms
service code 40 ms
SQL query 120 ms
payment provider 1450 ms
serialization 15 ms
network 75 ms
Without distributed tracing, the application may be blamed for a problem that actually sits downstream.
Instrument important boundaries:
- inbound HTTP;
- outbound HTTP;
- database calls;
- queues/messages;
- cache operations;
- expensive domain operations.
Do not create a span for every trivial function. Tracing is useful when it explains latency and dependency flow.
Propagate deadlines
If the caller has two seconds left before giving up, a downstream service should not begin a 30-second operation as though it has unlimited time.
Carry cancellation/deadline information through the call chain where your stack allows it.
This prevents zombie work: requests that continue consuming CPU, DB connections and downstream capacity long after the caller has disappeared.
Timeouts should form a budget:
client timeout: 5.0 s
API budget: 4.5 s
downstream A timeout: 1.0 s
downstream B timeout: 2.0 s
Exact numbers depend on the operation. The important part is that they are intentional.
Retries need telemetry
Retries can improve reliability, but they can also hide an outage until load multiplies.
Measure:
original calls
retry attempts
retry success rate
retry exhaustion
backoff time
A downstream service that normally receives 1,000 requests/sec can suddenly receive several thousand when every caller retries aggressively.
Use bounded retries with jitter/backoff, and retry only operations whose semantics make it safe.
For mutation requests, idempotency design from Part 3 becomes critical.
Watch queue age, not just queue depth
For asynchronous APIs, queue depth alone can mislead.
A queue of 10,000 jobs may be healthy if workers process it in seconds. A queue of 50 may be a serious incident if the oldest job has waited an hour.
Useful queue metrics include:
depth
oldest-message age
enqueue rate
completion rate
failure rate
retry/dead-letter rate
worker saturation
Alert on user impact, not merely the existence of work.
Health checks should answer different questions
Avoid one giant /health endpoint that checks everything and marks the process dead whenever any dependency hiccups.
Separate concepts such as:
Liveness: is this process alive enough that restarting it might help?
Readiness: can this instance currently accept useful traffic?
Dependency health: what is the state of databases, queues and downstreams?
If every instance removes itself from service because a shared database is briefly unavailable, you can turn a dependency incident into a full routing collapse.
Health checks need the same careful failure design as the API itself.
Deploy in a backward-compatible sequence
Database and contract changes are where many otherwise safe releases fail.
Use expand-and-contract migrations.
Suppose full_name becomes first_name and last_name.
Do not deploy code that expects the new columns at the same moment you drop the old one.
A safer sequence is:
1. Add new schema while old remains valid.
2. Deploy code that can work during the transition.
3. Backfill data.
4. Switch reads/writes deliberately.
5. Verify old code is no longer running.
6. Remove old schema in a later deployment.
The same pattern applies to events, cache keys and API fields.
Rollouts should limit blast radius
A deployment does not need to reach every instance immediately.
Depending on platform and risk, use:
- rolling deployments;
- canaries;
- blue/green environments;
- feature flags;
- tenant-level rollout;
- percentage rollout.
The goal is not sophisticated release theatre. It is to expose a defect to 1% of traffic before exposing it to 100%.
Compare the new cohort with the old one using real metrics:
error rate
latency
CPU/memory
DB load
business conversion
queue behaviour
Then automatically or manually stop promotion when the evidence is bad.
Feature flags are not permanent architecture
Flags are useful for separating deployment from release, but stale flags create branching complexity.
Every temporary flag should have:
owner
purpose
creation date
expected removal date
Do not allow a codebase to accumulate hundreds of forgotten flags whose combinations nobody can test.
Contract tests are more useful than screenshots of Swagger
OpenAPI documentation is valuable, but having a schema does not prove compatibility.
Automate checks for important contract behaviour:
expected routes exist
required fields remain stable
status codes remain compatible
problem responses keep their shape
pagination links/cursors work
idempotency behaviour holds
authorization rules hold
For APIs with external consumers, consider schema-diff checks in CI that flag potentially breaking changes before merge.
A tool cannot understand every behavioural break, but it can catch obvious accidental ones.
Consumer-driven tests can help — with discipline
When a small number of known services depend on each other, consumer-driven contract testing can expose assumptions before deployment.
It becomes less useful if every consumer pins every incidental field and makes provider evolution impossible.
Contract tests should protect real compatibility requirements, not encode entire response snapshots simply because snapshot testing is easy.
Run load tests against realistic bottlenecks
A benchmark that serves a static 200 OK from memory tells you little about the API that joins five tables and calls two external services.
Test representative operations and realistic data volumes.
Include scenarios such as:
hot cache
cold cache
slow database
rate-limit activation
queue backlog
downstream latency
large tenant
high-cardinality search
burst traffic
The point of performance testing is to discover where the system bends before production traffic discovers it for you.
Capacity plans should follow the constrained resource
“10,000 requests per second” is not a capacity plan.
Different routes consume different resources.
One endpoint may be CPU-bound, another database-bound, another constrained by an external vendor quota.
Model expensive operations separately.
For example:
catalog reads limited primarily by cache/edge capacity
search limited by search-cluster CPU
exports limited by worker concurrency and DB I/O
payment creation limited by provider latency/quota
Then autoscaling and rate limits can target the actual constraint.
Incident response should be designed before the incident
When the API is failing, operators should not need to invent the investigation process.
Have a playbook that answers:
Where is the dashboard?
How do we identify the affected version?
Can we disable the feature?
Can we roll back safely?
How do we stop a retry storm?
How do we throttle one tenant?
How do we drain or pause a queue?
How do we contact a downstream provider?
Where are recent deployments shown?
The best operational architecture contains levers.
A service with no way to reduce load, disable a broken integration or roll back quickly is much harder to recover.
Post-incident work should change the system
A useful post-incident review is not a search for the person who made the mistake.
Ask:
What conditions made this failure possible?
Why did it reach users?
Why did detection take this long?
Why did recovery take this long?
Which safeguard would prevent or reduce recurrence?
Then create concrete actions with owners.
“Be more careful” is not an engineering control.
A better outcome might be:
add schema compatibility check
add canary gate on 5xx rate
set DB pool saturation alert
add idempotency to payment endpoint
remove unbounded export size
add runbook for vendor outage
A production operating checklist
Before treating an API as mature, verify that:
- compatibility rules are documented;
- breaking changes have a deliberate versioning strategy;
- deprecated versions have owners and retirement dates;
- route/version/client usage is measured;
- every request can be correlated across logs and traces;
- metrics use bounded-cardinality labels;
- latency percentiles, errors, traffic and saturation are visible;
- SLOs reflect user-visible operations;
- timeouts and cancellation propagate through dependencies;
- retries are bounded and observable;
- asynchronous work exposes age/backlog/failure metrics;
- readiness and liveness semantics are deliberate;
- database changes use backward-compatible deployment patterns;
- risky releases can be canaried or disabled;
- API contract changes are checked in CI;
- incident responders have dashboards, rollback paths and runbooks.
Audit the experience around your API too
SiteTidy can inspect the public web experience for performance, security and technical issues. Pair that with API telemetry and contract testing for a fuller production picture.
The real definition of a scalable API
Scalability is not simply handling more requests.
A mature API scales traffic, teams, clients and change.
It has clear contracts. It can reject unsafe load. It exposes enough telemetry to explain its own failures. It can evolve without surprising every consumer. It gives operators safe ways to release, throttle, disable and recover.
That is what turns an HTTP interface into dependable infrastructure.
