[erlang-questions] Design to Avoid Races

Roger Larsson roger.larsson@REDACTED
Sat Sep 16 08:16:39 CEST 2006


On Saturday 16 September 2006 02:58, Darrin Thompson wrote:
> I've been building a comet app with yaws, and I've run into a mental
> block trying to get something "right".
>
> Most of the examples in tutorials assume that an app is built out of a
> number of processes communicating.
>
> Suppose I have two users chatting, and my design calles for each user
> to have a process. The processes were spawned when users created
> sessions. The processes were linked when at some point the users chose
> to communicate.

The user is interested in chatting with a real person - not a pid.
So I would store the friends Nick (and a cookie) in my process.
And have a name server where everyone register their pid, and link to them.

When the friend process dies. Query the name process.
Name process could delay answers for a while to give the peer time to restart.

Connection reestablished!

I would avoid to have a router process - it sounds like a bottleneck...
Note that the user processes could be located on different nodes.
And the name server could be distributed as well, store names, cookie in
Mnesia.

Other ideas?

/RogerL



More information about the erlang-questions mailing list