We found out recently that elasticsearch doesn't terminate clients by default. I suspect this endpoint might leak memory. Hopefully setting keepAlive: false and doing an explicit client.close() will be enough. Failing that, we probably need to separately manage a pool of clients for the app as a whole.
Measure how much memory is actually being leaked by pinging the process every n seconds for a large number of hours/days. Maybe it's not a problem at all.
If it really is a problem, try just closing the connections for each heartbeat.
Measure again.
If it's still a problem, we probably should try pooling elasticsearch connections, or having one that's dedicated to the heartbeat endpoint (maybe we can register it on the server at startup).
We found out recently that elasticsearch doesn't terminate clients by default. I suspect this endpoint might leak memory. Hopefully setting
keepAlive: false
and doing an explicitclient.close()
will be enough. Failing that, we probably need to separately manage a pool of clients for the app as a whole.