Containers

Stop Losing Requests! Learn Graceful Shutdown Techniques

Look at this.

I will send a request to the application,…

curl "http://silly-demo.127.0.0.1.nip.io/fibonacci?number=50"

…and simulate failure or upgrade or any similar action by deleting the Pod where the application is running.

kubectl --namespace a-team delete pod \
    --selector app.kubernetes.io/name=silly-demo

The output of the curl command is as follows.

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx</center>
</body>
</html>

Since we initiated the delete process before the server returned a response we got 502 Bad Gateway message. The application was deleted before it could respond and I, the user of that application, failed to get what I was looking for. That’s horrible experience that could have been improved by enabling the application to shut down gracefully.