You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now /stats HTTP call always returns memory stats even if you don't need them. To do that it calls runtime.ReadMemStats which incurs STW on every call. Go team did make it very short but I would like to avoid it completely if I can.
The use case for us is the following. We use stats call to measure how full topics and channels are and throttle producers so that they don't keep spamming messages if consumers for some reason are slow. It could be due to consumers simply not working properly or just being overwhelmed with traffic. Our services can be quite slow as each NSQ message is a task that requires heavy computations. We request stats every 30 seconds. This seems not too much but this is done in every service (we built our own custom NSQ client library that does this) of which there're 10s and 100s of instances. Naturally, even with 30 seconds interval NSQ nodes would be constantly blasted with these requests.
I looked at the code and see that there's already some GET parameters like include_clients that you can use to filter out unneeded information. I propose to add another one include_mem that would allow one to avoid calling getMemStats (which, in turn, calls runtime.ReadMemStats) completely. I'm willing to send pull request if this gets accepted.
The text was updated successfully, but these errors were encountered:
@jehiah of course. By default it would return everything. Only when include_mem=0 would it exclude the information.
One question remains, how should the response look like if include_mem=0? Should memory field in JSON and Memory: in text formats be completely removed or just return zeroes for all mem stats? Personally have no real preference. The latter could be done in just a few lines.
Right now
/stats
HTTP call always returns memory stats even if you don't need them. To do that it callsruntime.ReadMemStats
which incurs STW on every call. Go team did make it very short but I would like to avoid it completely if I can.The use case for us is the following. We use stats call to measure how full topics and channels are and throttle producers so that they don't keep spamming messages if consumers for some reason are slow. It could be due to consumers simply not working properly or just being overwhelmed with traffic. Our services can be quite slow as each NSQ message is a task that requires heavy computations. We request stats every 30 seconds. This seems not too much but this is done in every service (we built our own custom NSQ client library that does this) of which there're 10s and 100s of instances. Naturally, even with 30 seconds interval NSQ nodes would be constantly blasted with these requests.
I looked at the code and see that there's already some GET parameters like
include_clients
that you can use to filter out unneeded information. I propose to add another oneinclude_mem
that would allow one to avoid callinggetMemStats
(which, in turn, callsruntime.ReadMemStats
) completely. I'm willing to send pull request if this gets accepted.The text was updated successfully, but these errors were encountered: