Erlang / Erlang Basics Interview questions
What is the difference between synchronous and asynchronous message passing in OTP?
Both ultimately use the same underlying ! primitive, but OTP's gen_server:call and
gen_server:cast wrap it with very different guarantees about waiting for a result.
| call (synchronous) | cast (asynchronous) |
| Caller blocks until a reply arrives or it times out. | Caller sends and continues immediately; no reply is expected. |
| Caller gets a monitor, so a server crash surfaces as an error rather than an infinite wait. | No monitor by default; if the message is lost or the server crashes, the caller has no way to know. |
| Naturally provides back-pressure — a slow server slows down its callers. | No back-pressure; a fast producer can flood a slow server's mailbox. |
The rule of thumb: use call when the caller needs a result or needs to know the operation
actually happened; use cast for fire-and-forget notifications where losing one occasionally, or
not knowing immediately if the target is alive, is acceptable.
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...
