An Overview of Phoenix
Discover the history behind Phoenix to increase your understanding of real-time applications.
Introduction
The course is about building real-time applications that run quickly with less resource overhead. Today’s software users expect the data on their screens to reflect instantly. To win our users’ trust, we must give them a seamless application experience powered by real-time features.
Building systems that provide this real-time data flow and feedback is a challenging endeavor that often involves trade-offs between application development, maintenance, or runtime. These trade-offs can now be reduced due to modern advances in real-time application development. This means that developing a real-time application is now in the hands of everyday developers—like us.
Real-time systems are all about getting data from the server to the user, or vice versa, as efficiently as possible. A critical piece of a real-time system is the communication layer between the server and the user. The user may be on a browser, a mobile application, or even another server. This means we want to pick a communication layer that can work well in various circumstances, from high-latency mobile connections to high-speed internet connections.
Structure of the course
There are three parts of this course; they build upon each other to teach us about WebSockets, Phoenix Channels, and real-time applications.
Part I
This part will focus on the essential part of the real-time stack in:
- Elixir Phoenix channels
- WebSockets
- GenStage
We’ll cover a lot of ground in these lessons and gain the foundations necessary to build real-time applications.
Part II
We’ll leverage the foundations from Part I when we work on a real-time application in Part II. We’ll add real-time features to an e-commerce application that serves many users simultaneously. Then, we’ll also get to work with some of the more advanced features of Phoenix, such as Phoenix Tracker.
Part III
Part III will finish the course with guidance on running real-time applications in production. Our task only begins when we write an application. We have to then keep our application healthy and happy in production.
Prerequisites
Knowledge of the following technologies is required in this course. If you are not familiar with them, we strongly recommend you to learn about them before diving into the course:
- Elixir
- Erlang
- Phoenix
The installation instructions of the above components can be found in the Appendix section.
The case for real-time systems
Users expect applications to reflect the correct state of the world.
Imagine an online shopping cart for a fashion store. You browse around and finally find the perfect item, but there are only a few left in your size. You then manage to successfully navigate through the checkout process and enter payment information. Just as you check out, you get a message: your item is sold out! Your expectations of an easy checkout experience are dashed. You’re understandably frustrated that you went through a long process only to not be able to buy the item you want.
Definition of real-time
Real-time features are a way to ensure that what users know to be true is reflected in their view of an application, thus improving its usability and minimizing frustration.
It’s often not enough to reflect what was true when a page was loaded. In the case of the above e-commerce application, the item could have been in stock when the checkout page loaded, and then became out-of-stock while you entered your billing information. So, applications need to reflect the most up-to-date information without requiring a user to take action.
Example
A chat application will insert new chats in a window without a user needing to press a “Fetch New Chats” button. The real-time aspect of a chat system allows it to be valuable and enjoyable for people who use it.