20k messages in 4s but want to go faster!

Jim Morris <>
Mon Jul 13 07:57:57 CEST 2009


Actually Tony has a good point, I presumed Joel was doing it that way.

In my server when I unicast what I actually do is send an erlang
message to each process, and that of course sends the TCP message to
its client. So when I have 8,000 clients connected I have 8,000
processes, and each one sends a TCP message to its client.

Not sure if having a list of 8,000 TCP sockets and iterating over them
sending to each socket from a single process would be any slower, I
never tried that approach. It seems more obvious to me to have a
process per connection, and that process is responsible for any
communication with its client, that way everything is serialized to a
specific client, and the process keeps its clients state.

So Joel do you have one process per client or iterate over a list of
sockets?

On Jul 12, 4:37 pm, Tony Arcieri <> wrote:
> On Sat, Jul 11, 2009 at 3:34 AM, Joel Reymont <> wrote:
>
> > On Jul 10, 2009, at 11:56 PM, Tony Arcieri wrote:
>
> >  Have you tried persisting the processes?
>
> > What do you mean?
>
> If this sending of 20k messages is a repeat affair, what if you had a
> process per connection you could broadcast messages to that remained alive
> for the duration of their TCP connections?
>
> There would be overhead for process creation/teardown, but it would not
> factor into the actual message transmission if the processes were
> persistent.
>
> Just a guess... as Jim Morris said a better profile of where your program is
> spending its time would be helpful in diagnosing this problem.
>
> --
> Tony Arcieri
> medioh.com


More information about the erlang-questions mailing list