Email or username:

Password:

Forgot your password?
Ben Ramsey

What's the performance impact of logging in #PHP? Is there an I/O difference between writing to `STDERR` or `STDOUT` vs. a local file on disk?

I've heard folks like @rasmus speak in the past about ensuring you don't have errors because, even if you have error logging set to `error_reporting(0);` (i.e., "off"), the error handler is still invoked, so there's still a tiny a perf. hit, but I'm curious about the I/O impact between the various log streams.

14 comments
will talk for elePHPants!

@ramsey From an academic point that seems an interesting question indeed!

From a performance point of view I'd say "when that is your problem, you got other problems"

/cc @rasmus

Ben Ramsey

@heiglandreas @rasmus Well, yeah. I’m trying to understand how much of an impact it makes, even if minor. I’m also curious whether this is low-hanging fruit that could significantly impact performance of servers under high load.

will talk for elePHPants!

@ramsey The "significantly impact performance of servers under high load" is the thing where I believe you got other problems. Mostly when you got high load you are in a distributet setup where the underlying stream might not necessarily be a "real" filesystem so the minimal performamce gain will still cause network trafic with all the slowness that is tied to it.

But yeah. Investigating is cool and perhaps it can shave off a cPU cycle or two....

/cc @rasmus

will talk for elePHPants!

@ramsey Also:

"Don't optimize for the machine that executes the code! Optimize for the person that maintains the code."

CPU cycles are cheap. As is storage.

/cc @rasmus

Ben Ramsey

@heiglandreas I understand. I still want to know what the performance impact is.

will talk for elePHPants!

@ramsey As I said! Interesting question from an academic point of view! Go and figure it out!

And perhaps you can indeed make it a bit faster.

Ben Ramsey

@heiglandreas That's why I'm asking for pointers to resources to help me figure it out. ;-)

will talk for elePHPants!

@ramsey Thanks! TIL that STDOUT and STDERR are by default different in regards to buffering.... 😁

Beth Tucker Long

@heiglandreas @ramsey This is a very interesting question, especially considering the thousands of extra notices and warnings that 8.2 is generating on servers hourly.

Ben Ramsey

@e3betht @heiglandreas This comes closest to the type of resource I'm looking for. I might need to replicate their benchmarks for Java in PHP, using comparable libraries/approaches. blog.sebastian-daschner.com/en

ghorwood↙↙↙

@heiglandreas @ramsey is there a link on this? because i would totally read it.

will talk for elePHPants!

@ghorwood Just some stuff I found when searching for "performamce difference stderr stdout". Mostly on StackOverflow...

/cc @ramsey

Jim Winstead

@ramsey I’m not sure what the real-world performance impact would be, but isn’t `STDOUT` line-buffered and `STDERR` isn’t (and a file would depend on how you opened it)? @rasmus

Buathier

@ramsey @rasmus I worked a few years with logging on legacy systems. My approach was writing into rotating files (some were minutely with max 10 files because of the stream size). Filebeat streaming to logstash parsing to elastic (all in private network on VMs). The only problems I had to face was managing the free space. I used the rotating logs on FS as a broker. I don’t really know the impact of file logging as I did, but this was negligible in comparison with all the legacy bad designs.

Go Up