- URL: https://www.laruence.com/en/2010/12/17/1833.html
- Please include attribution when republishing.
Today I saw a repost on Weibo, with a title that was quite alarming: "Why is PHP's echo so slow?".
Clicking in, the gist is that echoing a 500K string in PHP takes hundreds of ms,
and the author then said that after turning on Apache's compression, the speed improved.
After that, I saw another colleague who approached it from the HTTP protocol, analyzing chunked mode vs direct transfer mode, the idea possibly being that it's related to segmented transfer...
I'm not criticizing or refuting anyone here, and those involved, please don't be angry — I just don't want to mislead others..
Echoing a 500K string being slow has nothing to do with PHP, and nothing to do with C, the language PHP is implemented in either. The relation is IO — the speed of IO limits the speed of output..
As for Apache's compression,, well,, after compression, the string becomes smaller (strings have a high compression ratio), so it naturally gets faster (trading CPU for IO)....
Finally, PHP is really innocent. It really has nothing to do with it..
Be First to Comment