HTTP 483: Prevent Resource Freezes in Your APIs
Краткое содержание
Pixel shares a guide to HTTP 483, a proposed status code for requests that could freeze or destabilize shared resources. It explains when to use 483 instead of errors like 500, 503, or 409, covers Retry-After and useful error headers, and offers practical API implementation guidance.
DEV Community
Master HTTP 483: Prevent Resource Freezes in Your APIs
HTTP 483 – “I’m Not a Freezer”: Why It Matters, How It Works, and How to Implement It Today Introduction When a client calls an API, the response is usually straightforward: 200 OK for success, 404 Not Found for a missing resource, 429 Too Many Requests when you’ve hit a rate limit. But there’s a subtle failure mode that isn’t covered by any existing code—the request would lock or “freeze” a critical shared resource (a database row, a GPU slot, a streaming pipeline, etc.). The IETF’s draft HTTP 483 – “I’m Not a Freezer” introduces a dedicated status code for that exact situation. It gives servers a clean, machine‑readable way to tell clients, “I can’t run this because it would jeopardize the stability of a shared resource,” without overloading the response body with custom error strings that get mis‑interpreted. In the next few minutes you’ll see why the community (Hacker News, Reddit, even Google Trends) is buzzing, how the spec is defined, concrete code snippets for both servers and clients, and a short checklist to make your API ready for 483 today. Quick‑Start Cheat Sheet Situation Traditional Response With HTTP 483 DB row lock would deadlock 500 Internal Error or custom 409 483 + Retry-After GPU queue full, new inference would stall 503 Service Unavailable 483 + error-code: gpu‑queue‑full Distributed mutex already held 409 Conflict 483 + resource: mutex‑xyz Rate limit exceeded (client‑side) 429 Too Many Requests 429 (unchanged) How the Specification Looks Status Code: 483 Reason Phrase: I’m Not a Freezer (optional, but recommended) Mandatory Headers Retry-After – seconds or HTTP‑date indicating when the client may safely retry. Recommended Headers (optional but highly useful) Content-Type: application/problem+json – standard problem‑details payload. error-code – a short, machine‑readable identifier (e.g., db‑row‑lock, gpu‑queue‑full). resource – URI or logical name of the frozen resource. Problem‑Details Example {
"type": "https://httpstatuses.io/483",
"title": "I’m Not a Freezer",
"status": 483,
"detail": "Executing this request would lock the GPU compute slot and stall other workloads.",
"error-code": "gpu-queue-full",
"resource": "/gpu/slot/7",
"retry-after": "30"
}
Server‑Side Implementation Below are minimal examples for three popular stacks. Adjust the logic to match the resource you protect. Node.js / Express app.post('/inference', async (req, res) => {
if (await gpuQueue.isFull()) {
res.set('Retry-After', '30'); // 30 seconds
res.set('error-code', 'gpu-queue-full');
res.set('resource', '/gpu/slot/7');
return res
.status(483)
.type('application/problem+json')
.send({
type: 'https://httpstatuses.io/483',
title: "I’m Not a Freezer",
status: 483,
detail: "GPU compute slot is saturated; request would block other jobs.",
errorCode: 'gpu-queue-full',
resource: '/gpu/slot/7',
retryAfter: 30
});
}
// … normal processing …
res.json({ result: await runInference(req.body) });
});
Python / Flask from flask import Flask, request, jsonify, make_response
app = Flask(name)
@app.route('/lock', methods=['POST'])
def acquire_lock():
if lock_service.is_locked('order-123'):
resp = make_response(jsonify({
"type": "https://httpstatuses.io/483",
"title": "I’m Not a Freezer",
"status": 483,
"detail": "Order 123 is currently locked by another process.",
"error-code": "db-row-lock",
"resource": "/orders/123",
"retry-after": 15
}), 483)
resp.headers['Retry-After'] = '15'
resp.headers['Content-Type'] = 'application/problem+json'
resp.headers['error-code'] = 'db-row-lock'
resp.headers['resource'] = '/orders/123'
return resp
# … proceed with the operation …
return jsonify({"status": "ok"})
Go / net/http func handleJob(w http.ResponseWriter, r http.Requ...

Powered by Readybot.io*