Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82204 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1723 invoked from network); 9 Feb 2015 00:26:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Feb 2015 00:26:39 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.53 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.53 mail-wg0-f53.google.com Received: from [74.125.82.53] ([74.125.82.53:39974] helo=mail-wg0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2A/1F-26926-EBEF7D45 for ; Sun, 08 Feb 2015 19:26:39 -0500 Received: by mail-wg0-f53.google.com with SMTP id x13so3740240wgg.12 for ; Sun, 08 Feb 2015 16:26:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=QFoumn+wfm5HJBAqtBifZu0dQElV8xFL3FonlS/PzpM=; b=nMXzLWhs50fhvSQfLs27aIJe/ICSqFaoyligpxSUmiGHrSM1d2R6QQwLgIx7HJG0v8 PjdwembdYmOarlOD8mDKPOM8PFWHE+8QWQHk2sLZewDtkA2hLkPrljmICvXDqbq6OnRu ZPpzgK9AYiHwhh/xf5/doT47ixaZwIJAXRqqStBnJv4dYW+C04C23+lQaPN4XRBsYThR BKGNWTACcLgqa4sVI23ZdO+f60vDZ83ps4RHh7jBdcNmiAi5naC5byDYCpUAtjK0fEWk v4p/ZzX+myJ5VC2uxtioIewlGiVvR+Fj2wVLvwC8ZJnz7iSTB6qG6PHoWsfrCnClAZWV yndQ== X-Received: by 10.181.9.107 with SMTP id dr11mr30181871wid.40.1423441595127; Sun, 08 Feb 2015 16:26:35 -0800 (PST) Received: from [192.168.0.2] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by mx.google.com with ESMTPSA id r3sm12072434wic.10.2015.02.08.16.26.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Feb 2015 16:26:34 -0800 (PST) Message-ID: <54D7FEBA.1070304@gmail.com> Date: Mon, 09 Feb 2015 00:26:34 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: internals References: <54D7F5D5.4050808@gmail.com> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] uWSGI experimental plugin for implementing a WSGI/PSGI/Rack-like interface for PHP From: rowan.collins@gmail.com (Rowan Collins) On 09/02/2015 00:02, S.A.N wrote: > You're right, but there is no threading issues. > One worker synchronously execute requests, but may run parallel many workers. I'm not sure what you mean by this. I can see 3 ways of handling incoming web requests, as it affects PHP's threading: A) The current "shared nothing" model: the web server may have multiple processes or threads, but each requested is executed in a completely separate global scope of PHP. B) Each process or thread in the web server spawns an instance of the application; the application has a global state within that instance, and startup and shutdown code; the instance is sent multiple requests, but has no way to know if it is getting all the requests, half the requests, or one hundredth of the requests. C) The web server executes the application once, which sets up its global state, and then spawns an internal threading model; each request is sent to a worker thread within PHP, which has to synchronise with other threads in order to access any aspect of global state. I guess you are suggesting option (B), which is what I was referring to when I said that global state would be "arbitrarily shared" - if handling a particular request caused any global state to be changed, such as registering an error handler, it could affect anything from 0 to 100% of subsequent requests, depending on how the web server is configured. The code therefore needs to avoid relying on any such global state at all, which basically restricts you to a subset of the current language. For it to become the default way of running PHP, huge changes would be needed to adapt code to this new model. The reason I mentioned threading is that under option (C), migration becomes a bit easier in some ways: you can move some things which are currently global state into an explicitly per-thread state, allowing old behaviour to be emulated; and you can leave other things in synchronized global state, like ini settings, solving the problem of "50% of my threads have a different error handler registered". Regards, -- Rowan Collins [IMSoP]