[erlang-questions] UDP client/server performance
Mon Aug 13 21:56:23 CEST 2012
Erlang will be slower and will consume more memory than C. That's pretty
much par for the course due to type munging and layers between you and the
hardware, including the VM itself. Some are using libevent through an
Erlang port to get around this.
You can also try "when I receive a packet, spawn an unlinked process to do
the reply" which may unblock things. (Not sure, haven't profiled it
Writing C directly to low-level structures is known to be much faster than
the Erlang VM. You can also see this in action at
On Mon, Aug 13, 2012 at 12:11 PM, Ronny Meeus <> wrote:
> I have created a simple UDP based client/server application.
> The code is available on bitbucket
> (https://bitbucket.org/meeusr/erl-examples) in the networking
> The server is just an echo server running in 1 process.
> The client can behave like a sync client (sending 1 message and
> waiting for the reply) or like an async client (sending X messages
> before waiting for all the replies).
> I see that my PC (Intel(R) Quad code i7 CPU 860 @ 2.80GHz) is able to
> process something like 7K - 10K messages per second. Both the sync and
> the async are in the same order of magnitude. Please note that I use
> the loopback interface.
> $ erl +sbt db
> Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4]
> [async-threads:0] [hipe] [kernel-poll:false]
> Eshell V5.9.1 (abort with ^G)
> 1> c(gen_udp_test).
> gen_udp_test.erl:47: Warning: variable 'Data' is unused
> gen_udp_test.erl:47: Warning: variable 'Msg' is unused
> gen_udp_test.erl:62: Warning: variable 'Data' is unused
> gen_udp_test.erl:62: Warning: variable 'Msg' is unused
> 2> gen_udp_test:start_server().
> 12> gen_udp_test:client_async(5000).
> stop : 841482
> 13> gen_udp_test:client_async(6000).
> stop : 1082679
> The timings are the number of usec for the processing of the X number
> of messages (round-trip).
> If I implement the same application in C (client and server are 2
> applications), I see that the application performs an order of
> magnitude better for the sync solution (86Kpkts/sec) and 100 times
> better (700Kpkts/sec) for the async version.
> The code for this is also available in the repo on bitbucket.
> I know there this test is only looking to a part of the application
> (transport of the data), but I find the difference rather big.
> Is this normal or is there something wrong in my Erlang code?
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions