SlideShare a Scribd company logo
ElixirPeeking into Elixir’s
Processes, OTP & Supervisors
21st March 2014
/benjamintanweihao /bentanweihao
benjamintanweihao@gmail.com
What will we learn today?
Elixir & Erlang
In less than 5 minutes
Elixir & Erlang
In less than 5 minutes
Processes 101
The Basic Concurrency
Primitive
What will we learn today?
Elixir & Erlang
In less than 5 minutes
OTP
Framework and much more
Processes 101
The Basic Concurrency
Primitive
What will we learn today?
Elixir & Erlang
In less than 5 minutes
OTP
Framework and much more
Supervisors
Fault Tolerance & Recovery
Processes 101
The Basic Concurrency
Primitive
What will we learn today?
Ohai, Elixir!
Elixir & ErlangIn less than 5 minutes
Ohai, Erlang!
Erlang is a general-purpose concurrent,
garbage-collected programming language and
runtime system. The sequential subset of
Erlang is a functional language, with eager
evaluation, single assignment, and dynamic
typing. It was designed by Ericsson to support
distributed, fault-tolerant, soft-real-time, non-
stop applications. It supports hot swapping, so
that code can be changed without stopping a
system.
Ohai, Erlang!
Erlang is a general-purpose concurrent,
garbage-collected programming language and
runtime system. The sequential subset of
Erlang is a functional language, with eager
evaluation, single assignment, and dynamic
typing. It was designed by Ericsson to support
distributed, fault-tolerant, soft-real-time, non-
stop applications. It supports hot swapping, so
that code can be changed without stopping a
system.
• Free lunch is over
Why Elixir ?
Why Elixir ?
• Free lunch is over
• Hyper-threading & Multicore
• Faster software means using all
cores!
• But … Concurrency -> Coordination
• Functional makes this easier
Design Goals of Elixir
1.Productivity
2.Extensibility
3.Compatibility
Productivity
Complete Elixir Application
Productivity
Includes Supervisor Chain
Productivity
Testing built-in
Extensibility
Macros & Meta-programming
Implementing unless using if
Extensibility
Macros & Meta-programming
Implementing unless using if
Compatibility
Elixir can call Erlang code,
without any conversion
cost at all.
Compatibility
Elixir can use Erlang libraries!
The Actor Concurrency Model
• Actor = Process
The Actor Concurrency Model
• Actor = Process
• A process performs a specific task
when it receives a message
The Actor Concurrency Model
• Actor = Process
• A process performs a specific task
when it receives a message
• In turn, the process can reply to the
sender
The Actor Concurrency Model
• Actor = Process
• A process performs a specific task
when it receives a message
• In turn, the process can reply to the
sender
• All messages go to a processes’
mailbox – Q of unprocessed messages
sent from other processes that are not
yet consumed
The Actor Concurrency Model
• Actor = Process
• A process performs a specific task
when it receives a message
• In turn, the process can reply to the
sender
• All messages go to a processes’
mailbox – Q of unprocessed messages
sent from other processes that are not
yet consumed Shared-nothing Async Message-passing
Processes 101The Basic Concurrency Primitive
Creating Processes & Sending Messages in Elixir
Creating a Process
Creating Processes & Sending Messages in Elixir
Module, Function, Arguments
Creating Processes & Sending Messages in Elixir
Process id
Creating Processes & Sending Messages in Elixir
Sending a Message to w1
Creating Processes & Sending Messages in Elixir
Process waits for a message …
Creating Processes & Sending Messages in Elixir
Pattern matches!
Creating Processes & Sending Messages in Elixir
Result is sent back to the
calling process (self)
Creating Processes & Sending Messages in Elixir
Returns immediately
Creating Processes & Sending Messages in Elixir
Get result from self
Creating Processes & Sending Messages in Elixir Demo
OTPFramework and much more
What is OTP?
• Comes with Elixir/Erlang
• Framework to build
applications that are fault-
tolerant, scalable,
distributed
• Databases + Profilers +
Debuggers
OTP Behaviours
• GenServer
• Supervisor
• Application
An Example GenServer
Implement the GenServer
Behaviour
An Example GenServer
Implement GenServer Callbacks
An Example GenServer
Callbacks are NOT called explicitly
An Example GenServer
OTP calls the callbacks.
An Example GenServer
Synchronous Call:
Caller waits for reply
An Example GenServer
Asynchronous Call:
Caller doesn’t wait
for reply
An Example GenServer Demo
SupervisorsFault Tolerance & Recovery
Supervisors for Fault Tolerance and Recovery
one_for_one restart strategy
Supervisors for Fault Tolerance and Recovery
rest_for_all restart strategy
Supervisors for Fault Tolerance and Recovery
rest_for_one restart strategy
An Example Supervisor
Implement the Supervisor
Behaviour
An Example Supervisor
Declaring the Supervision
tree. Both Supervisors and
Workers (e.g. GenServers)
can be supervised.
An Example Supervisor
An Example Supervisor
Declare the restart strategy
Supervisor Demo
Supervisor A
Supervisor B Supervisor C
Supervisor D
Server
D
Server
B
Worker 1Worker 1Worker
Supervisor Demo
Supervisor A
Supervisor B Supervisor C
Supervisor D
Server
D
Server
B
Worker 1Worker 1Worker
one_for_one
Supervisor Demo
Supervisor A
Supervisor B Supervisor C
Supervisor D
Server
D
Server
B
Worker 1Worker 1Worker
one_for_all
Supervisor Demo
Supervisor A
Supervisor B Supervisor C
Supervisor D
Server
D
Server
B
Worker 1Worker 1Worker
simple_one_for_one
Supervisor Demo
Supervisor A
Supervisor B Supervisor C
Supervisor D
Server
D
Server
B
Worker 1Worker 1Worker
one_for_one
Supervisor Demo
Supervisor A
Supervisor B Supervisor C
Supervisor D
Server
D
Server
B
Worker 1Worker 1Worker
one_for_one
simple_one_for_one
one_for_all
one_for_one
Elixir & Erlang
In less than 5 minutes
OTP
Framework and much more
Supervisors
Fault Tolerance & Recovery
Processes 101
The Basic Concurrency
Primitive
Resources
Work in Progress!
!
Sign up at:
http://www.exotpbook.com
Me.
Stickers!**Very Limited Quantity
Thanks!
/benjamintanweihao /bentanweihao
benjamintanweihao@gmail.com

More Related Content

What's hot (20)

PDF
How Elixir helped us scale our Video User Profile Service for the Olympics
Emerson Macedo
 
PPTX
Elixir Phoenix
Tanuj Soni
 
PPTX
Introduction to Phoenix Framework (Elixir) 2016-01-07
Svein Fidjestøl
 
PDF
GenRetry: Simple Exponential Backoff in Elixir
Pete Gamache
 
PDF
Learning Elixir as a Rubyist
Alex Kira
 
PPS
Erlang plus BDB: Disrupting the Conventional Web Wisdom
guest3933de
 
PDF
Rethinking the debugger
Iulian Dragos
 
PDF
effective_r27
Hiroshi Ono
 
PPTX
Akka.net versus microsoft orleans
Bill Tulloch
 
PPT
Nice performance using Sf2 cache wrapping Sf1 application
Marc Weistroff
 
PPTX
DDD loves Actor Model and Actor Model loves Elixir
Gianluca Padovani
 
PDF
Actor model : A Different Concurrency Approach
Emre Akış
 
PDF
Async await...oh wait!
Thomas Pierrain
 
PPTX
Ansible, Idempotency, and Jenkins
tylerturk
 
PDF
Elixir and elm
Mix & Go
 
PDF
Use the @types, Luke
Brooklyn Zelenka
 
PDF
Elixir intro
Anton Mishchuk
 
PDF
Functional programming with Xtend
Sven Efftinge
 
PDF
2021laravelconftwslides6
LiviaLiaoFontech
 
PDF
Debugging ansible modules
aleonhardt
 
How Elixir helped us scale our Video User Profile Service for the Olympics
Emerson Macedo
 
Elixir Phoenix
Tanuj Soni
 
Introduction to Phoenix Framework (Elixir) 2016-01-07
Svein Fidjestøl
 
GenRetry: Simple Exponential Backoff in Elixir
Pete Gamache
 
Learning Elixir as a Rubyist
Alex Kira
 
Erlang plus BDB: Disrupting the Conventional Web Wisdom
guest3933de
 
Rethinking the debugger
Iulian Dragos
 
effective_r27
Hiroshi Ono
 
Akka.net versus microsoft orleans
Bill Tulloch
 
Nice performance using Sf2 cache wrapping Sf1 application
Marc Weistroff
 
DDD loves Actor Model and Actor Model loves Elixir
Gianluca Padovani
 
Actor model : A Different Concurrency Approach
Emre Akış
 
Async await...oh wait!
Thomas Pierrain
 
Ansible, Idempotency, and Jenkins
tylerturk
 
Elixir and elm
Mix & Go
 
Use the @types, Luke
Brooklyn Zelenka
 
Elixir intro
Anton Mishchuk
 
Functional programming with Xtend
Sven Efftinge
 
2021laravelconftwslides6
LiviaLiaoFontech
 
Debugging ansible modules
aleonhardt
 

Viewers also liked (20)

PDF
Build Your Own Real-Time Web Service with Elixir Phoenix
Chi-chi Ekweozor
 
PDF
Bottleneck in Elixir Application - Alexey Osipenko
Elixir Club
 
ODP
Elixir basics-2
Ruben Amortegui
 
PDF
Elixir & Phoenix 推坑
Chao-Ju Huang
 
PDF
Hello elixir (and otp)
Abel Muíño
 
PDF
Elixir - Easy fun for busy developers @ Devoxx 2016
David Schmitz
 
PDF
Brief Intro to Phoenix - Elixir Meetup at BukaLapak
Riza Fahmi
 
PDF
Flow-based programming with Elixir
Anton Mishchuk
 
PDF
Distributed system in Elixir
Changwook Park
 
PDF
Flowex: Flow-Based Programming with Elixir GenStage - Anton Mishchuk
Elixir Club
 
PDF
Elixir and Dialyzer, Types and Typespecs, using and understanding them
Dan Janowski
 
PDF
Building a Network IP Camera using Erlang
Frank Hunleth
 
PDF
The Magic Of Elixir
Gabriele Lana
 
PDF
Introduction to Elixir
Diacode
 
PDF
ITB2016 - Mixing up the front end with ColdBox elixir
Ortus Solutions, Corp
 
PDF
Building Elixir App Release with Distillery and Docker
Mickey Chen
 
PPTX
A Brief Introduction To Erlang
Phillip Trelford
 
PPTX
Introduction to the Proteomics Bioinformatics Course 2016
Juan Antonio Vizcaino
 
PDF
Elixir and Phoenix for Rubyists
Brooklyn Zelenka
 
PPTX
BioContainers on ELIXIR All Hands 2017
Yasset Perez-Riverol
 
Build Your Own Real-Time Web Service with Elixir Phoenix
Chi-chi Ekweozor
 
Bottleneck in Elixir Application - Alexey Osipenko
Elixir Club
 
Elixir basics-2
Ruben Amortegui
 
Elixir & Phoenix 推坑
Chao-Ju Huang
 
Hello elixir (and otp)
Abel Muíño
 
Elixir - Easy fun for busy developers @ Devoxx 2016
David Schmitz
 
Brief Intro to Phoenix - Elixir Meetup at BukaLapak
Riza Fahmi
 
Flow-based programming with Elixir
Anton Mishchuk
 
Distributed system in Elixir
Changwook Park
 
Flowex: Flow-Based Programming with Elixir GenStage - Anton Mishchuk
Elixir Club
 
Elixir and Dialyzer, Types and Typespecs, using and understanding them
Dan Janowski
 
Building a Network IP Camera using Erlang
Frank Hunleth
 
The Magic Of Elixir
Gabriele Lana
 
Introduction to Elixir
Diacode
 
ITB2016 - Mixing up the front end with ColdBox elixir
Ortus Solutions, Corp
 
Building Elixir App Release with Distillery and Docker
Mickey Chen
 
A Brief Introduction To Erlang
Phillip Trelford
 
Introduction to the Proteomics Bioinformatics Course 2016
Juan Antonio Vizcaino
 
Elixir and Phoenix for Rubyists
Brooklyn Zelenka
 
BioContainers on ELIXIR All Hands 2017
Yasset Perez-Riverol
 
Ad

Similar to Elixir – Peeking into Elixir's Processes, OTP and Supervisors (20)

PPTX
Elixir
Fuat Buğra AYDIN
 
PDF
A sip of Elixir
Emanuele DelBono
 
PPTX
OTP, Concurrency and Testing Strategies
Adrián Mugnolo
 
PDF
Erlang factory SF 2011 "Erlang and the big switch in social games"
Paolo Negri
 
PDF
Erlang, the big switch in social games
Wooga
 
ODP
Elixir otp-basics
Ruben Amortegui
 
PPTX
Repeating History...On Purpose...with Elixir
Barry Jones
 
PDF
Erlang workshopdrammen
Reidar Sollid
 
PPT
Selenium Concepts
Swati Bansal
 
PDF
Phoenix for Rubyists
Doug Goldie
 
ODP
Elm & Elixir: Functional Programming and Web
Publitory
 
PDF
DevOps in the Real World
Max Yermakhanov
 
PDF
4Developers 2015: Lessons for Erlang VM - Michał Ślaski
PROIDEA
 
PPT
The Migration From Erlang To Otp A Case Study Of A Heavy Duty Tcpip Clients...
l xf
 
PPTX
PCSG_Computer_Science_Unit_1_Lecture_2.pptx
AliyahAli19
 
PPTX
From Ruby to Elixir
Maksym Pugach
 
PPT
Clojure's take on concurrency
yoavrubin
 
PDF
The dream BEAM - A former DevOps perspective
Jeffrey Chan
 
PPTX
CPP03 - Repetition
Michael Heron
 
PDF
Module-1_Getting-Started_with_selenium_and_Java_basics.pdf
devika266518
 
A sip of Elixir
Emanuele DelBono
 
OTP, Concurrency and Testing Strategies
Adrián Mugnolo
 
Erlang factory SF 2011 "Erlang and the big switch in social games"
Paolo Negri
 
Erlang, the big switch in social games
Wooga
 
Elixir otp-basics
Ruben Amortegui
 
Repeating History...On Purpose...with Elixir
Barry Jones
 
Erlang workshopdrammen
Reidar Sollid
 
Selenium Concepts
Swati Bansal
 
Phoenix for Rubyists
Doug Goldie
 
Elm & Elixir: Functional Programming and Web
Publitory
 
DevOps in the Real World
Max Yermakhanov
 
4Developers 2015: Lessons for Erlang VM - Michał Ślaski
PROIDEA
 
The Migration From Erlang To Otp A Case Study Of A Heavy Duty Tcpip Clients...
l xf
 
PCSG_Computer_Science_Unit_1_Lecture_2.pptx
AliyahAli19
 
From Ruby to Elixir
Maksym Pugach
 
Clojure's take on concurrency
yoavrubin
 
The dream BEAM - A former DevOps perspective
Jeffrey Chan
 
CPP03 - Repetition
Michael Heron
 
Module-1_Getting-Started_with_selenium_and_Java_basics.pdf
devika266518
 
Ad

Recently uploaded (20)

PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
July Patch Tuesday
Ivanti
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Python basic programing language for automation
DanialHabibi2
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
July Patch Tuesday
Ivanti
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 

Elixir – Peeking into Elixir's Processes, OTP and Supervisors