...

/

Blue-Green Deployment and Destructive Operations in Database

Blue-Green Deployment and Destructive Operations in Database

Explore blue-green deployment more in this lesson to take it to the next level.

We'll cover the following...

Graceful shutdown

In blue-green deployments, whenever a new version comes up, the load balancer will stop routing traffic to the old version. Only after a couple of minutes or so have passed, it is safe to shut those VMs down. While this should be enough time to process all incoming work, sometimes that won’t be the case. Let’s consider a few examples.

Imagine that some of the incoming requests start new tasks that are responsible for sending emails asynchronously. We want to guarantee that the VM will not shut down before it finishes its tasks.

Supervision trees provide that guarantee. When we invoke System.stop(), the Erlang runtime will stop all running applications in the opposite order they were started within their respective supervision trees, respecting the configured shutdown values for each child. At the beginning of this chapter, we showed you how to pipe System.stop() into the runtime withto_erl. If we are using releases, that’s also what bin/sample stop does.

When we build a GenServer, agent, or another supervised process, we can specify how long the supervisor should wait before shutting down a child:

Press + to interact
defmodule MyApp.EmailSender do
use GenServer, shutdown: 5000
...

We can also override the ...