SlideShare une entreprise Scribd logo
1  sur  45
Télécharger pour lire hors ligne
Releases and Hot Code
Replacement in Elixir
Alexei Sholik
Kyiv Elixir Meetup, 3 Nov 2016
What we'll learn
• The importance of separating code and data
• Code loading in BEAM
• Fundamentals of release upgrades in OTP
• Building an upgrade using Distillery
Separation of code
and data
OOP
OOP
A program is an object graph
OOP
def some_method(this, x):
y = this.method_foo(x)
# ...
this.method_bar(y)
What if we change
the code at this
point?
Code reloading in OOP
DOES NOT WORK
Functional
programming
Functional programming
Code and data are separate
data
data
code
Code reloading in
functional programming
TRIVIAL
Code reloading in
functional programming
OR IS IT?
Code reloading in
functional programming
def some_function(x) do
y = function_foo(x)
# ...
function_bar(y)
end
What if we change
the code at this
point?
Code reloading in
functional programming
def some_function(x) do
y = function_foo(x)
# ...
M.function_bar(y)
end
What if we change
the code at this
point?
Code loading in
BEAM
Code loading in BEAM
A process is a unit of concurrency
Inside a single process all code is executed
sequentially
Concurrency is achieved by interleaving the
execution of many processes
Code loading in BEAM
A module is a unit of code
A module is loaded or reloaded as a whole
The VM keeps at most two versions of the same
module
Reloading a module creates a new version of it in
memory
Code loading in BEAM
The most recently loaded version is called current
The previous version is called old
Code loading in BEAM
When a process is executing the code from a module
(basically, when it is inside a function call),
it is said to be running in that version of the module.
If the module is purged (by the VM or manually), the
process is killed immediately.
Local vs fully qualified
function calls
function_foo()
ModuleBar.function_baz()
local call
fully qualified
call
Local vs fully qualified
function calls
Local function call always invokes code from
the same module version that is being executed
Local vs fully qualified
function calls
Fully qualified function call always invokes code from
the latest module version
Code reloading in BEAM
def some_function(x) do
y = function_foo(x)
# ...
function_bar(y)
end
Changing the code
at this point won't
affect the function
Code reloading in BEAM
def some_function(x) do
y = function_foo(x)
# ...
M.function_bar(y)
end
Changing the code
for M at this point
will result in running
the new code for
function_bar()
Code reloading in BEAM
Doing a fully qualified function call allows a process
to switch to the new code.
But there are caveats we have to take into account...
Deterministic code
reloading in the face of
massive concurrency
In other words, "Would would OTP do?"
Code reloading with OTP
We have two problems to solve
1. Switching a process to the newly loaded module
version
2. Migrating the process state
Code reloading with OTP
How do we ensure our gen servers keep running
in those unforgiving circumstances?
By building a release, of course!
Release upgrades in
OTP
Quick guide to release
upgrades
Quick guide to release
upgrades
• Change the code. Make sure to handle all
necessary data migrations
• Update the app version
• Write an <app name>.appup file with instructions
on how each changed or new module should
be loaded
Quick guide to release
upgrades (continued)
• Generate a relup file with low-level instructions
for the release upgrade process
• Build a release, package it up into a .tar file
and place it in the releases/ directory on the
target machine
• Execute a series of calls to :release_handler in
order to install the new release in the running
system
.appup instructions
{update, Mod}
{update, Mod, supervisor}
{update, Mod, Change}
{update, Mod, DepMods}
{update, Mod, Change, DepMods}
{update, Mod, Change, PrePurge, PostPurge, DepMods}
{update, Mod, Timeout, Change, PrePurge, PostPurge, DepMods}
{update, Mod, ModType, Timeout, Change, PrePurge, PostPurge, DepMods}
{load_module, Mod}
{load_module, Mod, DepMods}
{load_module, Mod, PrePurge, PostPurge, DepMods}
{add_module, Mod}
{add_module, Mod, DepMods}
{delete_module, Mod}
{delete_module, Mod, DepMods}
{add_application, Application}
{add_application, Application, Type}
{remove_application, Application}
{restart_application, Application}
...
Thankfully, the actual
upgrade process is
handled by OTP
Release upgrade process
• Find all processes running the changed
modules and suspend them
• Load the new code for those modules
• Invoked the code_change() callback in all
relevant processes
• Resume suspended processes
Release upgrade process
(optional extra steps)
• Update the init() callback of a supervisor
process
• Add or remove an OTP application
• Restart a running OTP application
• Restart the whole node
• ... (there are more possibilities)
Upgrading a release
with Distillery
Upgrading a release with
Distillery
• Change the code. Make sure to handle all
necessary data migrations
• Update the app version
• Build a release using mix release --upgrade
• Activate and install the new release in the shell
Update the app version
Build a release
$ mix release --upgrade
==> Assembling release..
==> Building release chat:0.2.0 using environment prod
==> Including ERTS 8.1 from /...
==> Generated .appup for chat 0.1.0 -> 0.2.0
==> Relup successfully created
==> Packaging release..
==> Release successfully built!
Install the new release
$ rel/chat/bin/chat console
iex(chat@127.0.0.1)1>
:release_handler.set_unpacked 'releases/0.2.0/chat.rel', []
{:ok, '0.2.0'}
iex(chat@127.0.0.1)2> :release_handler.install_release '0.2.0'
{:ok, '0.1.0', []}
iex(chat@127.0.0.1)3> :release_handler.which_releases
[{'chat', '0.2.0', [...], :current},
{'chat', '0.1.0', [...], :permanent}]
Install the new release
(continued)
iex(chat@127.0.0.1)4> :release_handler.make_permanent '0.2.0'
:ok
iex(chat@127.0.0.1)5> :release_handler.which_releases
[{'chat', '0.2.0', [...], :permanent},
{'chat', '0.1.0', [...], :old}]
Distillery helps a lot
But you still have to
know the underlying
details
Conclusions
• The basic code reloading is trivial to do in
BEAM
• In a real application, though, there are a lot
more things to consider
• It's easy to make a mistake and cause the
application to misbehave
• Rule of thumb: don't use hot code replacement
unless absolutely necessary and worth the cost
Questions?
Alexei Sholik
github.com/alco
twitter.com/true_droid

Contenu connexe

Tendances

ContainerSched 2017: Why Containers Will Take Over the World
ContainerSched 2017: Why Containers Will Take Over the WorldContainerSched 2017: Why Containers Will Take Over the World
ContainerSched 2017: Why Containers Will Take Over the WorldElton Stoneman
 
[English][Test Girls] Zero to Hero: Start Test automation with Cypress
[English][Test Girls] Zero to Hero: Start Test automation with Cypress[English][Test Girls] Zero to Hero: Start Test automation with Cypress
[English][Test Girls] Zero to Hero: Start Test automation with CypressTest Girls
 
DockerCon 17 EU: Modernizing .NET Apps with Docker
DockerCon 17 EU: Modernizing .NET Apps with DockerDockerCon 17 EU: Modernizing .NET Apps with Docker
DockerCon 17 EU: Modernizing .NET Apps with DockerElton Stoneman
 
C installation guide
C installation guideC installation guide
C installation guidevikas mishra
 
Евгений Жарков "React Native: Hurdle Race"
Евгений Жарков "React Native: Hurdle Race"Евгений Жарков "React Native: Hurdle Race"
Евгений Жарков "React Native: Hurdle Race"Fwdays
 
Js Test Driver, JsHamcrest, JsMockito
Js Test Driver, JsHamcrest, JsMockitoJs Test Driver, JsHamcrest, JsMockito
Js Test Driver, JsHamcrest, JsMockitoFredrik Wendt
 
Griffon: Swing just got fun again
Griffon: Swing just got fun againGriffon: Swing just got fun again
Griffon: Swing just got fun againJames Williams
 
Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)Dennys Hsieh
 
React native on windows
React native on windowsReact native on windows
React native on windowsAbdul Karim
 
Easy Setup for Parallel Test Execution with Selenium Docker
Easy Setup for Parallel Test Execution with Selenium DockerEasy Setup for Parallel Test Execution with Selenium Docker
Easy Setup for Parallel Test Execution with Selenium DockerSargis Sargsyan
 
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...Puppet
 
Getting Started with Dockerization of Selenium Tests Execution - Testwarez 2019
Getting Started with Dockerization of Selenium Tests Execution - Testwarez 2019Getting Started with Dockerization of Selenium Tests Execution - Testwarez 2019
Getting Started with Dockerization of Selenium Tests Execution - Testwarez 2019Sargis Sargsyan
 
Automated android testing using jenkins ci
Automated android testing using jenkins ciAutomated android testing using jenkins ci
Automated android testing using jenkins cisveinungkb
 
WinOps 2017 - Docker on Windows, the Beginner's Guide
WinOps 2017 - Docker on Windows, the Beginner's GuideWinOps 2017 - Docker on Windows, the Beginner's Guide
WinOps 2017 - Docker on Windows, the Beginner's GuideElton Stoneman
 
Grunt Continuous Development of the Front End Tier
Grunt Continuous Development of the Front End TierGrunt Continuous Development of the Front End Tier
Grunt Continuous Development of the Front End TierErick Brito
 
How to Dockerize Parallel Execution of Selenium Tests - SQA Days EU, Rgia, La...
How to Dockerize Parallel Execution of Selenium Tests - SQA Days EU, Rgia, La...How to Dockerize Parallel Execution of Selenium Tests - SQA Days EU, Rgia, La...
How to Dockerize Parallel Execution of Selenium Tests - SQA Days EU, Rgia, La...Sargis Sargsyan
 
Continuous Integration for your Android projects
Continuous Integration for your Android projectsContinuous Integration for your Android projects
Continuous Integration for your Android projectsSergii Zhuk
 
Howto Create & Run zf2skeleton Apps with PHP's Built-in Webserver
Howto Create & Run zf2skeleton Apps with PHP's Built-in WebserverHowto Create & Run zf2skeleton Apps with PHP's Built-in Webserver
Howto Create & Run zf2skeleton Apps with PHP's Built-in WebserverMaster Zend Framework
 
Run your Appium tests using Docker Android - AppiumConf 2019
Run your Appium tests using Docker Android - AppiumConf 2019Run your Appium tests using Docker Android - AppiumConf 2019
Run your Appium tests using Docker Android - AppiumConf 2019Sargis Sargsyan
 

Tendances (20)

ContainerSched 2017: Why Containers Will Take Over the World
ContainerSched 2017: Why Containers Will Take Over the WorldContainerSched 2017: Why Containers Will Take Over the World
ContainerSched 2017: Why Containers Will Take Over the World
 
[English][Test Girls] Zero to Hero: Start Test automation with Cypress
[English][Test Girls] Zero to Hero: Start Test automation with Cypress[English][Test Girls] Zero to Hero: Start Test automation with Cypress
[English][Test Girls] Zero to Hero: Start Test automation with Cypress
 
DockerCon 17 EU: Modernizing .NET Apps with Docker
DockerCon 17 EU: Modernizing .NET Apps with DockerDockerCon 17 EU: Modernizing .NET Apps with Docker
DockerCon 17 EU: Modernizing .NET Apps with Docker
 
C installation guide
C installation guideC installation guide
C installation guide
 
Евгений Жарков "React Native: Hurdle Race"
Евгений Жарков "React Native: Hurdle Race"Евгений Жарков "React Native: Hurdle Race"
Евгений Жарков "React Native: Hurdle Race"
 
Js Test Driver, JsHamcrest, JsMockito
Js Test Driver, JsHamcrest, JsMockitoJs Test Driver, JsHamcrest, JsMockito
Js Test Driver, JsHamcrest, JsMockito
 
Griffon: Swing just got fun again
Griffon: Swing just got fun againGriffon: Swing just got fun again
Griffon: Swing just got fun again
 
Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)
 
React native on windows
React native on windowsReact native on windows
React native on windows
 
Easy Setup for Parallel Test Execution with Selenium Docker
Easy Setup for Parallel Test Execution with Selenium DockerEasy Setup for Parallel Test Execution with Selenium Docker
Easy Setup for Parallel Test Execution with Selenium Docker
 
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...
 
Welcome to Jenkins
Welcome to JenkinsWelcome to Jenkins
Welcome to Jenkins
 
Getting Started with Dockerization of Selenium Tests Execution - Testwarez 2019
Getting Started with Dockerization of Selenium Tests Execution - Testwarez 2019Getting Started with Dockerization of Selenium Tests Execution - Testwarez 2019
Getting Started with Dockerization of Selenium Tests Execution - Testwarez 2019
 
Automated android testing using jenkins ci
Automated android testing using jenkins ciAutomated android testing using jenkins ci
Automated android testing using jenkins ci
 
WinOps 2017 - Docker on Windows, the Beginner's Guide
WinOps 2017 - Docker on Windows, the Beginner's GuideWinOps 2017 - Docker on Windows, the Beginner's Guide
WinOps 2017 - Docker on Windows, the Beginner's Guide
 
Grunt Continuous Development of the Front End Tier
Grunt Continuous Development of the Front End TierGrunt Continuous Development of the Front End Tier
Grunt Continuous Development of the Front End Tier
 
How to Dockerize Parallel Execution of Selenium Tests - SQA Days EU, Rgia, La...
How to Dockerize Parallel Execution of Selenium Tests - SQA Days EU, Rgia, La...How to Dockerize Parallel Execution of Selenium Tests - SQA Days EU, Rgia, La...
How to Dockerize Parallel Execution of Selenium Tests - SQA Days EU, Rgia, La...
 
Continuous Integration for your Android projects
Continuous Integration for your Android projectsContinuous Integration for your Android projects
Continuous Integration for your Android projects
 
Howto Create & Run zf2skeleton Apps with PHP's Built-in Webserver
Howto Create & Run zf2skeleton Apps with PHP's Built-in WebserverHowto Create & Run zf2skeleton Apps with PHP's Built-in Webserver
Howto Create & Run zf2skeleton Apps with PHP's Built-in Webserver
 
Run your Appium tests using Docker Android - AppiumConf 2019
Run your Appium tests using Docker Android - AppiumConf 2019Run your Appium tests using Docker Android - AppiumConf 2019
Run your Appium tests using Docker Android - AppiumConf 2019
 

Similaire à Hot Code Replacement - Alexei Sholik

Vladimir Ulogov - Beyond the Loadable Module
Vladimir Ulogov - Beyond the Loadable ModuleVladimir Ulogov - Beyond the Loadable Module
Vladimir Ulogov - Beyond the Loadable ModuleZabbix
 
Beyond the Loadable Module
Beyond the Loadable ModuleBeyond the Loadable Module
Beyond the Loadable ModuleVladimir Ulogov
 
How To Use IO Monads in Scala?
 How To Use IO Monads in Scala? How To Use IO Monads in Scala?
How To Use IO Monads in Scala?Knoldus Inc.
 
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav DukhinFwdays
 
Working Effectively With Legacy Perl Code
Working Effectively With Legacy Perl CodeWorking Effectively With Legacy Perl Code
Working Effectively With Legacy Perl Codeerikmsp
 
What's new in c# 5.0 net ponto
What's new in c# 5.0   net pontoWhat's new in c# 5.0   net ponto
What's new in c# 5.0 net pontoPaulo Morgado
 
Code Difference Visualization by a Call Tree
Code Difference Visualization by a Call TreeCode Difference Visualization by a Call Tree
Code Difference Visualization by a Call TreeKamiya Toshihiro
 
As novidades do C# 5.0
As novidades do C# 5.0As novidades do C# 5.0
As novidades do C# 5.0pt_programar
 
What's New In C# 5.0 - Programar 2013
What's New In C# 5.0 - Programar 2013What's New In C# 5.0 - Programar 2013
What's New In C# 5.0 - Programar 2013Paulo Morgado
 
Function Overloading,Inline Function and Recursion in C++ By Faisal Shahzad
Function Overloading,Inline Function and Recursion in C++ By Faisal ShahzadFunction Overloading,Inline Function and Recursion in C++ By Faisal Shahzad
Function Overloading,Inline Function and Recursion in C++ By Faisal ShahzadFaisal Shehzad
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of SignalsCoding Academy
 
OOP-Module-1-Section-4-LectureNo1-5.pptx
OOP-Module-1-Section-4-LectureNo1-5.pptxOOP-Module-1-Section-4-LectureNo1-5.pptx
OOP-Module-1-Section-4-LectureNo1-5.pptxsarthakgithub
 
Compiler optimizations based on call-graph flattening
Compiler optimizations based on call-graph flatteningCompiler optimizations based on call-graph flattening
Compiler optimizations based on call-graph flatteningCAFxX
 
Chapter_1.__Functions_in_C++[1].pdf
Chapter_1.__Functions_in_C++[1].pdfChapter_1.__Functions_in_C++[1].pdf
Chapter_1.__Functions_in_C++[1].pdfTeshaleSiyum
 
Chapter 1. Functions in C++.pdf
Chapter 1.  Functions in C++.pdfChapter 1.  Functions in C++.pdf
Chapter 1. Functions in C++.pdfTeshaleSiyum
 
C++ unit-1-part-11
C++ unit-1-part-11C++ unit-1-part-11
C++ unit-1-part-11Jadavsejal
 

Similaire à Hot Code Replacement - Alexei Sholik (20)

Vladimir Ulogov - Beyond the Loadable Module
Vladimir Ulogov - Beyond the Loadable ModuleVladimir Ulogov - Beyond the Loadable Module
Vladimir Ulogov - Beyond the Loadable Module
 
Beyond the Loadable Module
Beyond the Loadable ModuleBeyond the Loadable Module
Beyond the Loadable Module
 
How To Use IO Monads in Scala?
 How To Use IO Monads in Scala? How To Use IO Monads in Scala?
How To Use IO Monads in Scala?
 
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
 
Working Effectively With Legacy Perl Code
Working Effectively With Legacy Perl CodeWorking Effectively With Legacy Perl Code
Working Effectively With Legacy Perl Code
 
What's new in c# 5.0 net ponto
What's new in c# 5.0   net pontoWhat's new in c# 5.0   net ponto
What's new in c# 5.0 net ponto
 
Code Difference Visualization by a Call Tree
Code Difference Visualization by a Call TreeCode Difference Visualization by a Call Tree
Code Difference Visualization by a Call Tree
 
As novidades do C# 5.0
As novidades do C# 5.0As novidades do C# 5.0
As novidades do C# 5.0
 
What's New In C# 5.0 - Programar 2013
What's New In C# 5.0 - Programar 2013What's New In C# 5.0 - Programar 2013
What's New In C# 5.0 - Programar 2013
 
Java Decompiler
Java DecompilerJava Decompiler
Java Decompiler
 
Function Overloading,Inline Function and Recursion in C++ By Faisal Shahzad
Function Overloading,Inline Function and Recursion in C++ By Faisal ShahzadFunction Overloading,Inline Function and Recursion in C++ By Faisal Shahzad
Function Overloading,Inline Function and Recursion in C++ By Faisal Shahzad
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of Signals
 
OOP-Module-1-Section-4-LectureNo1-5.pptx
OOP-Module-1-Section-4-LectureNo1-5.pptxOOP-Module-1-Section-4-LectureNo1-5.pptx
OOP-Module-1-Section-4-LectureNo1-5.pptx
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Compiler optimizations based on call-graph flattening
Compiler optimizations based on call-graph flatteningCompiler optimizations based on call-graph flattening
Compiler optimizations based on call-graph flattening
 
Chapter_1.__Functions_in_C++[1].pdf
Chapter_1.__Functions_in_C++[1].pdfChapter_1.__Functions_in_C++[1].pdf
Chapter_1.__Functions_in_C++[1].pdf
 
Chapter 1. Functions in C++.pdf
Chapter 1.  Functions in C++.pdfChapter 1.  Functions in C++.pdf
Chapter 1. Functions in C++.pdf
 
C++ unit-1-part-11
C++ unit-1-part-11C++ unit-1-part-11
C++ unit-1-part-11
 
Function
Function Function
Function
 

Plus de Elixir Club

Kubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club Ukraine
Kubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club UkraineKubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club Ukraine
Kubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club UkraineElixir Club
 
Integrating 3rd parties with Ecto - Eduardo Aguilera | Elixir Club Ukraine
Integrating 3rd parties with Ecto -  Eduardo Aguilera | Elixir Club UkraineIntegrating 3rd parties with Ecto -  Eduardo Aguilera | Elixir Club Ukraine
Integrating 3rd parties with Ecto - Eduardo Aguilera | Elixir Club UkraineElixir Club
 
— An async template - Oleksandr Khokhlov | Elixir Club Ukraine
— An async template  -  Oleksandr Khokhlov | Elixir Club Ukraine— An async template  -  Oleksandr Khokhlov | Elixir Club Ukraine
— An async template - Oleksandr Khokhlov | Elixir Club UkraineElixir Club
 
BEAM architecture handbook - Andrea Leopardi | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club UkraineBEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi | Elixir Club UkraineElixir Club
 
You ain't gonna need write a GenServer - Ulisses Almeida | Elixir Club Ukraine
You ain't gonna need write a GenServer - Ulisses Almeida  | Elixir Club UkraineYou ain't gonna need write a GenServer - Ulisses Almeida  | Elixir Club Ukraine
You ain't gonna need write a GenServer - Ulisses Almeida | Elixir Club UkraineElixir Club
 
— Knock, knock — An async templates — Who’s there? - Alexander Khokhlov | ...
 — Knock, knock — An async templates — Who’s there? - Alexander Khokhlov  |  ... — Knock, knock — An async templates — Who’s there? - Alexander Khokhlov  |  ...
— Knock, knock — An async templates — Who’s there? - Alexander Khokhlov | ...Elixir Club
 
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3Elixir Club
 
Erlang cluster. How is it? Production experience. — Valerii Vasylkov | Elixi...
Erlang cluster. How is it? Production experience. —  Valerii Vasylkov | Elixi...Erlang cluster. How is it? Production experience. —  Valerii Vasylkov | Elixi...
Erlang cluster. How is it? Production experience. — Valerii Vasylkov | Elixi...Elixir Club
 
Promo Phx4RailsDevs - Volodya Sveredyuk
Promo Phx4RailsDevs - Volodya SveredyukPromo Phx4RailsDevs - Volodya Sveredyuk
Promo Phx4RailsDevs - Volodya SveredyukElixir Club
 
Web of today — Alexander Khokhlov
Web of today —  Alexander KhokhlovWeb of today —  Alexander Khokhlov
Web of today — Alexander KhokhlovElixir Club
 
ElixirConf Eu 2018, what was it like? – Eugene Pirogov
ElixirConf Eu 2018, what was it like? – Eugene PirogovElixirConf Eu 2018, what was it like? – Eugene Pirogov
ElixirConf Eu 2018, what was it like? – Eugene PirogovElixir Club
 
Implementing GraphQL API in Elixir – Victor Deryagin
Implementing GraphQL API in Elixir – Victor DeryaginImplementing GraphQL API in Elixir – Victor Deryagin
Implementing GraphQL API in Elixir – Victor DeryaginElixir Club
 
WebPerformance: Why and How? – Stefan Wintermeyer
WebPerformance: Why and How? – Stefan WintermeyerWebPerformance: Why and How? – Stefan Wintermeyer
WebPerformance: Why and How? – Stefan WintermeyerElixir Club
 
GenServer in Action – Yurii Bodarev
GenServer in Action – Yurii Bodarev   GenServer in Action – Yurii Bodarev
GenServer in Action – Yurii Bodarev Elixir Club
 
Russian Doll Paradox: Elixir Web without Phoenix - Alex Rozumii
Russian Doll Paradox: Elixir Web without Phoenix - Alex RozumiiRussian Doll Paradox: Elixir Web without Phoenix - Alex Rozumii
Russian Doll Paradox: Elixir Web without Phoenix - Alex RozumiiElixir Club
 
Practical Fault Tolerance in Elixir - Alexei Sholik
Practical Fault Tolerance in Elixir - Alexei SholikPractical Fault Tolerance in Elixir - Alexei Sholik
Practical Fault Tolerance in Elixir - Alexei SholikElixir Club
 
Phoenix and beyond: Things we do with Elixir - Alexander Khokhlov
Phoenix and beyond: Things we do with Elixir - Alexander KhokhlovPhoenix and beyond: Things we do with Elixir - Alexander Khokhlov
Phoenix and beyond: Things we do with Elixir - Alexander KhokhlovElixir Club
 
Monads are just monoids in the category of endofunctors - Ike Kurghinyan
Monads are just monoids in the category of endofunctors - Ike KurghinyanMonads are just monoids in the category of endofunctors - Ike Kurghinyan
Monads are just monoids in the category of endofunctors - Ike KurghinyanElixir Club
 
Craft effective API with GraphQL and Absinthe - Ihor Katkov
Craft effective API with GraphQL and Absinthe - Ihor KatkovCraft effective API with GraphQL and Absinthe - Ihor Katkov
Craft effective API with GraphQL and Absinthe - Ihor KatkovElixir Club
 
Elixir in a service of government - Alex Troush
Elixir in a service of government - Alex TroushElixir in a service of government - Alex Troush
Elixir in a service of government - Alex TroushElixir Club
 

Plus de Elixir Club (20)

Kubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club Ukraine
Kubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club UkraineKubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club Ukraine
Kubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club Ukraine
 
Integrating 3rd parties with Ecto - Eduardo Aguilera | Elixir Club Ukraine
Integrating 3rd parties with Ecto -  Eduardo Aguilera | Elixir Club UkraineIntegrating 3rd parties with Ecto -  Eduardo Aguilera | Elixir Club Ukraine
Integrating 3rd parties with Ecto - Eduardo Aguilera | Elixir Club Ukraine
 
— An async template - Oleksandr Khokhlov | Elixir Club Ukraine
— An async template  -  Oleksandr Khokhlov | Elixir Club Ukraine— An async template  -  Oleksandr Khokhlov | Elixir Club Ukraine
— An async template - Oleksandr Khokhlov | Elixir Club Ukraine
 
BEAM architecture handbook - Andrea Leopardi | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club UkraineBEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi | Elixir Club Ukraine
 
You ain't gonna need write a GenServer - Ulisses Almeida | Elixir Club Ukraine
You ain't gonna need write a GenServer - Ulisses Almeida  | Elixir Club UkraineYou ain't gonna need write a GenServer - Ulisses Almeida  | Elixir Club Ukraine
You ain't gonna need write a GenServer - Ulisses Almeida | Elixir Club Ukraine
 
— Knock, knock — An async templates — Who’s there? - Alexander Khokhlov | ...
 — Knock, knock — An async templates — Who’s there? - Alexander Khokhlov  |  ... — Knock, knock — An async templates — Who’s there? - Alexander Khokhlov  |  ...
— Knock, knock — An async templates — Who’s there? - Alexander Khokhlov | ...
 
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
 
Erlang cluster. How is it? Production experience. — Valerii Vasylkov | Elixi...
Erlang cluster. How is it? Production experience. —  Valerii Vasylkov | Elixi...Erlang cluster. How is it? Production experience. —  Valerii Vasylkov | Elixi...
Erlang cluster. How is it? Production experience. — Valerii Vasylkov | Elixi...
 
Promo Phx4RailsDevs - Volodya Sveredyuk
Promo Phx4RailsDevs - Volodya SveredyukPromo Phx4RailsDevs - Volodya Sveredyuk
Promo Phx4RailsDevs - Volodya Sveredyuk
 
Web of today — Alexander Khokhlov
Web of today —  Alexander KhokhlovWeb of today —  Alexander Khokhlov
Web of today — Alexander Khokhlov
 
ElixirConf Eu 2018, what was it like? – Eugene Pirogov
ElixirConf Eu 2018, what was it like? – Eugene PirogovElixirConf Eu 2018, what was it like? – Eugene Pirogov
ElixirConf Eu 2018, what was it like? – Eugene Pirogov
 
Implementing GraphQL API in Elixir – Victor Deryagin
Implementing GraphQL API in Elixir – Victor DeryaginImplementing GraphQL API in Elixir – Victor Deryagin
Implementing GraphQL API in Elixir – Victor Deryagin
 
WebPerformance: Why and How? – Stefan Wintermeyer
WebPerformance: Why and How? – Stefan WintermeyerWebPerformance: Why and How? – Stefan Wintermeyer
WebPerformance: Why and How? – Stefan Wintermeyer
 
GenServer in Action – Yurii Bodarev
GenServer in Action – Yurii Bodarev   GenServer in Action – Yurii Bodarev
GenServer in Action – Yurii Bodarev
 
Russian Doll Paradox: Elixir Web without Phoenix - Alex Rozumii
Russian Doll Paradox: Elixir Web without Phoenix - Alex RozumiiRussian Doll Paradox: Elixir Web without Phoenix - Alex Rozumii
Russian Doll Paradox: Elixir Web without Phoenix - Alex Rozumii
 
Practical Fault Tolerance in Elixir - Alexei Sholik
Practical Fault Tolerance in Elixir - Alexei SholikPractical Fault Tolerance in Elixir - Alexei Sholik
Practical Fault Tolerance in Elixir - Alexei Sholik
 
Phoenix and beyond: Things we do with Elixir - Alexander Khokhlov
Phoenix and beyond: Things we do with Elixir - Alexander KhokhlovPhoenix and beyond: Things we do with Elixir - Alexander Khokhlov
Phoenix and beyond: Things we do with Elixir - Alexander Khokhlov
 
Monads are just monoids in the category of endofunctors - Ike Kurghinyan
Monads are just monoids in the category of endofunctors - Ike KurghinyanMonads are just monoids in the category of endofunctors - Ike Kurghinyan
Monads are just monoids in the category of endofunctors - Ike Kurghinyan
 
Craft effective API with GraphQL and Absinthe - Ihor Katkov
Craft effective API with GraphQL and Absinthe - Ihor KatkovCraft effective API with GraphQL and Absinthe - Ihor Katkov
Craft effective API with GraphQL and Absinthe - Ihor Katkov
 
Elixir in a service of government - Alex Troush
Elixir in a service of government - Alex TroushElixir in a service of government - Alex Troush
Elixir in a service of government - Alex Troush
 

Dernier

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 

Dernier (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Hot Code Replacement - Alexei Sholik

  • 1. Releases and Hot Code Replacement in Elixir Alexei Sholik Kyiv Elixir Meetup, 3 Nov 2016
  • 2. What we'll learn • The importance of separating code and data • Code loading in BEAM • Fundamentals of release upgrades in OTP • Building an upgrade using Distillery
  • 4. OOP
  • 5. OOP A program is an object graph
  • 6. OOP def some_method(this, x): y = this.method_foo(x) # ... this.method_bar(y) What if we change the code at this point?
  • 7. Code reloading in OOP DOES NOT WORK
  • 9. Functional programming Code and data are separate data data code
  • 10. Code reloading in functional programming TRIVIAL
  • 11. Code reloading in functional programming OR IS IT?
  • 12. Code reloading in functional programming def some_function(x) do y = function_foo(x) # ... function_bar(y) end What if we change the code at this point?
  • 13. Code reloading in functional programming def some_function(x) do y = function_foo(x) # ... M.function_bar(y) end What if we change the code at this point?
  • 15. Code loading in BEAM A process is a unit of concurrency Inside a single process all code is executed sequentially Concurrency is achieved by interleaving the execution of many processes
  • 16. Code loading in BEAM A module is a unit of code A module is loaded or reloaded as a whole The VM keeps at most two versions of the same module Reloading a module creates a new version of it in memory
  • 17. Code loading in BEAM The most recently loaded version is called current The previous version is called old
  • 18. Code loading in BEAM When a process is executing the code from a module (basically, when it is inside a function call), it is said to be running in that version of the module. If the module is purged (by the VM or manually), the process is killed immediately.
  • 19. Local vs fully qualified function calls function_foo() ModuleBar.function_baz() local call fully qualified call
  • 20. Local vs fully qualified function calls Local function call always invokes code from the same module version that is being executed
  • 21. Local vs fully qualified function calls Fully qualified function call always invokes code from the latest module version
  • 22. Code reloading in BEAM def some_function(x) do y = function_foo(x) # ... function_bar(y) end Changing the code at this point won't affect the function
  • 23. Code reloading in BEAM def some_function(x) do y = function_foo(x) # ... M.function_bar(y) end Changing the code for M at this point will result in running the new code for function_bar()
  • 24. Code reloading in BEAM Doing a fully qualified function call allows a process to switch to the new code. But there are caveats we have to take into account...
  • 25. Deterministic code reloading in the face of massive concurrency In other words, "Would would OTP do?"
  • 26. Code reloading with OTP We have two problems to solve 1. Switching a process to the newly loaded module version 2. Migrating the process state
  • 27. Code reloading with OTP How do we ensure our gen servers keep running in those unforgiving circumstances? By building a release, of course!
  • 29. Quick guide to release upgrades
  • 30. Quick guide to release upgrades • Change the code. Make sure to handle all necessary data migrations • Update the app version • Write an <app name>.appup file with instructions on how each changed or new module should be loaded
  • 31. Quick guide to release upgrades (continued) • Generate a relup file with low-level instructions for the release upgrade process • Build a release, package it up into a .tar file and place it in the releases/ directory on the target machine • Execute a series of calls to :release_handler in order to install the new release in the running system
  • 32. .appup instructions {update, Mod} {update, Mod, supervisor} {update, Mod, Change} {update, Mod, DepMods} {update, Mod, Change, DepMods} {update, Mod, Change, PrePurge, PostPurge, DepMods} {update, Mod, Timeout, Change, PrePurge, PostPurge, DepMods} {update, Mod, ModType, Timeout, Change, PrePurge, PostPurge, DepMods} {load_module, Mod} {load_module, Mod, DepMods} {load_module, Mod, PrePurge, PostPurge, DepMods} {add_module, Mod} {add_module, Mod, DepMods} {delete_module, Mod} {delete_module, Mod, DepMods} {add_application, Application} {add_application, Application, Type} {remove_application, Application} {restart_application, Application} ...
  • 33. Thankfully, the actual upgrade process is handled by OTP
  • 34. Release upgrade process • Find all processes running the changed modules and suspend them • Load the new code for those modules • Invoked the code_change() callback in all relevant processes • Resume suspended processes
  • 35. Release upgrade process (optional extra steps) • Update the init() callback of a supervisor process • Add or remove an OTP application • Restart a running OTP application • Restart the whole node • ... (there are more possibilities)
  • 37. Upgrading a release with Distillery • Change the code. Make sure to handle all necessary data migrations • Update the app version • Build a release using mix release --upgrade • Activate and install the new release in the shell
  • 38. Update the app version
  • 39. Build a release $ mix release --upgrade ==> Assembling release.. ==> Building release chat:0.2.0 using environment prod ==> Including ERTS 8.1 from /... ==> Generated .appup for chat 0.1.0 -> 0.2.0 ==> Relup successfully created ==> Packaging release.. ==> Release successfully built!
  • 40. Install the new release $ rel/chat/bin/chat console iex(chat@127.0.0.1)1> :release_handler.set_unpacked 'releases/0.2.0/chat.rel', [] {:ok, '0.2.0'} iex(chat@127.0.0.1)2> :release_handler.install_release '0.2.0' {:ok, '0.1.0', []} iex(chat@127.0.0.1)3> :release_handler.which_releases [{'chat', '0.2.0', [...], :current}, {'chat', '0.1.0', [...], :permanent}]
  • 41. Install the new release (continued) iex(chat@127.0.0.1)4> :release_handler.make_permanent '0.2.0' :ok iex(chat@127.0.0.1)5> :release_handler.which_releases [{'chat', '0.2.0', [...], :permanent}, {'chat', '0.1.0', [...], :old}]
  • 43. But you still have to know the underlying details
  • 44. Conclusions • The basic code reloading is trivial to do in BEAM • In a real application, though, there are a lot more things to consider • It's easy to make a mistake and cause the application to misbehave • Rule of thumb: don't use hot code replacement unless absolutely necessary and worth the cost