Erlang / Erlang Basics Interview questions
How do you troubleshoot process mailbox overflow?
A growing mailbox means a process is receiving messages faster than it processes them, which if left unchecked can exhaust memory and eventually crash the node. The first step is confirming which process(es) are affected.
Pid = whereis(my_worker), {message_queue_len, Len} = process_info(Pid, message_queue_len). %% or, node-wide, via recon: recon:proc_count(message_queue_len, 5).
Once you've identified the culprit, common causes and fixes include:
- Slow receive loop — the process is doing too much per message; profile and optimize the hot path, or offload work to helper processes.
- Unbounded producer — switch producers from
casttocallso they block and naturally throttle instead of flooding the mailbox. - Selective receive scanning cost — a
receivewith a narrow pattern has to skip past unmatched messages already in the queue; a mismatched, ever-growing backlog of unrelated messages makes each receive progressively slower.
Tools like observer's process view, or the recon library's
proc_count/2, make it straightforward to spot the offending process across a whole running node
rather than checking processes one at a time.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
