What is sbroker library in plain terms and what it does?

I trying to understand the Postgresx driver for elixir
According to the sbroker description

Sojourn-time based active queue management library

The main roles of a pool are: dispatching, back pressure, load shedding, worker supervision and resizing.

Apart from worker supervision I don’t understand any of the other terms can someone explain what it does and terms

1 Like

Imagine You are at the post office. You want to send a letter, but it is rush hour. Only 5 desks, for more and more people. queue behind each desk starts to grow, that is resizing.

Imagine You are still at the post office. You arrive in front of the cashier, but he starts to feel asleep. The manager comes and yield at him, that is worker supervision.

Just behind there is the back office. Employees are sorting letters. One employee is sorting letters by part of the city and distribute them to the corresponding zone employees, that is dispatching.

Now it’s busy time, maybe black friday… to many letters, the poor employees cannot follow more than 10 letters at a time. If only they could say… ok, I do 10 and You give me 10 more after but please don’t send me all at the same time, that is back pressure.

Under heavy heavy load, the work could be distributed between post offices, that is load shedding.

So sbroker manage the load of workers by using an active queue, acting like a resizable buffer, allowing the system to support heavy activity. GenStage is an example of behavior meant to solve those kinds of problems, in particular back pressure.


Fantastic analogy

1 Like