I’m analyzing the concurrency principles for the Erlang processes and their mailbox.
So I know each message is processed one by one which seems a bit like a mutex in the concurrency language.
However there are some limitation regarding the maximum size of the mailbox and its message queue.
I found an article and lib proposed by Discord using semaphore to ensure the non overloading of the mailbox queue. Which seems like back pressure for Erlang processes . So this would mean to implement for each GenServer message an update of a counter using atomic updates and from the client verifying if there are some space for it.
But I know this concept of backpressure is already managed by GenStage , so a consumer is not overloaded by a list of messages. Nevertheless, from a producer perspective, it will be possible to overflow some pushed events and the GenStage mailbox and internal queue. This may causes event dropping.
So do you know if GenStage manages this ? Should we using semaphore concept to protect processes ? Or maybe using pooling to resolve this issue ?