We are hiring

How fast can Erlang send messages?

My previous post examined Erlang’s speed of process setup and teardown. Here I’m looking at how quickly messages can be sent and received within a single Erlang node. Roughly speaking, I’m seeing 3.4 million deliveries per second one-way, and 1.4 million roundtrips per second (2.8 million deliveries per second) in a ping-pong setup in the same environment as previously – a 2.8GHz Pentium 4 with 1MB cache.

Here’s the code I’m using – time_diff and dotimes aren’t shown, because they’re the same as the code in the previous post:

Removing dotimes for oneway produced a speed boost of about 10% – but doing the same for pingpong scarcely affected the speed at all. If anything, it ran slightly slower. It’s possible that the extra arguments to the helper procedure (Count, Pid, Message) for the non-dotimes pingpong costs more than the overhead of using a fun for the dotimes pingpong. The fun can close over (Pid, Message) once, avoiding the need to pass the parameters around.