O SlideShare utiliza cookies para otimizar a funcionalidade e o desempenho do site, assim como para apresentar publicidade mais relevante aos nossos usuários. Se você continuar a navegar o site, você aceita o uso de cookies. Leia nosso Contrato do Usuário e nossa Política de Privacidade.
O SlideShare utiliza cookies para otimizar a funcionalidade e o desempenho do site, assim como para apresentar publicidade mais relevante aos nossos usuários. Se você continuar a utilizar o site, você aceita o uso de cookies. Leia nossa Política de Privacidade e nosso Contrato do Usuário para obter mais detalhes.
You’re already familiar with
immutability you just don’t know it.
• a = 99
• We all know 99 is always 99.
• integers are immutable values, even in Ruby.
• You’d be upset if someone monkey patched 99
to be 3 right?
Why is Immutability a good
• Immutability provides a contract that each piece
of information has one source of truth.
• Concurrency is a natural side effect of
Does this mean I can never
change a variable once I set it?
• The short answer is no, you can reassign
variables as much as you like.
• Erlang would not be so kind, but Elixir we have
So how is it immutable if I
can change things?
• You can change things, elixir will just copy the
values you don’t change, but the original
reference stays intact.
• The original reference can then be used in part
or in whole later in the application.
Isn’t this inefﬁcient?
• At ﬁrst glance it would seem that way, but the
opposite is true.
• Won’t all the old reference values balloon elixirs
• Yes this means you could have thousands of
unused variables ﬂoating in memory
• Because the data is immutable we can rely on it
always being a certain value
• which means we can make our programs
concurrent and not worry.
• Elixir uses its concurrency to help with garbage
collections. Each process gets it own heap
allocated and that heap is garbage collected or
reclaimed as needed for that individual process.
• Elixir will eat as many cores/computers as you
can throw at it.
• It treats each core as though it were a computer
on the network with near zero latency.
Productive |> Reliable |> Fast
• Created by Chris McCord
• Release 1.0 August 28th 2015
• It’s not rails for Elixir
• It has been inﬂuence heavily by rails as well as
many other frameworks.
• Focus on API and web sockets
• Web request response time is often measured in
micro seconds and not milliseconds.
• Recently benchmarked 2 million+ web socket
• With 2 - 3 second broadcast times to all 2 million
• Mix is essentially bundler and rake combined
• Additionally mix is your test runner.
• It’s included with Elixir
Rails like Generators
• mix phoenix.gen.html Post posts title body:text
• mix phoenix.gen.json User users name:string
• mix phoenix.gen.model User users name:string
• Async processing with out the need for
DelayedJob or Resque/sidekiq
• We can write code that looks like this.
Isolated & Concurrent
• Crashes are isolated
• Data is isolated
(GC is per process, no global pauses)
• Load Balances on IO and CPU - Efﬁcient on a
• No triggering massive garbage collection
• GC per process / end of process life cycle
• Ensuring top 10 percent of requests are not vastly
slower than any other request
• Just a series of function calls that transform
• Phoenix makes it easy to add middleware or
plugs to this pipeline. We could easily add
authentication to this.
Explicitness Over Magic
• Phoenix Removes a lot of the confusion and
“magic” found in rails and replaces it with
• Models, Controllers and Views are singular
named by convention.