3 ms·
>>Actually, only the thread running the PHP script blocks. Other threads/processes can run. Yup. But imagine a situation that suddenly around 10000 requests ha
by prahladyeri 12y ago
>>Actually, only the thread running the PHP script blocks. Other threads/processes can run.
Yup. But imagine a situation that suddenly around 10000 requests have arrived at your server and sitting on the queue. Now that "one php thread" suddenly becomes a life-saver.
- mtdewcmu 12y agoIndeed. That's what node.js is for. I was just nitpicking the article's explanation. It would be interesting to see a breakdown of what makes the apache+PHP solution so slow. apache probably eats a lot of time by itself. Are you using an opcode cache for PHP, like APC? The PHP script is being executed repeatedly, possibly being read, parsed and translated into bytecode each iteration. The Javascript gets compiled once into native code by v8 and just loops.
- prahladyeri 12y agoThe opcache is enabled and so is apc (though I don't think caching would matter much in this case). As for apache eating time, nginx might run a bit faster than apache, but without a proper async I/O model built into the language itself (such as functional javascript), it would still be a band-aid solution.
- mtdewcmu 12y agoTrue. I don't expect that nginx would make them equal. But it would be interesting to gather more evidence to support the hypothesis that async I/O is the difference.