inaka

Latest blog entries

/
The Art of Writing a Blogpost

The Art of Writing a Blogpost

Apr 11 2017 : Matias Vera

/
SpellingCI: No more spelling mistakes in your markdown flies!

Feb 14 2017 : Felipe Ripoll

/
Fast reverse geocoding with offline-geocoder

Do you need a blazing fast reverse geocoder? Enter offline-geocoder!

Jan 18 2017 : Roberto Romero

/
Using Jayme to connect to the new MongooseIM REST services

MongooseIM has RESTful services!! Here I show how you can use them in an iOS application.

Dec 13 2016 : Sergio Abraham

/
20 Questions, or Maybe a Few More

20 Questions, or Maybe a Few More

Nov 16 2016 : Stephanie Goldner

/
The Power of Meeting People

Because conferences and meetups are not just about the technical stuff.

Nov 01 2016 : Pablo Villar

/
Finding the right partner for your app build

Sharing some light on how it is to partner with us.

Oct 27 2016 : Inaka

/
Just Play my Sound

How to easily play a sound in Android

Oct 25 2016 : Giaquinta Emiliano

/
Opening our Guidelines to the World

We're publishing our work guidelines for the world to see.

Oct 13 2016 : Brujo Benavides

/
Using NIFs: the easy way

Using niffy to simplify working with NIFs on Erlang

Oct 05 2016 : Hernan Rivas Acosta

/
Function Naming In Swift 3

How to write clear function signatures, yet expressive, while following Swift 3 API design guidelines.

Sep 16 2016 : Pablo Villar

/
Jenkins automated tests for Rails

How to automatically trigger rails tests with a Jenkins job

Sep 14 2016 : Demian Sciessere

/
Erlang REST Server Stack

A description of our usual stack for building REST servers in Erlang

Sep 06 2016 : Brujo Benavides

/
Replacing JSON when talking to Erlang

Using Erlang's External Term Format

Aug 17 2016 : Hernan Rivas Acosta

/
Gadget + Lewis = Android Lint CI

Integrating our Android linter with Github's pull requests

Aug 04 2016 : Fernando Ramirez and Euen Lopez

/
Passwordless login with phoenix

Introducing how to implement passwordless login with phoenix framework

Jul 27 2016 : Thiago Borges

/
Beam Olympics

Our newest game to test your Beam Skills

Jul 14 2016 : Brujo Benavides

/
Otec

Three Open Source Projects, one App

Jun 28 2016 : Andrés Gerace

/
CredoCI

Running credo checks for elixir code on your github pull requests

Jun 16 2016 : Alejandro Mataloni

/
Thoughts on rebar3

Thoughts on rebar3

Jun 08 2016 : Hernán Rivas Acosta

/
See all Inaka's blog posts >>

/
Worker Pool (for Erlang)

A photo of Brujo Benavides wrote this on September 25, 2014 under erlang, inaka, worker_pool .

Not long ago, Fred Hebert released a great new book ERLANG IN ANGER. I'm reading it (according to my kindle, I'm 45% into it already) and I realized, as many others may have as well, that many of the problems and situations described in the book also happened in one or more of the systems I developed.

In this post I want to talk about one in particular: bottlenecks. In particular, a while ago (while working for TigerText) we found one where a single gen_server was slowing the whole system down because it couldn't process messages fast enough so its message queue kept increasing with each new message until the other processes that depended on it timed out and/or just crashed.

At that time, we didn't know Fred's pobox (the recomended library in his book) and poolboy was not quite what we were looking for. So, we created worker_pool: a very simple pool of gen_servers that turned that single server into a group of servers, all managed by a supervisor.

More than 2 years later and after many battles, we decided to give it the proper care (i.e. documentation, tests, etc.) it needs and release it to the world.

You can read all about it in its github page and its documentation but in a nutshell, this is how you would use it:

%% You start a pool...
wpool:start_pool(
    my_pool,
    [{workers, 200}, {worker, {my_module, []}}]),

%% You call/cast to your servers as
%% you would've done if you had just one...
wpool:cast(my_pool, my_message),
wpool:call(my_pool, my_other_message),

%% You can pick a different strategy to
%% choose the worker to process your request...
wpool:cast(my_pool, my_message, best_worker),

%% You can check how your pool is behaving...
wpool:stats(my_pool),

%% And you close your pool, if you want...
wpool:stop(my_pool).

The library is already being used in sumo_db and therefore in all the systems that use it as a persistency layer, so you can say it's production-tested. In fact, one of the main use cases for this app is multiplexing requests to servers with long initialization periods and a somewhat big state (like database connections).