Lesson 23 — Circuit breaker (half-open)
Let the breaker heal itself
An open breaker should not stay open forever. After a cooldown time it goes half-open: it lets one test call through. If that call succeeds, the breaker closes (back to normal); if it fails, it opens again and waits another cooldown.
States: closed → (too many fails) → open → (cooldown passed) → half → closed or open. We pass the time now in so the result is predictable.
Note: real DevOps tools (CI servers, load balancers, Docker, Kubernetes) cannot run in your browser, so this exercise is a small plain-JS simulation of the logic those tools use.
Why it matters: services recover without anyone restarting them by hand at 3 a.m.
When the breaker is open and now - openedAt >= cooldown, set state to "half" so the test call goes through.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based DevOps Foundations courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for DevOps Foundations books — check the publication year so the examples match current versions.
Search Amazon →