On Thu, Apr 1, 2010 at 12:57 PM, speedy <speedy.s...@gmail.com> wrote:
> Now imagine a whole web server written in PHP (ie. nanoserv), say, using > libevent as the network backend, running the above described real-time web > implementation. Alternatively, you could perhaps even wire it into > worker/event > model of apache/other servers instead of rolling your own. It sounds quite > powerful, > and development-effort-wise cheap - out of a mere HTML preprocessor! > > With proper threading, this would be a piece of cake to implement in PHP, > efficiently > and ensuring low latency, using up all available CPU cores / resources. > > Without using native threads, the whole class of web architectures on both > server > and processing levels, viewed both separately or together, are quite a bit > more hairy > to implement. > Sorry, but as a performance-oriented C developer who has written a good amount of stuff directly against libevent, I'm having a hard time not laughing at this thread. Why would anyone want to write such a thing directly in PHP, or any other scripting language for that matter? If you're worried about performance, you're going to have to do it in something either low-level or that is natively compiled. In the scripting language world, I can only think of something like Lua with libevent bindings as being capable of performing fairly well in a multi-threaded environment (given no GIL). Though, even in that case, you'd still have a good amount of custom work to do. I've worked with libevent-based Comet servers written in C, and there's *no way* a scripting language version is going to handle memory management, messaging, and queueing for a large number of connections effectively. Similarly, you'll never really be able to approach near-real-time processing in this type of environment given basic abstraction/interpretation/scheduling issues. These are very basic systems architecture issues and it's obvious that scripting languages are *not* designed for what you're asking. Not to sound demeaning, but do you have any real need for what you're asking, or are you just saying, "gee, it would be nice for me to be able to write a Comet server in 99 lines of PHP that is capable of managing 60K concurrent connections and a rate of 15K messages/second with a maximum latency of 50ms?" Sorry, I'm a little grumpy today... -- Jonah H. Harris Blog: http://www.oracle-internals.com/