Episode 3 – 136.000 Processes on a ‘Pi!

In Episode 2, we hinted that this video would contain some distributed Erlang fun but since we are still (eagerly) waiting for the postman to deliver the rest of our Raspberry Pi boards, we thought it would be cool to spend more time playing with concurrency.

Ed, one of the Erlang hackers in our London office (also our resident Thai food expert), joins us in this video to talk about the process ring demo he’s coded:

“More blinkenlights?!”

It’s true that blinking an LED is not the most computationally challenging task but it certainly is a nice way of demonstrating program activity. In this demo, LEDs are used to visualise tokens being passed around a ring of processes. Each LED will toggle it’s state once a token gets passed around 100 times around the ring. For example, the red LED will toggle state once the token gets passed around 100 times over 1000 processes and it will blink after two revolutions (since a blink is essentially two ‘toggles’).

We managed to spawn up to 136.000 processes without any tricks, other than increasing the maximum number of concurrent processes allowed by the runtime using the +P parameter, which by default is set to 32768, after which we started running out of memory — an impressive figure considering that this is on a credit-card sized computer that costs $35!

As always, you can grab a copy of the code at our GitHub repository.

We will be busy getting ready for the Erlang User Conference 2012 that’s happening at the end of the month so the next video might be a bit late but we promise it will be worth it 😉

Leave a Reply

Your email address will not be published. Required fields are marked *