OTP and the microservices advent

otp
phoenix
microservices

#1

About a month or so we embarked on redesigning/rearchitecting most of the operation processes of the business for the company I work for, one of the biggest online clothing retailers in Mexico.

In order to support more sale channels and marketplaces, we decided to delegate some operational aspects of the overall system and start building systems to coordinate or orchestrate these operations and keep them in sync with our monolith back office system and services around it.

We started building these microservices using Go. It’s been a little difficult to find people willing to work/learn Go our the Mexico City’s area, but still, we are about to ship these to production and the overall outcome seem pretty promising, systems talk to each other in a proper way using message queues, RPC calls, etc.

We built a series of mechanisms in order to manage and monitor the lifecycle of various processes (task workers, consumers, etc.) in Go. Which I’ve seen that’s related almost homogeneously to the way Processes, GenServers and Supervisors work in Elixir.

As of today, we manage and monitor periodically running tasks and queue consumers using Goroutines, channels, and mutexes. Different endpoints are exposed via an API in order to query the state of processes and to manage their lifecycles, the number of workers needed for a particular job/consumer.

Although it works, I started feeling it is a little hacky, considering that this kind of supervising processes seems to come out almost free out of the box in OTP, the challenging being I think designing the correct processes tree and exposing the interfaces to monitor/manage them.

In this regard, along with reading the excellent articles and presentations out there, I’m considering getting a couple of books in order to research this in depth and build a stronger base to implement part of the system using Elixir, but I’m afraid of wasting my time (and money) reading things that treat Elixir with a web development point of view. Not that I’m not considering something like Plug, or even Phoenix, but for now I consider a little more important understanding OTP for the kind of system we are trying to build.

What are your thoughts on the following books? Is there any other good book/resource you consider worth reading to have a better understanding of OTP and Elixir in general?:

Thanks in advance!


#2

So far the best OTP (design) book that I’ve encountered is still Designing for Scalability with Erlang/OTP-Implement Robust, Fault-Tolerant Systems. The ebook is available DRM-free from Google Play Books and ebooks.com. The free sample on Google Play Books covers everything up to most of Chapter 4.

The Chapter 2 Erlang primer should be enough to get an Elixir developer going to understand the Erlang code - which isn’t that difficult to port to Elixir.

Functional Web Development with Elixir, OTP, and Phoenix would be a great follow up as a demonstration in the pure Elixir space with Phoenix (don’t forget the forum discount).

If you are still looking for a more introductory Elixir text Elixir In Action - 2e is a good choice for an experienced programmer with its more “Erlang-oriented” approach - and it dabbles a little bit with OTP (for a few more hours half off).

Fred Hébert:


#3

@peerreynders Thanks for your recommendations. I’ve been playing around with Elixir mostly, no Erlang nor Phoenix, but I’m more interested in getting a good understanding of the design principles of OTP, so definitely I will check your first recommendation. Following up with the one that covers OTP and Phoenix too.

Thanks!


#4

I think highly of the Programming Elixir >=1.6 book for established programmers in other languages.


#5

Hi @ghoetker, thanks for your response.

I’ve been reading (the few) comments on the internet about the book, no this particular edition for Elixir 1.6 but, they all seem to agree on that the book doesn’t get deep on OTP, I mean, as I was saying, I’m aware enough about Elixir and the functional programming side of things, but most of the resources I’ve found (articles, videos) don’t deepen on supervising trees, which is exactly what I’m trying to get my hands dirty with. I’ve already added that book to the basket though.

I already started reading the one @peerreynders suggested, I think it aligns more with what we have ahead rather than just learning a new programming language, be it Elixir or Erlang, I think it’s more of a mindset shift.

Thanks!


#6

If You want to focus on OTP, there is also from Manning

It is also an Erlang book, a little bit outdated, but worth the read.

I also did enjoy The little Elixir & Otp guidebook, as it really focus on Otp. While outdated too, if You make the effort, You will learn how to build a poolboy clone.