Elixir and Phoenix
Elixir is an open-source, functional, dynamic language with a strong emphasis on concurrency and fault tolerance. It runs on BEAM, Erlang’s virtual machine, so it takes full advantage of Erlang and OTP’s fully tested ecosystem. If you think these properties are key for your new project, then Elixir may be just what you’re looking for.
Elixir was built with concurrency in mind. Its basic units of execution (called processes, but they are actually different from native OS processes) are easy to spawn and very inexpensive to keep, so it's common to have thousands of processes running at the same time.
Elixir provides a special type of process called Supervisor, whose only responsibility is to monitor other processes so that in the event of failure they can be restarted to an initial state. Because our system consists of multiple processes, each with its own limited scope of work, a failure in one part won't necessarily affect the rest.
Put this together, and we have a system that won't be affected by a failure in one single module, and even if this module fails it will be automatically restarted to a fresh state. Sleep easy knowing that our system is up and working, and we’ll take a look at that issue in the morning ;)
Processes in Elixir are completely isolated and only communicate with each other via messages. This design, while limiting at first sight, actually allows a flexible scalability model. Despite sharing no resources of any kind, processes can run on the same virtual machine (Erlang’s), on different VMs on the same computer, and even on different computers. Using Elixir, we can provide solutions that natively support horizontal scaling across multiple nodes right from the start.
Hot Code Swapping
Erlang is one the few languages that natively supports hot code swapping. Since Elixir runs on the same virtual machine it enjoys the same benefit. This unique feature allows us to update specific sections of the code without stopping the system or even interrupting ongoing connections.
Phoenix - The Web Framework for Elixir
Phoenix is the most popular web framework for Elixir. It leverages the Erlang virtual machine to create full-featured web applications that follow the platform’s philosophy. It puts special focus on real time interaction with a concept called channels, which enables bidirectional communication between the clients and the server.
Is Elixir the Right Choice for your project?
If you are thinking of a highly distributed system, low latency, high availability or other similar characteristics as critical for your new project, we suggest Elixir as it can definitely provide an advantage over other platforms. If that’s not the case, but you still think your project would benefit from Elixir’s distinctive features, drop us a line. Elixir is a general purpose language with a wide range of applications.