Not keeping connection open?

Is there an option in Ecto to connect only when needed? rather than keeping connection open?

1 Like

Could you please explain your usecase for this so that I can understand why you’d want to do that?

1 Like

The phoenixserver is used only for messages and channels, so little DB queries in, most our queries take place in our PHP server.

So, I thought that having connections on while rarely using them is not wise, right?

1 Like

You should be able to use Poolboy to configure the number of connections https://hexdocs.pm/db_connection/1.1.0/DBConnection.Poolboy.html

If you want just one connection open and want to open more connections as needed you could set the pool_size to 1 and pool_overflow to your maximum number of connections. However, if your site gets hit with a ton of traffic poolboy would try to create new connections (which takes time) as needed respecting the pool_overflow limit.

2 Likes

Thanks minhajuddin

1 Like