January 20, 2020
Elixir is a functional and dynamic programming language first released in 2011, so it’s still relatively new.
Since then, it’s been gaining popularity because it’s highly scalable, reliable, and great for microservices and cloud computing. Let’s look at a handful of major-league companies that decided to introduce Elixir into their architecture and see what they gained from the change.
Elixir is based on Erlang VM, a 20-year-old virtual machine built to support robust, concurrent, and distributed software. Together with its Phoenix framework, you can use Elixir in virtually any industry and for any application. Recently, it’s been gaining popularity as an enterprise-level software in:
The language is perfect for projects that need to support concurrency and low latency, handle a lot of traffic, and scale easily. Actually, in the foreword to “Programming Elixir ≥ 1.6: Functional |> Concurrent |> Pragmatic |> Fun”, a recent book by Dave Thomas, the creator of the language, José Valim, describes concurrency as the backbone of Elixir, adding that its biggest value is “freeing programmers from antiquated concurrency mechanisms.”
The benefits of Elixir also include high fault tolerance, reliability, and a tidy, modern syntax. It’s proven itself useful for distributed systems like Blockchain projects, embedded systems, as well as real-time apps using instant messaging, video chats, or financial apps.
Furthermore, there are multiple additional architectures, services, and frameworks that build upon Elixir. Some examples include:
Thinking of making the switch yourself? Take a look at just a few of the most prominent examples of highly successful companies that have employed Elixir in their major projects in recent months—and the results they managed to achieve with it.
Ruby or Elixir?
Not sure if you should choose Elixir or Ruby for scaling or building software?
Pinterest is one of the biggest online companies to have successfully used Elixir. In Q3 of 2018, the service had 250 million active users pinning 175 billion items to their boards. Their speedy growth might have had something to do with their conversion to Elixir in 2014. The new programming language helped them speed up the performance of their notification system delivering 14,000 notifications per second and cut down the number of servers by half—from 30 to just 15—compared to when the service relied on Java.
Using Elixir also allowed Pinterest to clean up their code, slimming it down to around 1,000 lines—a tenfold reduction. Pinterest now also uses Elixir to route more than 30,000 events per second to its in-house rule engine for spam prevention.
In 2016, Moz Pro, the leading SEO tool and online platform helping companies analyze and improve their search engine performance, decided to do an overhaul of their backend architecture. Their goals were to:
They explained the process and the results on their developer blog. The main problem they had to solve was the fact that they’ve outgrown their database infrastructure. As a result, the architecture didn’t scale well and stopped performing properly when flooded with large sets of data, which was absolutely key for a growing SEO analytics tool.
The architecture limited the depth and flexibility of the data that was to be presented in a variety of ways. The problems they identified included non-scalability, non-standard use of MySQL, and concurrency limitations in Ruby.
Switching to Elixir, they were able to use smaller data files and, as a result, use 63 times less disk space, on average, than when using MySQL rankings tables. They were also able to improve the speed of their API by 20 times compared to the previous API, with average response times consistently below 50 ms (compared to 800+ ms). All in all, the simple deployment resulted in 30 times faster build speeds.
Lonely Planet is a worldwide travel site (and a traditional travel guide publisher) serving millions of unique visitors each month. It publishes a lot of rich content using their website, mobile app, and third-party services. The problem was that their Web content was stuck behind Ruby on Rails applications, Wordpress instances, and various other data stores.
What they needed was to be able to serve it to Web and mobile apps quicker and at scale. This called for a different data model, a cleaner API, and a much more scalable infrastructure.
After several failed attempts, the company hired a development team that created several microservices, some of them written in Elixir. One was an Elixir microserver with an API sub-service using the Phoenix Web framework, designed to serve available lodgings from booking.com and HostelWorld. Another microservice written in Elixir serves their inventory of books and ebooks from a custom ecommerce system backed by a Microsoft SQL server.
According to the architects of the new solution, they were able to put a robust architecture in place using Elixir, with much higher performance and lower memory requirements.
The Financial Times is a respected news publication established in 1888. Alongside their traditional daily newspaper, they also run a huge online service that just announced a million paying readers last April. They previously used a micro-service REST APIs, but to deal with the growing online readership and improve the performance of the service, they turned to a GrapQL API based on Elixir.
Now, they also have another Elixir-based app and enjoy much smaller memory usage compared to Java. According to the now former senior software developer at Financial Times, Ellis Pritchard, Elixir was easy to learn for the development team—another advantage of the language.
Toyota has just launched its first global car sharing platform. The service uses Toyota’s proprietary global Mobility Service Platform (MSPF) and a consumer-facing app.
Toyota Connected uses Elixir as part of the backend system that makes up the Mobility Service Platform. It provides an API for mobile and Web applications and handles the geo-processing, e.g. verifying whether a vehicle is inside or outside a geofence.
The company’s plans are to have the majority of its new vehicles sold in North America and Japan sending information to their cloud by 2020. They’re planning to analyze traffic patterns and driver behavior, connect drivers with infrastructure, and create new services and products.
To learn more about how Toyota Connected uses Elixir, watch the talk their developer Powell Kinney gave at Code Elixir LDN conference in 2018, where he explains designing for longevity using Elixir and Erlang/OTP.
Bleacher Report, a division of Turner Sports, is the second largest sports website in the world. They get up to 1.5 billion page views a month and send out more than 3 billion push notifications.
Ruby on Rails was originally used to create the service, but the growing traffic eventually demonstrated that the service was no longer scalable. Another huge challenge involved supporting concurrent streaming in their Team Stream app. Given the real-time, mobile-first approach the company boasts, they needed to be able to handle huge spikes in traffic at peak times on mobile devices.
Their development team tried out various options, including Node.js and Go, before finally deciding on Elixir—it brought significant improvements in performance, while its syntax was similar to Ruby’s, which made it easy to learn.
This is how lead engineer Ben Marx summarized the benefits of the switch:
Elixir has proven so efficient that testing the limits of our services became a challenge unto itself, requiring investment in new benchmarking tools and strategies. In a recent test, for example, our most heavily trafficked service was able to handle 8x our average traffic load, without autoscaling, before the database proved to be a bottleneck.
Other benefits of employing Elixir included:
In most of the cases mentioned above, the switch to Elixir (or the decision to build in Elixir right from the start) resulted in apps and services capable of handling much bigger traffic. That means they scale well, can grow without losing reliability, all the while improving overall performance. In business terms, that means more users, customers, and a higher ROI.