[erlang-questions] Slow when using chained gen_server:call's, redesign or optimize?

Jesper Louis Andersen <>
Sun Jan 29 12:15:30 CET 2012

On 1/29/12 12:13 AM, Jachym Holecek wrote:
>> -export([write/1, read/1]).
>> write(Obj) ->
>>    call({write, Obj}).
>> call(M) ->
>>    gen_server:call(?SERVER, M, infinity).
>    3. No infinite timeouts without very good justification! You're
>       sacrificing a good default protective measure for no good
>       reason...
The question here is really one of what you want to do if a write takes 
more than the default timeout of 5 seconds. You can either decide to 
tell the writer that the cache is clogged up at the moment and the 
abstain from caching the result, you can crash, or you can wait around 
like the above code does. What the right thing to do in a situation 
depends a bit on what semantics you want.

Perhaps my reaction for a cache was to knee-jerky. You might want a call 
to fail if it takes too long to process because it will uncover another 
problem in the code: namely overload of the cache.

Jesper Louis Andersen
   Erlang Solutions Ltd., Copenhagen, DK

More information about the erlang-questions mailing list