Is there an option in Ecto to connect only when needed? rather than keeping connection open?
Could you please explain your usecase for this so that I can understand why you’d want to do that?
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?
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.
Thanks minhajuddin