Error Budgets, Rate Limits, and Monitoring
📦 Module 9: Ship to Production
Error Budgets, Rate Limits, and Monitoring
Your app will fail. The question is: how often is acceptable?
Rate limits
EnergyAtIT is free until we get your feedback. There is no paid tier.
When you hit a limit, you get a 429 Too Many Requests response. The Retry-After header tells you how long to wait.
import time
response = requests.get(url, headers=headers)
if response.status_code == 429:
wait = int(response.headers.get("Retry-After", 60))
time.sleep(wait)
response = requests.get(url, headers=headers) # Retry onceError Budgets
An error budget is the maximum amount of downtime you can tolerate per year.
| SLA | Downtime/Year | Downtime/Month | What It Means |
|---|---|---|---|
| 99% | 3.65 days | 7.3 hours | Fine for internal dashboards |
| 99.9% | 8.76 hours | 43.8 minutes | Standard for production apps |
| 99.99% | 52.6 minutes | 4.38 minutes | TAQA / Khazna SLA territory |
If your app has 99.9% uptime, you have 8 hours and 46 minutes per year of acceptable failure. That sounds like a lot until a bad deploy eats 4 hours on a Friday.
Monitoring with /health
Every production app needs a health check. EnergyAtIt provides one:
curl https://app.energyatit.com/api/v1/healthcurl.exe "https://app.energyatit.com/api/v1/health"Build one for your app too:
@app.route("/health")
def health():
checks = {
"api_reachable": ping_energyatit(),
"db_connected": check_db(),
"last_reading_fresh": last_reading_age() < 300 # < 5 minutes
}
ok = all(checks.values())
return {"status": "ok" if ok else "degraded", "checks": checks}, 200 if ok else 503Point your monitoring tool (UptimeRobot, Datadog, even a cron job with curl) at that endpoint. Alert when it returns 503.
The apps that survive production are the ones that tell you when they are broken.
Log in to track your progress and earn certifications.