Hosting providers for Elixir and Phoenix applications

Hosting providers for Elixir and Phoenix applications

Learn all about the pros and cons of the major hosting providers to deploy Elixir and Phoenix applications. Let’s explore the best hosting solutions for Elixir.
Andy Duong
Andy Duong
December 24, 2020
Web

Table of Contents

For an Elixir app to get all the benefits of the advanced features of BEAM (the Erlang virtual machine), choosing the right hosting provider is an important step. There are several hosting solutions for Elixir. So which one is the best? Let’s explore.

TL;DR:

Heroku

Heroku is a great platform, and Elixir performs well on it. However, there are some limitations, as mentioned in the official Phoenix documentation. We will highlight the main ones below.

Connections are limited

It is common to use Elixir for real-time apps that need several concurrent and persistent connections. Phoenix is capable of handling over 2 million connections on a single server, but Heroku limits the number of simultaneous connections as well as the duration of each connection (maximum 50 concurrent requests per dyno).

Distributed clustering is not possible

Heroku dynos are isolated from one another. This means that advanced features such as distributed Phoenix channels and distributed tasks will need to rely on external services like Redis instead of Elixir’s built-in distributed capabilities.

In-memory state is reset every 24 hours

Agents, GenServers, and ETS make use of in-memory state. Unfortunately, Heroku restarts dynos every 24 hours regardless of whether the node is healthy or not.

The built-in Observer can’t be used with Heroku

Heroku allows to open a connection to the dyno via SSH, but it will not be possible to use the Erlang-based observer to monitor the state of your dyno.

So, in summary, when you are just getting started with Elixir, and you are in search of a quick deployment solution, or if the application does not require the usage of advanced features such as BEAM’s powerful distribution functionality and non-ephemeral state, then Heroku can be good enough.

Gigalixir

As described on the Gigalixir Docs:

A fully-featured, production-stable platform-as-a-service built just for Elixir that saves you money and unlocks the full power of Elixir and Phoenix without forcing you to build production infrastructure or deal with maintenance and operations.

Gigalixir supports multiple deployment strategies:

Gigalixir supports many of BEAM’s advanced features:

  • Distributed clustering.
  • Hot upgrades.
  • Remote observer over SHH (by using mix release observer).
  • Remote console over SSH (by using mix release remote).

Deployments are also triggered similarly to Heroku by a single command git push gigalixir master, so it is easy to use. It’s also simple to scale up both the application and database when in need of more resources.

Eventually, Gigalixir also provides some often-needed features out of the box:

  • SSL.
  • Custom domain.
  • Blue/Green deployment.

However, there are also some limitations:

  • Relative higher cost: $5 for each 0.1 GB of memory for the app instance or the database instance per month.
  • Security: databases are hosted on a public network. While each client obviously needs to have valid credentials to access a database, anyone can ping to a database.
  • Lack of support for additional services such as Redis or ElasticSearch.

As a conclusion, Gigalixir is an excellent choice to host an Elixir/Phoenix application because many of BEAM’s advanced features are supported out-of-the-box, the in-memory state is persistent since servers are never restarted, and an easy deployment flow is provided. Even though, it comes with a higher cost, some security concerns, and a lack of support for additional services.

Render

Render supports Elixir with the Distributed clustering feature, but SSH access to the instance is not allowed yet, which means mix release remote or mix release observer features cannot be used.

While it is cheaper than Gigalixir ($7 for each 0.5 GB of memory for the app instance), with such limitations alone, Render is not suitable for a production system, as access to the instance or checking the BEAM instance is critically needed.

Amazon Web Services (AWS)

As an Infrastructure as a Service (IaaS) provider, AWS is more flexible than the aforementioned Platform as a Service (PaaS) providers. AWS allows a team to build a flexible infrastructure to map with any requirements, for example:

  • Setup the database in a private network (by using a VPC).
  • Running on distributed clustering (by using ECS or EKS).
  • Blue/Green deployments.
  • Direct SSH connection to instances.
  • Easy to scale up/down with AWS Autoscaling.
  • No limitations on the handling of concurrent requests with AWS Load balancer.

AWS also provides many additional services such as Amazon Elasticsearch, Amazon ElastiCache, CloudWatch, Route53, S3, etc. Listing all AWS services is out of this article’s scope, a complete list can be found on the AWS website.

Putting all together, AWS does cater to all of Elixir’s application architecture needs, from one server to thousands of servers. However, it requires application’s owners to provision and maintain the infrastructure on their own. If you are in need to build or manage your Elixir application, Nimble offers professional development services for Elixir and Phoenix.

If this is the kind of challenges you wanna tackle, Nimble is hiring awesome web and mobile developers to join our team in Bangkok, Thailand, Ho Chi Minh City, Vietnam, and Da Nang, Vietnam✌️

Join Us

Recommended Stories:

Accelerate your digital transformation.

Subscribe to our newsletter and get latest news and trends from Nimble