
Mastering Elixir
Build and scale concurrent, distributed, and fault-tolerant applications
- 574 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Mastering Elixir
Build and scale concurrent, distributed, and fault-tolerant applications
About this book
Leverage the power of Elixir programming language to solve practical problems associated with scalability, concurrency, fault tolerance, and high availability.
Key Features
- Enhance your Elixir programming skills using its powerful tools and abstractions
- Discover how to develop a full-fledged file server
- Understand how to use Phoenix to create a web interface for your application.
Book Description
Running concurrent, fault-tolerant applications that scale is a very demanding responsibility. After learning the abstractions that Elixir gives us, developers are able to build such applications with inconceivable low effort. There is a big gap between playing around with Elixir and running it in production, serving live requests. This book will help you fll this gap by going into detail on several aspects of how Elixir works and showing concrete examples of how to apply the concepts learned to a fully fledged application. In this book, you will learn how to build a rock-solid application, beginning by using Mix to create a new project. Then you will learn how the use of Erlang's OTP, along with the Elixir abstractions that run on top of it (such as GenServer and GenStage), that allow you to build applications that are easy to parallelize and distribute. You will also master supervisors (and supervision trees), and comprehend how they are the basis for building fault-tolerant applications. Then you will use Phoenix to create a web interface for your application. Upon fnishing implementation, you will learn how to take your application to the cloud, using Kubernetes to automatically deploy, scale, and manage it. Last, but not least, you will keep your peace of mind by learning how to thoroughly test and then monitor your application.
What you will learn
- Use Elixir tools, including IEx and Mix
- Find out how an Elixir project is structured and how to create umbrella applications
- Discover the power of supervision trees, the basis for fault-tolerance
- Create a Domain-Specifc Language (DSL) that abstracts complexity
- Create a blazing-fast web interface for your application with Phoenix
- Set up an automatic deployment process for the cloud
- Monitor your application and be warned if anything unexpected happens
Who this book is for
Mastering Elixir is for you if you have experience in Elixir programming and want to take it to the next level. This Elixir book shows you how to build, deploy, and maintain robust applications, allowing you to go from tinkering with Elixir on side projects to using it in a live environment. However, no prior knowledge of Elixir is required to enjoy the complex topics covered in the book.
Tools to learn more effectively

Saving Books

Keyword Search

Annotating Text

Listen to it instead
Information
Metaprogramming – Code That Writes Itself
- What is an abstract syntax tree and how to access it?
- Using the special forms quote/2 and unquote/1
- Macro hygiene and the caller and macro contexts
- Applying use and its __using__/1 function
- Using module attributes to collect information about the caller module
- Creating a domain-specific language with macros
The abstract syntax tree
iex> quote do: :"Funky.Atom"
:"Funky.Atom"
iex> quote do: ["a", "b", "c", "z"]
["a", "b", "c", "z"]
iex> quote do: 1.88
1.88
iex> quote do: "really big string but still simple"
"really big string but still simple"
iex> {:elixir, :rocks} == quote do: {:elixir, :rocks}
true
iex> quoted_case = quote do
...> case 1 == 2 do
...> true -> "it seems 1 == 2 is true"
...> _ -> IO.puts "1 == 2 isn't true after all"
...> end
...> end
{:case, [],
[
{:==, [context: Elixir, import: Kernel], [1, 2]},
[
do: [
{:->, [], [[true], "it seems 1 == 2 is true"]},
{:->, [],
[
[{:_, [], Elixir}],
{{:., [], [{:__aliases__, [alias: false], [:IO]}, :puts]}, [],
["1 == 2 isn't true after all"]}
]}
]
]
]}
iex> Code.eval_quoted quoted_case
1 == 2 isn't true after all
{:ok, []}
iex> quoted_case_with_vars = quote do
...> case x == 2 do
...> true -> "it seems x == 2"
...> _ -> IO.puts "x == 2 isn't true after all"
...> end
...> end
{:case, [],
[
{:==, [context: Elixir, import: Kernel], [{:x, [], Elixir}, 2]},
[
do: [
{:->, [], [[true], "it seems x == 2"]},
{:->, [],
[
[{:_, [], Elixir}],
{{:., [], [{:__aliases__, [alias: false], [:IO]}, :puts]}, [],
["x == 2 isn't true after all"]}
]}
]
]
]}
iex> Code.eval_quoted quoted_case_with_vars, [x: 3]
warning: variable "x" does not exist and is being expanded to "x()", please use parentheses to remove the ambiguity or change the variable name
nofile:1
** (CompileError) nofile:1: undefined function x/0
(stdlib) lists.erl:1354: :lists.mapfoldl/3
iex> quoted_case_with_external_vars = quote do
...> case var!(x) == 2 do
...> true -> "it seems x == 2"
...> _ -> IO.puts "x == 2 isn't true after all"
...> end
...> end
{:case, [],
[
{:==, [context: Elixir, import: Kernel],
[{:var!, [context: Elixir, import: Kernel], [{:x, [], Elixir}]}, 2]},
[
do: [
{:->, [], [[true], "it seems x == 2"]},
{:->, [],
[
[{:_, [], Elixir}],
{{:., [], [{:__aliases__, [alias: false], [:IO]}, :puts]}, [],
["x == 2 isn't true after all"]}
]}
]
]
]}
iex> Code.eval_quoted quoted_case_with_external_vars, [x: 2]
{"it seems x == 2", [x: 2]}
Table of contents
- Title Page
- Copyright and Credits
- Dedication
- Packt Upsell
- Contributors
- Preface
- Preparing for the Journey Ahead
- Innards of an Elixir Project
- Processes – The Bedrock of Concurrency and Fault Tolerance
- Powered by Erlang/OTP
- Demand-Driven Processing
- Metaprogramming – Code That Writes Itself
- Persisting Data Using Ecto
- Phoenix – A Flying Web Framework
- Finding Zen through Testing
- Deploying to the Cloud
- Keeping an Eye on Your Processes
- Other Books You May Enjoy
Frequently asked questions
- Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
- Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app