SlideShare a Scribd company logo
1 of 38
Phoenix a Rails successor
INTRODUCTION TO ELIXIR AND ITS POWERFUL WEB FRAMEWORK
Tanuj Soni | mail@tanuj.in
1
What is Phoenix?
It’s a web framework that is written in Elixir
programing language and runs on Erlang
virtual machine.
2
How does it came to existence
Chris Mccord (the creator of Phoenix) was working on a realtime application
in which clients had to open long connections with the server and needed to
have data flowing full duplex mode.
And developing scalable realtime applications was hard because the clients
will maintain long connections with server and will block the resources of the
server till the connection ends.
While he was trying to figure out the problem he heard WhatsApp case.
WhatsApp guys were maintaining 2 Million connections on a single machine.
Blog post describing the case..
http://blog.whatsapp.com/index.php/2012/01/1-million-is-so-2011/
3
WhatsApp Server configuration
Intel(R) Xeon(R) CPU X5675 @ 3.07GHz
24 CPU Cores
96 GB RAM
Only 40% of RAM and CPU were utilized…..
4
● It was designed by Ericsson for its
telecommunication systems in 1986.
● It’s Distributed, Fault-tolerant and Hot swappable
language. These features met all telecommunication
requirements.
5
● Elixir is a functional, concurrent, general-purpose programming language
that runs on the Erlang virtual machine (BEAM).
● José Valim is the creator of the Elixir programming language, a R&D
project of Plataformatec. His goals were to enable higher extensibility and
productivity in the Erlang VM while keeping compatibility with Erlang's tools
and ecosystem.
● José added a lot of syntactic sugar to make look similar to Ruby.
Ref- https://en.wikipedia.org/wiki/Elixir_(programming_language)
6
7
8
9
10
What is new in that?
Isn't that’s similar to Node or EM Websocket Ruby?
11
The difference is about scaling!
● The clock speed of newer CPUs are not getting faster
instead they having multiple cores.
● Ruby and Node both are not able to utilize the
resources in a way these are utilized by Elixir.
● As we have seen the WhatsApp case we know the
Elixir can scale vertically and it scales very well.
12
So what happens if we can not further
scale vertically?
13
14
We start scaling it horizontally
● If a single powerful machine is not capable, we can simply turn on another
machine and tell this new machine how to find other machines.
● Erlang is distributed so is Elixir as the system is designed around message
passing, the Erlang VM abstracts the message passing in a such a way
that it doesn’t matter if the recipient of the message is in the same
machine or in another node in the same network.
15
Scaling vertically by adding more powerful hardware
was a thing of the past. We scaled horizontally, by
adding more commodity hardware. With the coming of
age of mega-core architectures, we have the choice of
either adding more hardware or more cores, or both.
Erlang style concurrency puts Elixir/Phoenix ahead of
the game when it comes to scaling with both
approaches.
16
17
18
● Whenever a socket is initiated a new process is
created to handle it. Don’t worry the are Erlang virtual
machine processes not operating system processes.
● And for every channel that is created within this
channel separate processes are created.
● Erlang VM processes are very isolated that means a
buggy or faulty channel will not affect any other thing
in the system.
● All the processes are concurrent so none of the
process is going to block anything in the system.
19
Problem with Node
Despite its asynchronous event model, by nature it is
single threaded. When you launch a Node process, you
are running a single process with a single thread on a
single core. So your code will not be executed in
parallel, only I/O operations are parallel because they
are executed asynchronous. As such, long running CPU
tasks will block the whole server and are usually a bad
way to do things.
20
Problem with Rails 5 ActionCable
One of Rails screencast suggested that “You should
not do any processing in action cable channels
because they are not concurrent , if you do they will
block everything.” and that is true.
What Rails actually does is that it puts the actions in a
queue after some time it will be fetched, processed
and broadcasted afterwards.
21
This was a brief introduction about
how it came to existence.
22
With Elixir Phoenix we can be as
much productive as we were with
Rails best part is that the
developed things are going to be
multiple times efficient.
Let’s see other benchmarks and
features of Phoenix.
23
The Road to 2 Million Websocket
Connections in Phoenix
● Phoenix guys started to benchmark the framework developed on a 128GB
RAM and 40 cores.
● And they were able to open 2 Million connections using 80 GB of RAM.
CPUs were ideal as none of the data was flowing.
● They broadcasted a Wikipedia article to 2 million connection and it took
only 3 seconds.
Ref-
http://www.phoenixframework.org/blog/the-road-to-2-million-websocket-
connections
24
25
26
How regular applications benefit from
Elixir Phoenix?
Phoenix allocates a separate
dedicated Erlang VM process for
every http request and serves
them concurrently.
27
28
● Data for each request is isolated.
● Garbage Collector is per process based.
● Most of the time it is not required to Garbage collect as once the request is
served the data is scraped, no GC is required and this also saves the CPU
cycles.
● Node, Ruby, Python have global GCs and when the servers starts getting
heavy load the GC starts running very frequently that increases the
response time of requests.
29
● Ref- https://github.com/mroth/phoenix-showdown
30
Productivity
➢Short-term Productivity
- Documentation/Guides
- Workflows/Generators
➢Long-term Productivity
- Introspection
- Maintainability
31
32
Generators
mix phoenix.gen.html
mix phoenix.gen.json
mix phoenix.gen.channel
These generates highly documented code.
33
Some more development addons.
● Live Reloads.
● ES6 as default.
● Pretty error pages.
● Concurrency test tools.
● (HEX) Packages and dependency resolution tool.
● Uses all cores for compiling code.
● Uses all cores to run tests.
● Debuggers: IEx.pry, Debugger(GUI).
34
35
Observer Tool
Observer allows us to open multiple windows with information on the whole
system's statistics or even an individual process of that running system.
It makes it easy to identify the bottlenecks of the application just by looking in
to the stats of resources consumed by multiple processes.
We can simulate an error by manually killing process or by killing DB
connection pools.
36
Related links
● https://github.com/h4cc/awesome-elixir
● https://hex.pm/
● https://github.com/doomspork/elixir-companies
● http://elixir-lang.org/docs.html
● https://hexdocs.pm/phoenix/Phoenix.html
37
Tanuj Soni
mail@tanuj.in
https://www.linkedin.com/in/tanujsoni
38
Contact me on the below details for any question or
suggestion.

More Related Content

What's hot

GenRetry: Simple Exponential Backoff in Elixir
GenRetry: Simple Exponential Backoff in ElixirGenRetry: Simple Exponential Backoff in Elixir
GenRetry: Simple Exponential Backoff in ElixirPete Gamache
 
Learning Elixir as a Rubyist
Learning Elixir as a RubyistLearning Elixir as a Rubyist
Learning Elixir as a RubyistAlex Kira
 
The Actor Model - Towards Better Concurrency
The Actor Model - Towards Better ConcurrencyThe Actor Model - Towards Better Concurrency
The Actor Model - Towards Better ConcurrencyDror Bereznitsky
 
Rethinking the debugger
Rethinking the debuggerRethinking the debugger
Rethinking the debuggerIulian Dragos
 
Building Elixir App Release with Distillery and Docker
Building Elixir App Release with Distillery and DockerBuilding Elixir App Release with Distillery and Docker
Building Elixir App Release with Distillery and DockerMickey Chen
 
Awesome Concurrency with Elixir Tasks
Awesome Concurrency with Elixir TasksAwesome Concurrency with Elixir Tasks
Awesome Concurrency with Elixir TasksJonathan Magen
 
Intro to Erlang
Intro to ErlangIntro to Erlang
Intro to ErlangKen Pratt
 
Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threadsmperham
 
Phoenix for Rubyists
Phoenix for RubyistsPhoenix for Rubyists
Phoenix for RubyistsDoug Goldie
 
Increase eZ Power With EzCoreExtraBundle (presented by Jérôme Vieilledent at ...
Increase eZ Power With EzCoreExtraBundle (presented by Jérôme Vieilledent at ...Increase eZ Power With EzCoreExtraBundle (presented by Jérôme Vieilledent at ...
Increase eZ Power With EzCoreExtraBundle (presented by Jérôme Vieilledent at ...eZ Systems
 
Developer-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing oneDeveloper-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing oneSylvain Zimmer
 
Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)Esun Kim
 
Actor model : A Different Concurrency Approach
Actor model : A Different Concurrency ApproachActor model : A Different Concurrency Approach
Actor model : A Different Concurrency ApproachEmre Akış
 
Refactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and PatternsRefactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and PatternsTristan Gomez
 
Nice performance using Sf2 cache wrapping Sf1 application
Nice performance using Sf2 cache wrapping Sf1 applicationNice performance using Sf2 cache wrapping Sf1 application
Nice performance using Sf2 cache wrapping Sf1 applicationMarc Weistroff
 
Don Wibier
Don WibierDon Wibier
Don WibierCodeFest
 
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyFast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyKyle Drake
 
Swift 2 Under the Hood - Gotober 2015
Swift 2 Under the Hood - Gotober 2015Swift 2 Under the Hood - Gotober 2015
Swift 2 Under the Hood - Gotober 2015Alex Blewitt
 
NCUG 2019: Spring forward: an introduction to Spring boot and Thymeleaf for (...
NCUG 2019: Spring forward: an introduction to Spring boot and Thymeleaf for (...NCUG 2019: Spring forward: an introduction to Spring boot and Thymeleaf for (...
NCUG 2019: Spring forward: an introduction to Spring boot and Thymeleaf for (...Frank van der Linden
 

What's hot (20)

GenRetry: Simple Exponential Backoff in Elixir
GenRetry: Simple Exponential Backoff in ElixirGenRetry: Simple Exponential Backoff in Elixir
GenRetry: Simple Exponential Backoff in Elixir
 
Learning Elixir as a Rubyist
Learning Elixir as a RubyistLearning Elixir as a Rubyist
Learning Elixir as a Rubyist
 
The Actor Model - Towards Better Concurrency
The Actor Model - Towards Better ConcurrencyThe Actor Model - Towards Better Concurrency
The Actor Model - Towards Better Concurrency
 
Rethinking the debugger
Rethinking the debuggerRethinking the debugger
Rethinking the debugger
 
Building Elixir App Release with Distillery and Docker
Building Elixir App Release with Distillery and DockerBuilding Elixir App Release with Distillery and Docker
Building Elixir App Release with Distillery and Docker
 
Awesome Concurrency with Elixir Tasks
Awesome Concurrency with Elixir TasksAwesome Concurrency with Elixir Tasks
Awesome Concurrency with Elixir Tasks
 
Intro to Erlang
Intro to ErlangIntro to Erlang
Intro to Erlang
 
Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threads
 
Phoenix for Rubyists
Phoenix for RubyistsPhoenix for Rubyists
Phoenix for Rubyists
 
Increase eZ Power With EzCoreExtraBundle (presented by Jérôme Vieilledent at ...
Increase eZ Power With EzCoreExtraBundle (presented by Jérôme Vieilledent at ...Increase eZ Power With EzCoreExtraBundle (presented by Jérôme Vieilledent at ...
Increase eZ Power With EzCoreExtraBundle (presented by Jérôme Vieilledent at ...
 
Developer-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing oneDeveloper-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing one
 
Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)
 
Actor model : A Different Concurrency Approach
Actor model : A Different Concurrency ApproachActor model : A Different Concurrency Approach
Actor model : A Different Concurrency Approach
 
Refactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and PatternsRefactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and Patterns
 
Nice performance using Sf2 cache wrapping Sf1 application
Nice performance using Sf2 cache wrapping Sf1 applicationNice performance using Sf2 cache wrapping Sf1 application
Nice performance using Sf2 cache wrapping Sf1 application
 
Don Wibier
Don WibierDon Wibier
Don Wibier
 
Introduction to keras
Introduction to kerasIntroduction to keras
Introduction to keras
 
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyFast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
 
Swift 2 Under the Hood - Gotober 2015
Swift 2 Under the Hood - Gotober 2015Swift 2 Under the Hood - Gotober 2015
Swift 2 Under the Hood - Gotober 2015
 
NCUG 2019: Spring forward: an introduction to Spring boot and Thymeleaf for (...
NCUG 2019: Spring forward: an introduction to Spring boot and Thymeleaf for (...NCUG 2019: Spring forward: an introduction to Spring boot and Thymeleaf for (...
NCUG 2019: Spring forward: an introduction to Spring boot and Thymeleaf for (...
 

Viewers also liked

Concurrency, Robustness & Elixir SoCraTes 2015
Concurrency, Robustness & Elixir SoCraTes 2015Concurrency, Robustness & Elixir SoCraTes 2015
Concurrency, Robustness & Elixir SoCraTes 2015steffenbauer
 
Going crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPGoing crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPMariano Iglesias
 
Bootstrap |> Elixir - Easy fun for busy developers
Bootstrap |> Elixir - Easy fun for busy developersBootstrap |> Elixir - Easy fun for busy developers
Bootstrap |> Elixir - Easy fun for busy developersDavid Schmitz
 
Current and future plans for ELIXIR presentation given by Niklas Blomberg, EL...
Current and future plans for ELIXIR presentation given by Niklas Blomberg, EL...Current and future plans for ELIXIR presentation given by Niklas Blomberg, EL...
Current and future plans for ELIXIR presentation given by Niklas Blomberg, EL...ELIXIR-Europe
 
IET NW Region - Payment Hub Design
IET NW Region - Payment Hub DesignIET NW Region - Payment Hub Design
IET NW Region - Payment Hub DesignGary Farrow
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean ArchitectureMattia Battiston
 

Viewers also liked (6)

Concurrency, Robustness & Elixir SoCraTes 2015
Concurrency, Robustness & Elixir SoCraTes 2015Concurrency, Robustness & Elixir SoCraTes 2015
Concurrency, Robustness & Elixir SoCraTes 2015
 
Going crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPGoing crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHP
 
Bootstrap |> Elixir - Easy fun for busy developers
Bootstrap |> Elixir - Easy fun for busy developersBootstrap |> Elixir - Easy fun for busy developers
Bootstrap |> Elixir - Easy fun for busy developers
 
Current and future plans for ELIXIR presentation given by Niklas Blomberg, EL...
Current and future plans for ELIXIR presentation given by Niklas Blomberg, EL...Current and future plans for ELIXIR presentation given by Niklas Blomberg, EL...
Current and future plans for ELIXIR presentation given by Niklas Blomberg, EL...
 
IET NW Region - Payment Hub Design
IET NW Region - Payment Hub DesignIET NW Region - Payment Hub Design
IET NW Region - Payment Hub Design
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean Architecture
 

Similar to Elixir Phoenix

2014 carlos gzlez florido nksip the erlang sip application server
2014 carlos gzlez florido nksip the erlang sip application server2014 carlos gzlez florido nksip the erlang sip application server
2014 carlos gzlez florido nksip the erlang sip application serverVOIP2DAY
 
UniK - a unikernel compiler and runtime
UniK - a unikernel compiler and runtimeUniK - a unikernel compiler and runtime
UniK - a unikernel compiler and runtimeLee Calcote
 
DockerDay2015: Keynote
DockerDay2015: KeynoteDockerDay2015: Keynote
DockerDay2015: KeynoteDocker-Hanoi
 
Phoenix Framework for the realtime web
Phoenix Framework for the realtime webPhoenix Framework for the realtime web
Phoenix Framework for the realtime webPedro Medeiros
 
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...Russell Pavlicek
 
OSCON: Unikernels and Docker: From revolution to evolution
OSCON: Unikernels and Docker: From revolution to evolutionOSCON: Unikernels and Docker: From revolution to evolution
OSCON: Unikernels and Docker: From revolution to evolutionDocker, Inc.
 
Sharding Containers: Make Go Apps Computer-Friendly Again by Andrey Sibiryov
Sharding Containers: Make Go Apps Computer-Friendly Again by Andrey Sibiryov Sharding Containers: Make Go Apps Computer-Friendly Again by Andrey Sibiryov
Sharding Containers: Make Go Apps Computer-Friendly Again by Andrey Sibiryov Docker, Inc.
 
Docker Online Meetup #31: Unikernels
Docker Online Meetup #31: UnikernelsDocker Online Meetup #31: Unikernels
Docker Online Meetup #31: UnikernelsDocker, Inc.
 
Node.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel AvivNode.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel AvivRon Perlmuter
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640LLC NewLink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Newlink
 

Similar to Elixir Phoenix (20)

From Ruby to Elixir
From Ruby to ElixirFrom Ruby to Elixir
From Ruby to Elixir
 
NkSIP: The Erlang SIP application server
NkSIP: The Erlang SIP application serverNkSIP: The Erlang SIP application server
NkSIP: The Erlang SIP application server
 
2014 carlos gzlez florido nksip the erlang sip application server
2014 carlos gzlez florido nksip the erlang sip application server2014 carlos gzlez florido nksip the erlang sip application server
2014 carlos gzlez florido nksip the erlang sip application server
 
UniK - a unikernel compiler and runtime
UniK - a unikernel compiler and runtimeUniK - a unikernel compiler and runtime
UniK - a unikernel compiler and runtime
 
The C10k Problem
The C10k ProblemThe C10k Problem
The C10k Problem
 
Elixir in the Wild
Elixir in the WildElixir in the Wild
Elixir in the Wild
 
DockerDay2015: Keynote
DockerDay2015: KeynoteDockerDay2015: Keynote
DockerDay2015: Keynote
 
Phoenix Framework for the realtime web
Phoenix Framework for the realtime webPhoenix Framework for the realtime web
Phoenix Framework for the realtime web
 
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
 
OSCON: Unikernels and Docker: From revolution to evolution
OSCON: Unikernels and Docker: From revolution to evolutionOSCON: Unikernels and Docker: From revolution to evolution
OSCON: Unikernels and Docker: From revolution to evolution
 
MIcrokernel
MIcrokernelMIcrokernel
MIcrokernel
 
Sharding Containers: Make Go Apps Computer-Friendly Again by Andrey Sibiryov
Sharding Containers: Make Go Apps Computer-Friendly Again by Andrey Sibiryov Sharding Containers: Make Go Apps Computer-Friendly Again by Andrey Sibiryov
Sharding Containers: Make Go Apps Computer-Friendly Again by Andrey Sibiryov
 
Docker Online Meetup #31: Unikernels
Docker Online Meetup #31: UnikernelsDocker Online Meetup #31: Unikernels
Docker Online Meetup #31: Unikernels
 
Concurrency in ruby
Concurrency in rubyConcurrency in ruby
Concurrency in ruby
 
Node.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel AvivNode.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel Aviv
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 

Recently uploaded

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Elixir Phoenix

  • 1. Phoenix a Rails successor INTRODUCTION TO ELIXIR AND ITS POWERFUL WEB FRAMEWORK Tanuj Soni | mail@tanuj.in 1
  • 2. What is Phoenix? It’s a web framework that is written in Elixir programing language and runs on Erlang virtual machine. 2
  • 3. How does it came to existence Chris Mccord (the creator of Phoenix) was working on a realtime application in which clients had to open long connections with the server and needed to have data flowing full duplex mode. And developing scalable realtime applications was hard because the clients will maintain long connections with server and will block the resources of the server till the connection ends. While he was trying to figure out the problem he heard WhatsApp case. WhatsApp guys were maintaining 2 Million connections on a single machine. Blog post describing the case.. http://blog.whatsapp.com/index.php/2012/01/1-million-is-so-2011/ 3
  • 4. WhatsApp Server configuration Intel(R) Xeon(R) CPU X5675 @ 3.07GHz 24 CPU Cores 96 GB RAM Only 40% of RAM and CPU were utilized….. 4
  • 5. ● It was designed by Ericsson for its telecommunication systems in 1986. ● It’s Distributed, Fault-tolerant and Hot swappable language. These features met all telecommunication requirements. 5
  • 6. ● Elixir is a functional, concurrent, general-purpose programming language that runs on the Erlang virtual machine (BEAM). ● José Valim is the creator of the Elixir programming language, a R&D project of Plataformatec. His goals were to enable higher extensibility and productivity in the Erlang VM while keeping compatibility with Erlang's tools and ecosystem. ● José added a lot of syntactic sugar to make look similar to Ruby. Ref- https://en.wikipedia.org/wiki/Elixir_(programming_language) 6
  • 7. 7
  • 8. 8
  • 9. 9
  • 10. 10
  • 11. What is new in that? Isn't that’s similar to Node or EM Websocket Ruby? 11
  • 12. The difference is about scaling! ● The clock speed of newer CPUs are not getting faster instead they having multiple cores. ● Ruby and Node both are not able to utilize the resources in a way these are utilized by Elixir. ● As we have seen the WhatsApp case we know the Elixir can scale vertically and it scales very well. 12
  • 13. So what happens if we can not further scale vertically? 13
  • 14. 14
  • 15. We start scaling it horizontally ● If a single powerful machine is not capable, we can simply turn on another machine and tell this new machine how to find other machines. ● Erlang is distributed so is Elixir as the system is designed around message passing, the Erlang VM abstracts the message passing in a such a way that it doesn’t matter if the recipient of the message is in the same machine or in another node in the same network. 15
  • 16. Scaling vertically by adding more powerful hardware was a thing of the past. We scaled horizontally, by adding more commodity hardware. With the coming of age of mega-core architectures, we have the choice of either adding more hardware or more cores, or both. Erlang style concurrency puts Elixir/Phoenix ahead of the game when it comes to scaling with both approaches. 16
  • 17. 17
  • 18. 18
  • 19. ● Whenever a socket is initiated a new process is created to handle it. Don’t worry the are Erlang virtual machine processes not operating system processes. ● And for every channel that is created within this channel separate processes are created. ● Erlang VM processes are very isolated that means a buggy or faulty channel will not affect any other thing in the system. ● All the processes are concurrent so none of the process is going to block anything in the system. 19
  • 20. Problem with Node Despite its asynchronous event model, by nature it is single threaded. When you launch a Node process, you are running a single process with a single thread on a single core. So your code will not be executed in parallel, only I/O operations are parallel because they are executed asynchronous. As such, long running CPU tasks will block the whole server and are usually a bad way to do things. 20
  • 21. Problem with Rails 5 ActionCable One of Rails screencast suggested that “You should not do any processing in action cable channels because they are not concurrent , if you do they will block everything.” and that is true. What Rails actually does is that it puts the actions in a queue after some time it will be fetched, processed and broadcasted afterwards. 21
  • 22. This was a brief introduction about how it came to existence. 22
  • 23. With Elixir Phoenix we can be as much productive as we were with Rails best part is that the developed things are going to be multiple times efficient. Let’s see other benchmarks and features of Phoenix. 23
  • 24. The Road to 2 Million Websocket Connections in Phoenix ● Phoenix guys started to benchmark the framework developed on a 128GB RAM and 40 cores. ● And they were able to open 2 Million connections using 80 GB of RAM. CPUs were ideal as none of the data was flowing. ● They broadcasted a Wikipedia article to 2 million connection and it took only 3 seconds. Ref- http://www.phoenixframework.org/blog/the-road-to-2-million-websocket- connections 24
  • 25. 25
  • 26. 26
  • 27. How regular applications benefit from Elixir Phoenix? Phoenix allocates a separate dedicated Erlang VM process for every http request and serves them concurrently. 27
  • 28. 28
  • 29. ● Data for each request is isolated. ● Garbage Collector is per process based. ● Most of the time it is not required to Garbage collect as once the request is served the data is scraped, no GC is required and this also saves the CPU cycles. ● Node, Ruby, Python have global GCs and when the servers starts getting heavy load the GC starts running very frequently that increases the response time of requests. 29
  • 31. Productivity ➢Short-term Productivity - Documentation/Guides - Workflows/Generators ➢Long-term Productivity - Introspection - Maintainability 31
  • 32. 32
  • 33. Generators mix phoenix.gen.html mix phoenix.gen.json mix phoenix.gen.channel These generates highly documented code. 33
  • 34. Some more development addons. ● Live Reloads. ● ES6 as default. ● Pretty error pages. ● Concurrency test tools. ● (HEX) Packages and dependency resolution tool. ● Uses all cores for compiling code. ● Uses all cores to run tests. ● Debuggers: IEx.pry, Debugger(GUI). 34
  • 35. 35
  • 36. Observer Tool Observer allows us to open multiple windows with information on the whole system's statistics or even an individual process of that running system. It makes it easy to identify the bottlenecks of the application just by looking in to the stats of resources consumed by multiple processes. We can simulate an error by manually killing process or by killing DB connection pools. 36
  • 37. Related links ● https://github.com/h4cc/awesome-elixir ● https://hex.pm/ ● https://github.com/doomspork/elixir-companies ● http://elixir-lang.org/docs.html ● https://hexdocs.pm/phoenix/Phoenix.html 37
  • 38. Tanuj Soni mail@tanuj.in https://www.linkedin.com/in/tanujsoni 38 Contact me on the below details for any question or suggestion.