chare

chare

How to do phoenix deployment rollover?

I am trying to figure out how to upgrade a phoenix application on digitalocean for example with zero downtime. I am running phoenix 1.4.9 and elixir 1.9. My application uses channels. I googled some stuff and I am having trouble figuring out what is the definitive idiomatic way of doing this.

My thought are in trying to keep things simple to first try to limit this to one machine rather than deploying the upgraded phoenix app on a second machine and then figure out how to transition to the second machine and shutdown the first machine.

It seems to me that one approach is to have on the machine nginx listening to port 80 and passing off to something like port 8080 on the first phoenix process. Then to upgrade the application we bring up a second phoenix process listening on port 8081. We have this second process join the first one to form a cluster because we need the channels to be able to communicate globabally across the cluster during the rollover. We reconfigure nginx to pass off to port 8081 so all new traffic hits the upgraded phoenix application. Then we somehow send a command to the first phoenix process to close all websockets. The web browser clients will then reconnect the websockets and this will hit the second phoenix process. Then we can safely bring down the first phoenix process.

Does this make any sense? Is this at all normal? What would be the correct way to do this and is there a definitive guide?

Most Liked

Qqwy

Qqwy

TypeCheck Core Team

There is no ‘definitive guide’ since there are many decisions to be made that depend on your application’s exact circumstances.

However, I wrote a guide detailing the steps I use myself a while back, which also uses a VPS on DigitalOcean or a similar host as starting point. It’s not perfect, but it might give you some initial ides: Using LetsEncrypt with Phoenix (behind Nginx). How to make this more optimal?

Where Next?

Popular in Questions Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39467 209
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54120 245
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement