Help designing this web service

Hello, I want to write a web app (API) with Maru, that is going to act as a bridge to some slow web services. A request to the API would respond with a 200 right away, and call asynchronously to the slow web services.

I am new to Elixir. Which approach would you recommend for building this? Should I need a pool of workers of some sort for the slow requests? How to supervise them? How to create them and use them from the controller? Any guidance would be much appreciated.


First question, if it responds right away and calls to the slower service, do you want to throttle that if the slow service starts to get overloaded? If so then a pool of workers is perfect for this. If not then can just spawn off processes to do the slow async call.

Poolboy is a common library for pooling-made-easy, but you can always just do a supervisor with a genserver controller and a pool of workers under an adjacent 1-for-1 supervisor too.

Yes, probably the service would need to throttle, the workers should indeed try to keep persistent connections.

That sounds close to Greek to me :)… how would such code look like? And where would you setup all this stuff?

poolboy is the most popular pooling library, can see a discussion and links on using it here and the elixir school website has a section for poolboy specificly too.

sbroker is another alternative that is fairly popular with a good set of features, but less battle-tested than poolboy (which has been around for about a decade).


1 Like