Hi, I am looking for a way to monitor connections pool of Ecto repo. Basically we want to measure maximum capacity of our application, sort of a load/performace testing of app and DB.
We are using Postgres adapter in our application and have defined multiple repos with different
pool_size options. Is there an existing library or examples on how to check/count active DB connections in real time? We were considering
db_connection behaviour callbacks but just not sure if this is the right direction.
What have you tried so far? I’m curious of the same but haven’t dug deep yet.
Unfortunately I haven’t tried anything so far, besides basic research of tools and libraries. We used Postgres ‘Database Sessions’ graph before but it was just not enough, specially when there is more than ecto repo per database.
Ecto emits telemetry events for every query: https://hexdocs.pm/ecto/Ecto.Repo.html#module-telemetry-events
You can use it to track how long you are awaiting on the queue, the query time, as well as decoding time.
Thanks, yes, that seems like a very useful solution. I wonder about the case when given query won’t be finished for any reason, like a timeout for example. I guess in that case Telemetry won’t report any events regarding that query?