New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
High and Unexpected Memory surge #886
Comments
for low latency app, I recommend my highly-optimized logging https://github.com/phuslu/log |
Unfortunately we cannot investigate this issue without more details. Ideally, a minimal, reproducible case would be ideal. Alternatively, pprof memory/CPU profiles would be helpful. |
For OP case, I suppose the root cause is that zap/zerolog printf style API is Here is my implementation, https://github.com/phuslu/log/blob/9f855b33c3ba967ea71dd71e67f709eacd0f06f8/logger.go#L1171-L1186 And a playground example: https://play.golang.org/p/B86nSTxiiYy |
@phuslu Thanks for recommendation, will test and try to implement the logger you shared. Does your logger support printf styling logs as I have tried the zap structured logger with no success it also has the heavy memory issue. |
@phuslu thanks for example. Hoping the 20% performance difference of your sugared logger as mentioned on repo doesn't affect the latency of the app. Checking out other examples on the repo. |
Hi @azamshaikh-ai Have you solve your memory usage issue yet? I'd like confirm my assumption between |
Not yet, plan is to implement |
We avoid unsafe in zap, and the Core API uses strings, so we cannot do a 0-alloc sugar logger. For performance-sensitive cases, we recommend the non-sugared logger. |
I have implemented log using a wrapper for both zap(sugared) and logrus.
Main log file has struct defining a variable of Logger interface implementing all the logging function and other variable in struct include config to be used to initalize respective log library.
Initializing zap logger like this:
Interface implementation as follows:
However this does work when sending single request, but on production with zap production sugared logger on trace/debug mode, both console and file uses heavy memory increasing from 0-10%, some time also crashes the app and latency goes over 2-3 minute, some function which contains few variable initlaization takes 16000 seconds to process as compared to 1-2ms when processed without logging on or using single manual request. Logging 1-2 log in each request works great. But logging in trace/debug mode is pain to memory.
What could be wrong here in my approach which has to be a low latency app with proper logging at various stages.
Have checked #851, not sure if that's works as I am still having issue with the memory usage.
The text was updated successfully, but these errors were encountered: