We wanted to integrate with an external service, they would collect various metrics about our system so that the marketing team could do analytics on them.
The service provider we chose requested us to batch the requests so we wouldn’t overload their servers.
Choosing Elixir (esto le falta mucha cindor)
We are using rails, so when you think “I need a small server” in the ruby world everybody thinks Sinatra.
But this server would get a lot of traffic, and we don’t want to have the burden of making it scale and we’ve been wanting to try out elixir because we are having serious performance problems in our main app.
So we decided to make a small Elixir POC, along this post I’ll share my experiences, good and bad, using Elixir, both the tools and the programming language.
Why would I want to use Elixir
From the elixir website:
Elixir is a dynamic, functional language designed for building scalable and maintainable applications.
This sums up Elixir pretty well, except for a key concept: All data is immutable in elixir. Immutability lets you think generally and know that calling a function on a value will never modify it.
Another important point of elixir is that it’s a very flexible language, it inherits from erlang a very powerful macro system. We will see how this results while writing actual code.
Getting our feet wet in Elixir
As we all now, starting a new project in an unfamiliar environment can be challenging. But as many new languages, elixir has the burden to make it easy for developers to get their tooling and as expected, I had no issues installing Elixir as their website indicates.
And here is when I’d like to do
rails new, but luckily the elixir devs
created a tool called mix
that comes bundles with many useful tasks an can be extended by installed
mix new $PROJECT_NAME will create a
$PROJECT_NAME directory and populate it
with all that you need to start creating whatever you want. As always this is
really useful, both for getting started quickly and standardizing the way elixir
applications look just as Rails did before.
That will create the bare bones of any elixir application (nothing web specific yet), since our end product is only an API that doesn’t do much
After a little experimentation to get a better grasp of elixir and it’s ideas I felt like I could write my first tests