Need help understanding the worker_pool by inaka - anyone have any simple examples?

hey everyone. i am desperately trying to understand the worker_pool by inaka(GitHub - inaka/worker_pool: Erlang worker pool). the complex examples are quite hard to understand for a beginner like me, does anyone have any simple examples displaying the use of wpool please?

2 Likes

@shalinimada I would rather suggest poolboy or poolgirl. Much simpler to read and use IMHO

@shalinimada welcome! I suppose Mr. @elbrujohalcon can provide a lot of information about this great project.

In a nutshell: The idea behind worker_pool was that you would just replace your calls to gen_server with calls to wpool, i.e., wherever you had a gen_server:call(ā€¦) now you put a wpool:call(ā€¦) and thatā€™s it!

Here you can find our original explanation in a blog post that was luckily archived at archive.org: inaka / Worker Pool (for Erlang)

2 Likes

thank you so much., i will try that out

1 Like

Iā€™m not sure if it improved over time, but at the time of creating worker_pool, poolboy had a far more complex interface and it was far less configurable and scalable than wpool.
In fact, we wrote worker_pool because the libraries that existed at the time were insufficient for our purposes.

If I might only ask, can you point out which examples (or a lack of them) did you find complex? Would love to fix documentation a bit so any feedback is welcomed :slight_smile:

3 Likes

In the test folder, in the various test suites there is a lot of information there,especially for a beginner.so someone can easily get lost.
a simple basic example would have been great . for example :
in worker_pool.erl::
wpool:start_pool(test_pool,ā€¦) , that starts a test_worker.erl as a worker n times. and the some lines of code to bounce calls , broadcasts , calls in a simple way to easily understand worker_pool.

I think that would have been very helpful.

2 Likes

Hi @shalinimada, I would love to hear what you are trying to do with pools.

The available options, worker_pool, poolboy, poolgirl, the about-to-be-revived pooler, hnc and maybe more, are each suited to slightly different use cases, AFAICT, but in order to give you better advice I need to know more about your use case.

FWIW, personally I wouldnā€™t go for poolboy, though. The project seems to be abandoned, it has bugs and ugly edge case scenarios that have been known for ages but were never fixed. As an example, failure to restart a single worker crashes the entire pool.

1 Like

Hey, Iā€™ve reworked a lot the documentation, though currently thereā€™s a conflict between what the formatterā€™s plugin and the documentation plugin like, so until it is resolved, we canā€™t merge.

However, you can checkout that branch and build the documentation locally using rebar3 ex_doc and browse the docs as they are generated. Hopefully itā€™d be more useful now, let me know :slight_smile:

Edit, oh, the PR, forgot to paste!

3 Likes

Lookā€¦ itā€™s alive!! Worker Pool ā€” worker_pool v6.2.0

5 Likes