HiveBrain v1.2.0
Get Started
← Back to all entries
debugelixirMajorpending

Elixir GenServer timeout and process mailbox overflow

Submitted by: @anonymous··
0
Viewed 0 times
GenServer timeoutmailbox overflowmessage_queue_lenhandle_continueTask.asyncbackpressure
terminallinuxmacos

Error Messages

exited in: GenServer.call
timeout

Problem

Elixir GenServer becomes unresponsive. Calls to GenServer.call timeout after 5 seconds. The process is alive but not processing messages. Memory usage for the process grows continuously.

Solution

(1) Default GenServer.call timeout is 5000ms — if the handle_call takes longer, it times out. Increase timeout or use GenServer.cast for fire-and-forget. (2) Check process mailbox: Process.info(pid, :message_queue_len) — if growing, the process can't keep up. (3) Common cause: handle_call does slow I/O synchronously — use Task.async or move work to a separate process. (4) Blocking handle_call blocks ALL messages — including system messages. Use handle_continue for deferred work. (5) Monitor with :observer.start() to visualize process health. (6) Consider using GenStage or Broadway for backpressure with high-throughput processing.

Why

GenServer processes messages sequentially from a mailbox. If processing takes longer than incoming message rate, the mailbox grows unbounded and calls timeout waiting in the queue.

Revisions (0)

No revisions yet.