Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47706 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28955 invoked from network); 1 Apr 2010 17:59:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Apr 2010 17:59:18 -0000 Authentication-Results: pb1.pair.com header.from=jonah.harris@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=jonah.harris@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: jonah.harris@gmail.com X-Host-Fingerprint: 209.85.160.170 mail-gy0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:51681] helo=mail-gy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9A/62-16887-4FED4BB4 for ; Thu, 01 Apr 2010 12:59:16 -0500 Received: by gyf2 with SMTP id 2so581432gyf.29 for ; Thu, 01 Apr 2010 10:59:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:received:message-id:subject:from:to:cc:content-type; bh=Hs/u0STII1lT7UmgSGj42m4HdzmCJmVLnW4pcbqrSdo=; b=xA/FVWIDXTpZwZ9dMcJtAKTbuXEKzoR1sgGhJFnksXfsIAAN5URvUD5yGDaufc/6Ix JtYUwRh3IwDG1aznehLE8tmjoe0mnDcOQdo0cb1VC/3cXF770FQgDvi5y77hetw3RTUd dBbdIyoIWmYctRbmZ/2S4RvECu2V3rkEe3/JY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=MGUXYza51N5lBKbDg9dTYtAmn4jyFmSLaNESwE2rzcKaVQa3AKa5E9nI1H78P8OVZD P2pJ31oNXrz1FuoL1Cn7716zyj4NnhJfSQaGK6eV75NhoLHkiA6+Fuu3HaOw2POpeE40 XKdAutchG8tpiy0K5/uIuNZUM1/KabaXngSYY= MIME-Version: 1.0 Received: by 10.90.94.19 with HTTP; Thu, 1 Apr 2010 10:59:10 -0700 (PDT) In-Reply-To: <537889361.20100401192706@gmail.com> References: <1941231697.20100401163215@gmail.com> <4BB4BA13.2070706@lerdorf.com> <19610230188.20100401180311@gmail.com> <4BB4C6D5.7030004@lerdorf.com> <537889361.20100401192706@gmail.com> Date: Thu, 1 Apr 2010 13:29:10 -0430 Received: by 10.90.3.5 with SMTP id 5mr2110877agc.41.1270144750678; Thu, 01 Apr 2010 10:59:10 -0700 (PDT) Message-ID: To: speedy Cc: Rasmus Lerdorf , PHP Developers Mailing List Content-Type: multipart/alternative; boundary=00163630faafae992b0483309e32 Subject: Re: [PHP-DEV] php and multithreading (additional arguments) From: jonah.harris@gmail.com ("Jonah H. Harris") --00163630faafae992b0483309e32 Content-Type: text/plain; charset=ISO-8859-1 On Thu, Apr 1, 2010 at 12:57 PM, speedy 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/ --00163630faafae992b0483309e32--