SlideShare a Scribd company logo
1 of 56
Download to read offline
Elixir & Phoenix
Functional |> Concurrent |> Pragmatic |> Fun
Who am I?
• Jared Smith
• Software Engineer at One Month
• @sublimecoder
• www.sublimecoding.com
Lets get started
First lets talk about Erlang
• Elixir runs on the Erlang VM
• Many of the standard lib function calls in Elixir
call Erlang functions directly.
• Elixir piggy backs on the Erlang ecosystem
Why Erlang VM?
• 30 year old battle tested VM
• Highly available, fault tolerant, and distributed
History of Erlang
• Developed by Ericsson
• Used and developed for Telecommunications
• In fact its standard library is the OTP (Open
Telecom Platform)
Telecommunications
• High availability is king
• Remote Telecom switches need to run for years
sometimes with out being disturbed
Built with Erlang
• 50 person engineering team
• managing 900 million users.
• Up to 2 million active users per server.
https://blog.whatsapp.com/196/1-million-is-so-2011
2 Million Active Users?
• Intel Xeon CPU x5675 @ 3.07GHz

24 Cores - 96GB Ram
• Using only 40% of the CPU/Memory
https://blog.whatsapp.com/196/1-million-is-so-2011
So Erlang is pretty awesome
• Wouldn’t it be nice if we could harness this
power?
• Why isn’t everyone using Erlang?
Elixir
• Elixir utilizes much of the power of Erlang
• While giving us a much nicer syntax and api to
work with.
History of Elixir
• Created by Josè Valím - (Joe-zay Val-eem)
• First released in 2012
Elixir’s Strengths
• Concurrency
• Meta-programming Capability
• Transformation of data as a core ideal
Plus it has Ruby like syntax
Pipe Operator
• The following code is valid elixir.
• With the pipe operator we can write our code this
way instead. Keeping us out of nested function
hell.
Pattern Matching
• Pattern matching is a core part of Erlang and
Elixir
What is Pattern Matching?
• Make left side look like the right side
• a = 99
• [a,b,c] = [1,2,3]
• [head | tail] = [1,2,3]
Immutability
• Once you set a value 

it can never change.
Immutability
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
thing?
• Immutability provides a contract that each piece
of information has one source of truth.
• Concurrency is a natural side effect of
immutability.
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
this luxury.
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 inefficient?
• At first glance it would seem that way, but the
opposite is true.
• Won’t all the old reference values balloon elixirs
memory?
• Yes this means you could have thousands of
unused variables floating in memory
Concurrency
Concurrency fixes
everything
• 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.
Concurrency
• 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.
Phoenix Framework
Productive |> Reliable |> Fast
Phoenix Framework
• Created by Chris McCord
• Release 1.0 August 28th 2015
Phoenix Framework
• It’s not rails for Elixir
• It has been influence heavily by rails as well as
many other frameworks.
• Focus on API and web sockets
Speed
• Web request response time is often measured in
micro seconds and not milliseconds.
Benchmarks
• Recently benchmarked 2 million+ web socket
connections
• With 2 - 3 second broadcast times to all 2 million
connections
Benchmarks
https://github.com/mroth/phoenix-showdown
iMac Intel Core i7 (4.0 GHz 4 Cores) 32 GB RAM
https://github.com/mroth/phoenix-showdown
2.8 Ghz, 10 core Intel® Xeon 128 GB RAM
Easy Startup
• mix phoenix.new ./app/path/my_app
• mix ecto.create && mix ecto.migrate
• mix phoenix.server
Directory Structure
Web Dir Structure
Mix
• 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
Concurrency
• 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 - Efficient on a
multicore
Garbage Collection
• 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
Request Pipeline
• Just a series of function calls that transform
data.
• connection 

|> endpoint

|> router

|> pipelines

|> controller
Request Pipeline
• Phoenix makes it easy to add middleware or
plugs to this pipeline. We could easily add
authentication to this.
• connection 

|> endpoint

|> router

|> pipelines

|> authenticate_user

|> controller
Explicitness Over Magic
• Phoenix Removes a lot of the confusion and
“magic” found in rails and replaces it with
explicit calls.
• Models, Controllers and Views are singular
named by convention.
Phoenix Router
Phoenix Router
Phoenix Router
Phoenix Controllers
Phoenix Model
Phoenix View
Phoenix Template
Learn More
• Elixir-Lang on Slack 

https://elixir-slackin.herokuapp.com/
• #elixir-lang on Freenode IRC
• http://www.phoenixframework.org
• http://elixir-lang.org/
• https://github.com/h4cc/awesome-elixir

More Related Content

What's hot

Comparing Next-Generation Container Image Building Tools
 Comparing Next-Generation Container Image Building Tools Comparing Next-Generation Container Image Building Tools
Comparing Next-Generation Container Image Building ToolsAkihiro Suda
 
Developer Experience at Zalando - Handelsblatt Strategisches IT-Management 2019
Developer Experience at Zalando - Handelsblatt Strategisches IT-Management 2019Developer Experience at Zalando - Handelsblatt Strategisches IT-Management 2019
Developer Experience at Zalando - Handelsblatt Strategisches IT-Management 2019Henning Jacobs
 
Modern CI/CD Pipeline Using Azure DevOps
Modern CI/CD Pipeline Using Azure DevOpsModern CI/CD Pipeline Using Azure DevOps
Modern CI/CD Pipeline Using Azure DevOpsGlobalLogic Ukraine
 
Kubernetes deployment strategies - CNCF Webinar
Kubernetes deployment strategies - CNCF WebinarKubernetes deployment strategies - CNCF Webinar
Kubernetes deployment strategies - CNCF WebinarEtienne Tremel
 
DevOps 101 - an Introduction to DevOps
DevOps 101  - an Introduction to DevOpsDevOps 101  - an Introduction to DevOps
DevOps 101 - an Introduction to DevOpsRed Gate Software
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101Huy Vo
 
컨테이너 와 가상화 기술 비교 발표 자료
컨테이너 와 가상화 기술 비교 발표 자료컨테이너 와 가상화 기술 비교 발표 자료
컨테이너 와 가상화 기술 비교 발표 자료Opennaru, inc.
 
Set Up a CI/CD Pipeline for Deploying Containers Using the AWS Developer Tool...
Set Up a CI/CD Pipeline for Deploying Containers Using the AWS Developer Tool...Set Up a CI/CD Pipeline for Deploying Containers Using the AWS Developer Tool...
Set Up a CI/CD Pipeline for Deploying Containers Using the AWS Developer Tool...Amazon Web Services
 
Introduction to CI/CD
Introduction to CI/CDIntroduction to CI/CD
Introduction to CI/CDHoang Le
 
Cilium - overview and recent updates
Cilium - overview and recent updatesCilium - overview and recent updates
Cilium - overview and recent updatesMichal Rostecki
 
Testing Strategy in Micro Frontend architecture
Testing Strategy in Micro Frontend architectureTesting Strategy in Micro Frontend architecture
Testing Strategy in Micro Frontend architecturevodQA
 
Getting Started with Kubernetes
Getting Started with Kubernetes Getting Started with Kubernetes
Getting Started with Kubernetes VMware Tanzu
 
Cloud native principles
Cloud native principlesCloud native principles
Cloud native principlesDiego Pacheco
 
Rtf externalize tls MuleSoft meetup
Rtf externalize tls MuleSoft meetupRtf externalize tls MuleSoft meetup
Rtf externalize tls MuleSoft meetupSandeep Deshmukh
 
Let's talk about Failures with Kubernetes - Hamburg Meetup
Let's talk about Failures with Kubernetes - Hamburg MeetupLet's talk about Failures with Kubernetes - Hamburg Meetup
Let's talk about Failures with Kubernetes - Hamburg MeetupHenning Jacobs
 
CI/CD (DevOps) 101
CI/CD (DevOps) 101CI/CD (DevOps) 101
CI/CD (DevOps) 101Hazzim Anaya
 
Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Amazon Web Services
 

What's hot (20)

Comparing Next-Generation Container Image Building Tools
 Comparing Next-Generation Container Image Building Tools Comparing Next-Generation Container Image Building Tools
Comparing Next-Generation Container Image Building Tools
 
Developer Experience at Zalando - Handelsblatt Strategisches IT-Management 2019
Developer Experience at Zalando - Handelsblatt Strategisches IT-Management 2019Developer Experience at Zalando - Handelsblatt Strategisches IT-Management 2019
Developer Experience at Zalando - Handelsblatt Strategisches IT-Management 2019
 
Modern CI/CD Pipeline Using Azure DevOps
Modern CI/CD Pipeline Using Azure DevOpsModern CI/CD Pipeline Using Azure DevOps
Modern CI/CD Pipeline Using Azure DevOps
 
devops
devops devops
devops
 
Kubernetes deployment strategies - CNCF Webinar
Kubernetes deployment strategies - CNCF WebinarKubernetes deployment strategies - CNCF Webinar
Kubernetes deployment strategies - CNCF Webinar
 
"DevOps > CI+CD "
"DevOps > CI+CD ""DevOps > CI+CD "
"DevOps > CI+CD "
 
DevOps 101 - an Introduction to DevOps
DevOps 101  - an Introduction to DevOpsDevOps 101  - an Introduction to DevOps
DevOps 101 - an Introduction to DevOps
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
컨테이너 와 가상화 기술 비교 발표 자료
컨테이너 와 가상화 기술 비교 발표 자료컨테이너 와 가상화 기술 비교 발표 자료
컨테이너 와 가상화 기술 비교 발표 자료
 
IaC.pptx
IaC.pptxIaC.pptx
IaC.pptx
 
Set Up a CI/CD Pipeline for Deploying Containers Using the AWS Developer Tool...
Set Up a CI/CD Pipeline for Deploying Containers Using the AWS Developer Tool...Set Up a CI/CD Pipeline for Deploying Containers Using the AWS Developer Tool...
Set Up a CI/CD Pipeline for Deploying Containers Using the AWS Developer Tool...
 
Introduction to CI/CD
Introduction to CI/CDIntroduction to CI/CD
Introduction to CI/CD
 
Cilium - overview and recent updates
Cilium - overview and recent updatesCilium - overview and recent updates
Cilium - overview and recent updates
 
Testing Strategy in Micro Frontend architecture
Testing Strategy in Micro Frontend architectureTesting Strategy in Micro Frontend architecture
Testing Strategy in Micro Frontend architecture
 
Getting Started with Kubernetes
Getting Started with Kubernetes Getting Started with Kubernetes
Getting Started with Kubernetes
 
Cloud native principles
Cloud native principlesCloud native principles
Cloud native principles
 
Rtf externalize tls MuleSoft meetup
Rtf externalize tls MuleSoft meetupRtf externalize tls MuleSoft meetup
Rtf externalize tls MuleSoft meetup
 
Let's talk about Failures with Kubernetes - Hamburg Meetup
Let's talk about Failures with Kubernetes - Hamburg MeetupLet's talk about Failures with Kubernetes - Hamburg Meetup
Let's talk about Failures with Kubernetes - Hamburg Meetup
 
CI/CD (DevOps) 101
CI/CD (DevOps) 101CI/CD (DevOps) 101
CI/CD (DevOps) 101
 
Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration
 

Similar to Intro to elixir and phoenix

Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threadsmperham
 
Repeating History...On Purpose...with Elixir
Repeating History...On Purpose...with ElixirRepeating History...On Purpose...with Elixir
Repeating History...On Purpose...with ElixirBarry Jones
 
C# Async/Await Explained
C# Async/Await ExplainedC# Async/Await Explained
C# Async/Await ExplainedJeremy Likness
 
Concurrency & Parallel Programming
Concurrency & Parallel ProgrammingConcurrency & Parallel Programming
Concurrency & Parallel ProgrammingRamazan AYYILDIZ
 
VoltDB and Erlang - Tech planet 2012
VoltDB and Erlang - Tech planet 2012VoltDB and Erlang - Tech planet 2012
VoltDB and Erlang - Tech planet 2012Eonblast
 
Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"Paolo Negri
 
Erlang, the big switch in social games
Erlang, the big switch in social gamesErlang, the big switch in social games
Erlang, the big switch in social gamesWooga
 
The Economies of Scaling Software
The Economies of Scaling SoftwareThe Economies of Scaling Software
The Economies of Scaling SoftwareAbdelmonaim Remani
 
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
 
The economies of scaling software - Abdel Remani
The economies of scaling software - Abdel RemaniThe economies of scaling software - Abdel Remani
The economies of scaling software - Abdel Remanijaxconf
 

Similar to Intro to elixir and phoenix (20)

Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threads
 
Elixir
ElixirElixir
Elixir
 
Scalable game-servers-tgc
Scalable game-servers-tgcScalable game-servers-tgc
Scalable game-servers-tgc
 
Repeating History...On Purpose...with Elixir
Repeating History...On Purpose...with ElixirRepeating History...On Purpose...with Elixir
Repeating History...On Purpose...with Elixir
 
C# Async/Await Explained
C# Async/Await ExplainedC# Async/Await Explained
C# Async/Await Explained
 
Scaling tappsi
Scaling tappsiScaling tappsi
Scaling tappsi
 
From Ruby to Elixir
From Ruby to ElixirFrom Ruby to Elixir
From Ruby to Elixir
 
Concurrency & Parallel Programming
Concurrency & Parallel ProgrammingConcurrency & Parallel Programming
Concurrency & Parallel Programming
 
VoltDB and Erlang - Tech planet 2012
VoltDB and Erlang - Tech planet 2012VoltDB and Erlang - Tech planet 2012
VoltDB and Erlang - Tech planet 2012
 
Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"
 
Erlang, the big switch in social games
Erlang, the big switch in social gamesErlang, the big switch in social games
Erlang, the big switch in social games
 
Scheduling Thread
Scheduling  ThreadScheduling  Thread
Scheduling Thread
 
The Economies of Scaling Software
The Economies of Scaling SoftwareThe Economies of Scaling Software
The Economies of Scaling Software
 
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
 
The economies of scaling software - Abdel Remani
The economies of scaling software - Abdel RemaniThe economies of scaling software - Abdel Remani
The economies of scaling software - Abdel Remani
 
Erlang/Elixir and OTP
Erlang/Elixir and OTPErlang/Elixir and OTP
Erlang/Elixir and OTP
 

Recently uploaded

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 

Intro to elixir and phoenix

  • 1. Elixir & Phoenix Functional |> Concurrent |> Pragmatic |> Fun
  • 2. Who am I? • Jared Smith • Software Engineer at One Month • @sublimecoder • www.sublimecoding.com
  • 4. First lets talk about Erlang • Elixir runs on the Erlang VM • Many of the standard lib function calls in Elixir call Erlang functions directly. • Elixir piggy backs on the Erlang ecosystem
  • 5. Why Erlang VM? • 30 year old battle tested VM • Highly available, fault tolerant, and distributed
  • 6. History of Erlang • Developed by Ericsson • Used and developed for Telecommunications • In fact its standard library is the OTP (Open Telecom Platform)
  • 7. Telecommunications • High availability is king • Remote Telecom switches need to run for years sometimes with out being disturbed
  • 8. Built with Erlang • 50 person engineering team • managing 900 million users. • Up to 2 million active users per server. https://blog.whatsapp.com/196/1-million-is-so-2011
  • 9. 2 Million Active Users? • Intel Xeon CPU x5675 @ 3.07GHz
 24 Cores - 96GB Ram • Using only 40% of the CPU/Memory https://blog.whatsapp.com/196/1-million-is-so-2011
  • 10. So Erlang is pretty awesome • Wouldn’t it be nice if we could harness this power? • Why isn’t everyone using Erlang?
  • 11. Elixir • Elixir utilizes much of the power of Erlang • While giving us a much nicer syntax and api to work with.
  • 12. History of Elixir • Created by Josè Valím - (Joe-zay Val-eem) • First released in 2012
  • 13. Elixir’s Strengths • Concurrency • Meta-programming Capability • Transformation of data as a core ideal
  • 14. Plus it has Ruby like syntax
  • 15. Pipe Operator • The following code is valid elixir. • With the pipe operator we can write our code this way instead. Keeping us out of nested function hell.
  • 16. Pattern Matching • Pattern matching is a core part of Erlang and Elixir
  • 17. What is Pattern Matching? • Make left side look like the right side • a = 99 • [a,b,c] = [1,2,3] • [head | tail] = [1,2,3]
  • 18. Immutability • Once you set a value 
 it can never change.
  • 20. 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?
  • 21. Why is Immutability a good thing? • Immutability provides a contract that each piece of information has one source of truth. • Concurrency is a natural side effect of immutability.
  • 22. 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 this luxury.
  • 23. 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.
  • 24. Isn’t this inefficient? • At first glance it would seem that way, but the opposite is true. • Won’t all the old reference values balloon elixirs memory? • Yes this means you could have thousands of unused variables floating in memory
  • 26. Concurrency fixes everything • 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.
  • 27. Concurrency • 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.
  • 28.
  • 30. Phoenix Framework • Created by Chris McCord • Release 1.0 August 28th 2015
  • 31.
  • 32. Phoenix Framework • It’s not rails for Elixir • It has been influence heavily by rails as well as many other frameworks. • Focus on API and web sockets
  • 33. Speed • Web request response time is often measured in micro seconds and not milliseconds.
  • 34. Benchmarks • Recently benchmarked 2 million+ web socket connections • With 2 - 3 second broadcast times to all 2 million connections
  • 38. Easy Startup • mix phoenix.new ./app/path/my_app • mix ecto.create && mix ecto.migrate • mix phoenix.server
  • 41. Mix • Mix is essentially bundler and rake combined • Additionally mix is your test runner. • It’s included with Elixir
  • 42. 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
  • 43. Concurrency • Async processing with out the need for DelayedJob or Resque/sidekiq • We can write code that looks like this.
  • 44. Isolated & Concurrent • Crashes are isolated • Data is isolated 
 (GC is per process, no global pauses) • Load Balances on IO and CPU - Efficient on a multicore
  • 45. Garbage Collection • 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
  • 46. Request Pipeline • Just a series of function calls that transform data. • connection 
 |> endpoint
 |> router
 |> pipelines
 |> controller
  • 47. Request Pipeline • Phoenix makes it easy to add middleware or plugs to this pipeline. We could easily add authentication to this. • connection 
 |> endpoint
 |> router
 |> pipelines
 |> authenticate_user
 |> controller
  • 48. Explicitness Over Magic • Phoenix Removes a lot of the confusion and “magic” found in rails and replaces it with explicit calls. • Models, Controllers and Views are singular named by convention.
  • 56. Learn More • Elixir-Lang on Slack 
 https://elixir-slackin.herokuapp.com/ • #elixir-lang on Freenode IRC • http://www.phoenixframework.org • http://elixir-lang.org/ • https://github.com/h4cc/awesome-elixir