When Postlight was given the opportunity to revamp the Esports platform for a popular video game, the inevitable question arose: Which tech stack should we use? Knowing the platform would need to be scalable and resilient, particularly during high-traffic tournament days, and allow for live score updates, we decided to use Elixir, the functional programming language that celebrated its 10th anniversary in 2022. We’d like to share our experiences, both positive and negative (though mostly positive!), with our chosen technologies of Elixir and Phoenix LiveView.
Why Elixir?
As we’ve pointed out before, Elixir is gaining in popularity with those who want to build fast and stable systems. As a direct descendent of Erlang, a language developed by Ericsson employees for a telecom platform that required high stability and fault tolerance, Elixir would allow us to handle scaling up the number of concurrent processes running during tournaments without issue.
Our chosen stack.
When it comes to choosing a frontend framework to pair with Elixir, there are definitely options. Postlight engineers are well versed in React, and while it is entirely possible to build a product with an Elixir backend and a React frontend, we instead opted to use the Phoenix framework, including LiveView — after all, it is the web platform for Elixir. LiveView was especially compelling, as it enables creating a server-rendered web application that ships only diffs in the HTML over a WebSocket connection, allowing for fast and seamless updates to the UI. This feature, along with Phoenix’s built-in PubSub functionality, were key to our ability to update game scores in real time across an unknown number of connections.
So did we make the right choice? The answer is an unequivocal yes. The engineers on the project loved working with Elixir and LiveView, and quickly saw the benefits of working with this fast, developer-focused language.
There is a reason Elixir was the second most loved language in the 2022 Stack Overflow Developer Survey. Quite simply, it’s a joy to work with. The Mix build toolmakes creating and managing projects and their dependencies extremely easy. Personally, I found Elixir’s interactive shell, IEx, to be one of the coolest features of the language. The IEx shell is so useful for debugging your code and exploring features of Elixir without having to write full programs to test things out.
One of the greatest benefits of working in Elixir is its vibrant engineering community. People who work in Elixir are passionate about the language and want to do everything they can to bring more developers into the fold. I’ve never been part of a technology-based Slack community that was so positive, supportive, and helpful. And the community-driven Elixir Forumserves as a tremendous resource for those just learning the language or for more experienced engineers seeking help with a difficult problem.
While many languages have convenient third-party package managers that allow easy installation of libraries, we found Hex to be especially great to use. The consistency of documentation among the packages made it extremely smooth to peruse the docs for any of the libraries we chose to install for our Esports platform.
Perhaps we were just lucky, but we also found that the quality control of the Hex packages was extremely high and that package creators were responsive beyond any reasonable expectation. When we chose to implement a Command Query Responsibility Segregation (CQRS) pattern, we relied heavily on the Commanded packageand were thankful for the personalized consultation and advice we received from the package creator. Similarly, when we reported a small bug in Oban, the library we used to schedule background jobs, theOban creator immediately responded to our inquiry on the #oban channel in the Elixir Slack workspace and had the bug fix coded and deployed within a couple of days!
Some challenges
While we remain very confident in our choice of Elixir and LiveView for building out this platform, there were challenges we ran into along the way that are worth calling out.
Initially we had made the decision to use Surface UI — a component library specifically built to use with Phoenix and LiveView that provides the ability to create components in a more React-like way. However, as LiveView is continuously being enhanced and expanded, the utilities of Surface seemed less and less necessary and added a little technical bloat to the stack. Engineers needed to understand yet another syntax and needed to refer to an additional set of documentation. Don’t get me wrong, Surface is slick. But I think we all agreed that if the current features of LiveView had been around when we first started the project, we probably would have skipped over using Surface entirely. (Here’s looking at you, declarative assigns, slots, and JS commands.)
Another challenge was not Elixir-specific and would have been an issue with any newer tech stack we chose. Since only a couple of the engineers on the Esports project had any prior experience with Elixir, most of the team (including myself) needed a crash course in learning the new tech stack. Additionally, for some, it was their first time developing in a functional programming language.
Our Engineer Onboarding Guide for this Esports project.
While there is always a little ramp-up time when onboarding to a new project, adding a new tech stack to the mix did slow down initial engineer productivity, although everyone’s technical introduction to the project was aided by an excellent Engineer Onboarding Guide created by one of our lead engineers. However, I firmly believe that a slow ramp-up was more than made up for by the excellent developer experience provided by Elixir and LiveView, described above, once the engineers on the team became more comfortable with the technologies.
The magic potion?
When a team has the privilege of working on a greenfield project, it can be intimidating to choose the appropriate tech stack that meets all of the project’s requirements and also delivers an enjoyable engineering experience. For the engineering team at Postlight, and the requirements of the Esports platform we were tasked with building, Elixir was absolutely the right choice.
Most important, it worked! The combination of Elixir, Phoenix PubSub, and LiveView allowed for some really cool live scoring updates that were thrilling to see, for both the engineers on the project and our clients. But in addition to meeting the basic needs of being able to create a working Esports tournament platform, Elixir also provided at least one Postlight engineer with the most gratifying programming experience of her career.