The Toaster Didn't Trip the Breaker: or, Why the Container Died
Cassia Scheffer
Published on September 24, 2024
Ah, morning tea. My favourite. Plug the kettle in and get it going. Oh! How about some toast to go with that. Plug the toaster in and pop a nice slice of sour dough bread in. My favourite.
đ„
Power goes out.
What happened? âThe toaster flipped the breaker!â You might say. But, Iâm pedantic. No, the toaster did not flipped the breaker. âWas it the kettle, then?â Again, no, not the kettle.
âOh, come on, there was nothing else plugged in?â
Correct! So that means that the load of the toaster and the kettle blew the breaker. The appliances didnât do it themselves. And one appliance doesnât draw enough power to cause breaker to trip.
Even though we say âthe toaster blew the breaker,â the toaster doesnât have anything to do with the breaker. The toaster just happened to be the last thing to draw power from the circuit.
Okay, okay, what does all this toaster pedantry have to do with Docker
We make the same linguistic slip up when we talk about processes dying on computers. However, if we diagnose it incorrectly, weâll look in all the wrong places for solutions.
Imagine I said âthe toaster blew the breakerâ and then we went down a rabbit hole trying to get the toaster to draw less power! Weâd end up with a poorly working toaster and a circuit that could still blow at any moment. When the real solution is to use the toaster and the kettle on different circuits.
So, next time youâre looking at a process like a Docker container that dies, ask yourself, what symptoms are part of the cause, and what symptoms are correlations.
A correlation may be that you had requests running for a long time. But a long running request doesnât kill a container. The cause may be that the long-running requests were causing timeouts and the containerâs healthcheck timed out one-too-many times.
Diagnosing long-running requests is important, for sure. But suggesting that the request killed the container is not accurate. The container died because a monitor, like the breaker in an electrical circuit, was tripped.
Similarly, containers can churn because they run out of memory. Is the solution to give the container more memory so it doesnât run out? No! Find the memory problem and solve that. There is a good reason we have safeguards that monitor Docker container health and reboot them when needed.