3. TODAY’S WEB:
Hundreds of millions of interconnected services
continuously exchanging data.
Reliability, concurrency, fault-tolerance, scalability,
all expected as the norm.
5. ABOUT ME:
▸ Chi-chi Ekweozor (@thisischichi):
▸ Contract Software engineer - C/C++, PHP, JavaScript,
and now Elixir
▸ Previously a social media marketing consultant!
▸ Combined social media know how with Elixir/Phoenix to
create Assenty, a real-time Question & Answer tool for
event organisers.
6. INTENDED AUDIENCE:
This talk is intended for web developers with some
familiarity with functional programming concepts.
It is a high level overview of the Phoenix web
framework which is written in Elixir, a relatively new
functional programming language.
No prior experience with Elixir is required.
7. WE’LL COVER:
▸ Why Elixir?
▸ What is Phoenix?
▸ What are Phoenix Channels?
▸ How do they work?
▸ Assenty Live Demo: Phoenix Channels in Production
16. WHY ELIXIR?
▸ An extensible and well-documented dynamic language
with Ruby-inspired syntax, undergirded by Erlang’s 30 year
old, tried and tested virtual machine known as BEAM
▸ In-built pattern matching and the pipe operator |> makes it
easy to work with and reason about immutable data
▸ Mix: an impressive tooling ecosystem that adds rock solid
libraries for authentication, metrics, crypto, embedded
systems support and much more
24. AT LEAST TWO THINGS YOU STAND TO GAIN WITH ELIXIR:
▸ Because of data immutability, concurrency is a lot easier to
understand, and use:
▸ Your application or program will use all available cores
on your machine to function. It just does.
▸ A single function definition lets you define different
implementations depending on its arguments:
▸ Your application or program will be easier to modularise
and test.
25. WE’LL COVER:
▸ Why Elixir?
▸ What is Phoenix?
▸ What are Phoenix Channels?
▸ How do they work?
▸ Assenty Live Demo: Phoenix Channels in Production
27. INTRODUCING PHOENIX:
▸ Phoenix is a web development framework written in Elixir
which implements the server-side MVC pattern.
▸ Many of its components and concepts will seem familiar to
those of us with experience in other web frameworks like
Ruby on Rails or Python's Django.
▸ Phoenix is made up of a number of distinct parts, each
with its own purpose and role to play in building a web
application.
Excerpted from the Phoenix Framework Guides
44. WE’LL COVER:
▸ Why Elixir?
▸ What is Phoenix?
▸ What are Phoenix Channels?
▸ How do they work?
▸ Assenty Live Demo: Phoenix Channels in Production
45.
46. WHAT ARE PHOENIX CHANNELS?
▸ Channels are a really exciting and powerful part of
Phoenix that allow us to easily add soft real-time features
to our applications.
▸ Channels are based on a simple idea - sending and
receiving messages. Senders broadcast messages about
topics.
▸ Receivers subscribe to topics so that they can get those
messages. Senders and receivers can switch roles on the
same topic at any time.
Excerpted from the Phoenix Framework Guides
47. CHARACTERISTICS OF SOFT REAL-TIME SYSTEMS:
▸ You don’t have to hit every deadline, as opposed to the
case in hard real-time systems.
▸ Performance will degrade if too many are missed but
results are still valid after the deadline.
▸ Examples: airline reservation systems.
▸ Contrast with hard real-time systems where you must
absolutely hit every deadline. Examples: nuclear systems,
aircraft control systems, defence applications.
57. WHAT PHOENIX CHANNELS MAKE POSSIBLE:
▸ With Channels, neither senders nor receivers have to be
Elixir processes.
▸ They can be anything that we can teach to communicate
over a Channel - a JavaScript client, an iOS app, another
Phoenix application, our watch.
▸ Whereas request/response interactions are stateless,
conversations in a long-running process can be stateful.
Excerpted from the Phoenix Framework Guides
58. WE’LL COVER:
▸ Why Elixir?
▸ What is Phoenix?
▸ What are Phoenix channels?
▸ How do they work?
▸ Assenty Live Demo: Phoenix Channels in Production
61. HOW DO PHOENIX CHANNELS WORK?
▸ A Phoenix channel is a conversation.
▸ The channel sends messages, receives messages, and
keeps state. We call the messages events.
▸ A Phoenix conversation is about a topic, and it maps onto
application concepts like a chat room, a game, or in
Assenty's case, the question board for an event.
Excerpted from Programming Phoenix by Chris McCord, Bruce Tate, and José Valim
62. BENEFIT OF USING PHOENIX CHANNELS:
▸ For sophisticated user interactions like interactive pages or
multiplayer games, you don’t have to work so hard to keep
track of the conversation by using cookies, databases, or
the like.
▸ Each call to a channel simply picks up where the last one
left off.
▸ A client establishes a new connection with a web socket.
That socket is transformed through the life of the
conversation with the server.
Excerpted from Programming Phoenix by Chris McCord, Bruce Tate, and José Valim
86. THIS JAVASCRIPT OBJECT ADDS REAL-TIME
FUNCTIONALITY TO YOUR APPLICATION BY
LISTENING FOR EVENTS GENERATED BY THE
CALLBACKS (JOIN(), HANDLE_* ETC) DEFINED
IN ELIXIR AND RESPONDING APPROPRIATELY.
87. WE’LL COVER:
▸ Why Elixir?
▸ What is Phoenix?
▸ What are Phoenix channels?
▸ How do they work?
▸ Assenty Live Demo: Phoenix Channels in Production
88. WHAT IS ASSENTY?
▸ Assenty is a real-time question and answer tool for event
organisers.
▸ Written in Elixir, and running on the Phoenix framework, it
provides a platform for capturing and persisting questions
posted to an event’s ‘question board’
▸ A question board is an online archive of questions and answers
discussed at a physical or virtual event.
▸ As each question and answer submitted to a question board is
persisted to the database, it is easily shared via social media.
89. PHOENIX CHANNELS LIVE DEMO:
▸ Visit the Question Board created during the live demo
▸ Thank you to all the participants!