-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add support for QueueHandler and Listeners in logging pipeline #250
Comments
Thanks for mapping this, David, and all the findings and progress so far. |
So I was able to figure out a way we could potentially introduce queueing to our logging pipeline. Python's logging framework allows for setting the class of the logger returned by the getLogger function. What we can do is derive a new logger from the base logger that has built in queueing. I was able to construct a synthetic benchmark using this technique, and was able to see that the results were fairly comparable to the ones I got with attaching the queue handler to the regular logger. Here are the results I got:
|
@Ktmi looks like a very elegant solution. The gains are expressive, another cool thing also about this QueueLogger is that it respects the debug level accordingly, and if it performs well under stress tests on REST endpoints on hot paths that's a double win. In addition to the |
This has landed on #257 |
This issue is on using
QueueHandler
+QueueListener
to potentially improve logging performance.In #236 @viniarck discussed how loggers would result in reduced performance in our application hot paths. As part of discussion of this issue, @viniarck suggested that we integrate
QueueHandler
+QueueListener
into our logging pipeline in order to offload the IO operations associated with logging into a separate thread.As part of the evaluation of #247, I examined the potential performance gains of modifying how we provided the logger to napps by cross validating it with different methods for handling logging in a synthetic benchmark. Included in the log handling methods was a
QueueHandler
+QueueListener
for dispatching records to IO based handlers. I found that using theQueueHandler
resulted in the calling thread spending less time logging than using aStreamHandler
orRotatingFileHandler
. Here are the results I collected:Note: The first time is instantiation time for the logger, the second is the amount of time it takes to log 10000 records.
@viniarck took part of my synthetic benchmark code to create a test for using
QueueHandler
+QueueListener
in Kytos to measure the performance in a closer to real world setting. He found that versus directly passing logging to IO handlers, that logging with the QueueHandler performed about the same as the IO handlers. Here are his results:Logging with IO Handlers:
Logging with Queue Handlers:
Conclusion
It seems to me that Queue handlers have some potential to improve performance, however to what degree seems to vary. In @viniarck tests it showed little improvement by comparison to the IO Handlers, however in my experiments it showed nearly a 2x performance increase. In order to find out more, I propose we implement a method to use QueueHandlers and QueueListeners with our current logging infrastructure. This can be made an optional feature, which can be used in systems where logging directly is known to be slow.
Notes
It should be noted that both my benchmark and @viniarck's test contain the same bug, where we pass True as a handler for the queue listener, instead of doing
respect_handler_level=True
. This however, didn't seem to majorly affect performance. Additionally @viniarck uses one logger going to two queues each going to a separate handler, rather than 1 logger to 1 queue to both handlers, which could potentially increase performance.The text was updated successfully, but these errors were encountered: