Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85588 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39448 invoked from network); 31 Mar 2015 14:40:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Mar 2015 14:40:19 -0000 Authentication-Results: pb1.pair.com header.from=rdlowrey@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rdlowrey@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.180 as permitted sender) X-PHP-List-Original-Sender: rdlowrey@gmail.com X-Host-Fingerprint: 209.85.223.180 mail-ie0-f180.google.com Received: from [209.85.223.180] ([209.85.223.180:36217] helo=mail-ie0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D3/00-39077-2D1BA155 for ; Tue, 31 Mar 2015 09:40:19 -0500 Received: by iedm5 with SMTP id m5so17482461ied.3 for ; Tue, 31 Mar 2015 07:40:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-type; bh=ExPD/3BR0IiY+2MOJwzrcmsOQxWv4quCVOgv+ary1P8=; b=QZXGH04vy7mEPFA5jwxRcbYxtLeTq5tv1+JcncGIckENENfyihaL5rRDdOPLl+Xurr B647U+saV/hYJDgV8cOvkirAwlqXsaiVzKEcUBAIjK27qvAQtlHmX4hhO+39q5ayjhhR IoIBsf5Du7pXsWg7J6NG/1+BzG8zNroZ29WuElDQYx5IUbR6lmuRvU+oApXMOAMXLllY VB+TyzqdgxRAzTG0ykBqUYqAxOypx+Gzr8I9Wgj/IJ2wNmKeOJ+YVi9K2CjAemgzIaci fV2On80GlJsHdmW0klVjzHy4Lwp8+cqVgC3XviIxnPrhGZuC9Cu6mVs04Zwc1vPdcmSa fKSg== X-Received: by 10.43.69.68 with SMTP id yb4mr67045724icb.96.1427812815720; Tue, 31 Mar 2015 07:40:15 -0700 (PDT) MIME-Version: 1.0 References: <551AAB20.6060100@luni.fr> In-Reply-To: <551AAB20.6060100@luni.fr> Date: Tue, 31 Mar 2015 14:40:15 +0000 Message-ID: To: =?UTF-8?Q?Gr=C3=A9gory_Planchat?= , internals@lists.php.net, Daniel Lowrey Content-Type: multipart/alternative; boundary=bcaec51b1be9affb4a0512969309 Subject: Re: HTTP/2 and Websocket support in 7.x versions From: rdlowrey@php.net (Daniel Lowrey) --bcaec51b1be9affb4a0512969309 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, Mar 31, 2015 at 10:11 AM Gr=C3=A9gory Planchat wr= ote: > Le 31/03/2015 15:56, Daniel Lowrey a =C3=A9crit : > > HTTP/2 is entirely outside the scope of the PHP web SAPI as it currentl= y > > exists. The protocol impacts the actual HTTP server and has nothing to = do > > with the SAPI runtime which is simply handed information about the HTTP > > request once the server parses it. The protocol used to communicate tho= se > > details between the client and the HTTP server does not concern the web > > SAPI. There is no need for any sort of "support for h2" in PHP; it's th= e > > web server's concern. Apache and nginx will add support for h2 and PHP > will > > continue working as it always has. > > > > That said, the php web SAPI derives exceedingly little benefit from the > > advent of HTTP/2.0. h2 is designed to allow multiplexing of many reques= ts > > over the same TCP connection but the PHP web SAPI still has the same > > bottleneck it had before h2: one thread/process per request. > > > > As for websockets, you *can* do that using the web SAPI right now if yo= u > > wished but this would be inadvisable because long-lived connections wil= l > > quickly fill the bottleneck in every PHP web application (concurrent > > threads/processes for each "request"). > > > > Instead, the appropriate solution for websockets would be to implement = a > > socket server directly in the CLI that speaks the websocket protocol. > > > > Would it be useful to have raw incremental parsing functionality for > > HTTP/1.1, HTTP/1.2 and websocket protocols available in userland? Sure, > but > > this falls more in the realm of an extension than anything else as few > > people are implementing full-blown http and websocket servers in the CL= I > > right now. > > > > Hi Daniel, > > Your message is focusing on the solution I can find today in the wild, > not about the need mys previous message was about, namely multiplexing > and message push. > > Anyway I'm aware of this and I understand your point, but why should'nt > we be able, natively, to exploit HTTP/2 enhancements, particurlarly > resources multiplexing and data push? > > Why woud we restrain to exploit 20 years old protocol features, > deliberately omitting new ones that are already implemented on other > platforms? > > Gr=C3=A9gory > You're right -- I was addressing the status quo. The issue here is this: the web SAPI is historically the most stable thing about PHP. Supporting things like message push and multiplexing would require a fundamental change in what the web SAPI is. You would have to junk the entire model and create something completely new. It wouldn't be PHP anymore because you couldn't use the thread/process per-request model; users could no longer rely on the ease and simplicity of every function call being a simple synchronous operation. This kind of major paradigm shift is something that couldn't remotely be considered for PHP7. Even if it were possible you have to consider the web SAPI's target demographic. This demographic knows nothing about non-blocking IO and multitasking. I used to be a proponent of integrating things like this directly into the core of PHP. However I no longer consider this to be a good idea. Why? Because all of the functionality needed to implement these things yourself is available in extensions *right now.* I've personally worked on a closed-source userland non-blocking HTTP+websocket server over the last couple of years that clears 80,000 requests per second with 10,000 simultaneous clients running PHP7 on a single box with an i2600K cpu. Instead of massively changing the fundamental nature of the PHP web SAPI I believe we should focus on improving PHP as a language and not a web framework. By doing so we make it increasingly possible to implement things like this directly in userland with good performance. This can be accomplished right now by simply focusing on extension development (like php-uv which you mentioned and I've contributed to myself). Would I personally prefer to re-implement everything in PHP on top of libuv and bake non-blocking and threaded concurrency directly into the language with async functions and promises? Absolutely. But you're talking about a massive amount of work here. In standard internet parlance ... ain't no one got time for that. --bcaec51b1be9affb4a0512969309--