roadrunner icon indicating copy to clipboard operation
roadrunner copied to clipboard

[💡 FEATURE REQUEST]: Non-blocking logging

Open jackprice opened this issue 6 months ago • 1 comments

Plugin

Logger

I have an idea!

Currently, logging is blocking.

You can see this in action by running roadrunner through pv:

./rr serve 2> >(pv -q -L 1k)

This will result in a slowdown of roadrunner, including startup and a slowdown of it being able to process requests, tasks or workflows. (You can increase or decrease the throttling to see its effects by tweaking the -L parameter). The effect is higher with higher levels of logging, e.g. debug-level.

In my case, I'm running the roadrunner process from another host process, and processing its logs sent to stderr to enrich it. Poor processing performance on my part meant I was filling the pipe and blocking roadrunner.

jackprice avatar Jun 26 '25 08:06 jackprice

Hey @jackprice 👋🏻 Writing to a file (fd) would always be blocking and depends on your terminal throughput. This is why, if you need to write to a file, RR has a separate configuration for that (file logger). Also, debug logging level will slow down any application and should be used only on non-production environments. While we can use goroutines, for example, to write logs in a non-blocking manner, this may introduce significant memory spikes and slowness for the entire application (more goroutines -> more resources used). RR introduces several techniques under the hood, like sampling.

But I guess we can apply buffered writes as an additional technique to prevent stopping the application on log flushes.

rustatian avatar Jun 26 '25 09:06 rustatian