[erlang-questions] Design question: A process created per request?

Chandru <>
Tue Jun 12 14:20:08 CEST 2007


Hi Yeming,

On 11/06/07, Yeming Zhao <> wrote:
> I want to write a TCP application to process requests from a client and then
> response, asynchronously. The client sends a request without waiting for the
> response for the previous request. I'm assuming the processing will be
> time-consuming (part of the request may be forwarded to another server and
> my app will wait for the response from that server before it can send the
> final response to the client).
>
> I'm new to Erlang and heard creation and message passing in Erlang is
> inexpensive. I'm thinking of spawning a process for each request, but I'm
> really not sure whether this is the standard way in Erlang. Can someone give
> me any advise?
>

You heard right - that is the best way to handle such requests. Each
worker process you spawn can also write the response directly to the
socket without having to channel it through the process which owns the
socket. Even if some requests fail because of some errors, only those
requests will be affected so you get nice fault isolation.

Chandru



More information about the erlang-questions mailing list