How to use Poolboy in Elixir?

Hi all

I want to use poolboy and do not know how to use it.
What I did, just put poolboy into the dependencies

 defp deps do
    [{:poolboy, "~> 1.5"}]
  end

Could please someone help me, how to use poolboy?

Thanks

1 Like

What issues were you having when following the example application on the link you supplied? Is it just the Erlang->Elixir conversion you are having issues with? Or are you getting errors?

Also what are you trying to accomplish, do you need to use poolboy, or are you wanting a set of streaming workers, or do you need a single process, etc…? :slight_smile:

2 Likes

I need to create workers based on generic server. For example I need 10 workers to validate incoming requests body.

Thanks

Why do you need 10 workers? What are they being bound to that causes this number, is it an external server? Who will be accessing them and in what way and how often? What errors were you getting when you tried to implement poolboy? :slight_smile:

Basically I’m just trying to drill through questions to get the answer to The XY Problem. :slight_smile:

4 Likes

I’ve also been interested in Poolboy (just for educational purposes) since I’ve seen that a lot of apps use it. The thing is I don’t really know what its use-cases are, which problems does it solve and when you’re not supposed to use it.

The examples on its Github page are in Erlang (so I didn’t understand them at all) and I didn’t really find any Poolboy tutorials in Elixir. I think a basic overview of Poolboy with a few examples in Elixir would go a long way in helping Elixir noobs like myself understand it better.

(Except this: http://hashnuke.com/2013/10/03/managing-processes-with-poolboy-in-elixir.html)

2 Likes

Only times I would use it is for managing a fixed or bounded set of things, such as connections to another server, say a PostgreSQL server, and you want to throttle all access to that server through those limited connections. It is very specialized, but very very useful for what it is for. That is why I was asking the OP what his use-case was as there are often (though not always) better ways to accomplish it. :slight_smile:

2 Likes

This repository has some good examples https://github.com/thestonefox/elixir_poolboy_example

2 Likes

I’ve also been interested in Poolboy (just for educational purposes) since I’ve seen that a lot of apps use it. The thing is I don’t really know what its use-cases are, which problems does it solve and when you’re not supposed to use it.

I use it in an application where I have a pool of erlang processes that manage python processes. Each erlang process in the pool (poolboy_worker) is a gen_server. When started, the erlang process starts a python process (using erlport). If a pool worker crashes (an error can be either in erlang or python code), poolboy restarts it automatically. This way, I can execute python code concurrently and also take advantage of “let it crash” philosophy for python processes.

4 Likes