Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108244 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 16248 invoked from network); 25 Jan 2020 20:41:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Jan 2020 20:41:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D52731804CF for ; Sat, 25 Jan 2020 10:51:17 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NUMERIC_HTTP_ADDR, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,WEIRD_PORT autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 25 Jan 2020 10:51:17 -0800 (PST) Received: by mail-oi1-f175.google.com with SMTP id p125so2877069oif.10 for ; Sat, 25 Jan 2020 10:51:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9AKkeMFLctlh+Jdr5t1zglX824c4mR8zlJIC2NtcMco=; b=K+OiL4mnMvTlZKUx15ZU1J0MPLXj8q9diVSckEW556m7jiAn6LrlB7C5cSjdAcNm8O Ft7ADiKha+wSOPT51mhOm/6X0N7oaTky3Htcj7jkRSBKit6n+897BhF6YONI8g1eI/nf 7b1XkjYp0j+HJIH2BU0WTyEgTpUG5NldD6egRa0hfVAfD5b2KS8mMRZDr9x0Dy1ivFsG WGnp5yg0wPt4iyWKl8r02rNkwvjpgYX4x8jpNAcaPmL4Xe8IZfULMyi1EtjBZlTd3pxM bAEHhmCOhn/2klnqHBdG3dtn2oZ3l1iGnVtsimh2L/G/ma7ftSJcGQrDPa7hEW6sRCBy S0dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9AKkeMFLctlh+Jdr5t1zglX824c4mR8zlJIC2NtcMco=; b=AUAeXdzQcxGu1UVM1pgwHGFjtKzaDiCmWzMO3DpWHLVlcibnOxglEDuBtxb85J6pzQ TOyy/EvBbICcUO03g75u7sv0ukPFKfSUwdX//E0A2ueHTT7+6DYTOF2ejHVchWljeUlm 7U6EYw1/7x0Bm6Buegk38l5pcMPh2Hw9MtFSXZyJdfrJ1mtH+RKUst+RnDvuocoL6fJe dVqUQF4zknqCYA5ZNQ0zfUgr2qCx/7n4WTUrhk8VZgfT11LG77DdEjmUoTIpX+4N8981 ZirHcwY1YVoy6NHXiDTj90zjJHbC5V3F4RTCfb4a0h3WakDxyIKuTmlO+0FdviZdKjuu opWQ== X-Gm-Message-State: APjAAAWhO9eFrhubitpCp/76AHOHI6dtRw+rJRObN4o+MKRcA6QJFPC2 KnqJdsIA8sPksVZ2FZM3XenaPlKyjb7JXPDO+5U= X-Google-Smtp-Source: APXvYqxDvKG4SJgYCjDTUlj3TYDLZxsnCz4Pcqcr5scjZjx9Ff/Jb8e0glym+Ku5u5LIMvBUGfNtBc0GIeivk3KqAPU= X-Received: by 2002:aca:5490:: with SMTP id i138mr3132002oib.34.1579978275846; Sat, 25 Jan 2020 10:51:15 -0800 (PST) MIME-Version: 1.0 References: <3ca6d665-1a4f-8f7a-c82a-2e899f2e8df1@gmail.com> In-Reply-To: <3ca6d665-1a4f-8f7a-c82a-2e899f2e8df1@gmail.com> Date: Sat, 25 Jan 2020 18:51:03 +0000 Message-ID: To: Rowan Tommins Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Add viable long running execution model to php 8 From: robehickman@gmail.com (Robert Hickman) Hi Rowan > Could you share some more thoughts on what you are thinking of here? I'm > guessing you're thinking along the lines of an "event-based" system, > where each request is a function call, rather than a whole script > invocation? Yes that is what I was thinking, for example there is a userspace implementation 'Swoole' that works in the following way, ReactPHP is similar although I won't include that example as well. ------------------------- on("start", function ($server) { echo "Swoole http server is started at http://127.0.0.1:9501\n"; }); $http->on("request", function ($request, $response) { $response->header("Content-Type", "text/plain"); $response->end("Hello World\n"); }); $http->start(); ------------------------- > PHP is sometimes described as having a "shared nothing" architecture - > everything is wiped out at the end of each requests - so perhaps one way > to look at this is to propose a "shared something" version. > > The first question is _what_ we want to share. We already have sharing > of compiled code, with OpCache bundled since 5.5, and the pre-loading > feature in 7.4 could make autoloading redundant for many applications. > What we can't share natively is any data structures, resources like > database connections, or other global state like set_error_handler. The concept of a shared nothing architecture is a great basis for designing scaleable systems, and it does reduce/eliminate some types of bugs. However it may be better to approach this at a conceptual level instead of enforcing it with the design of the language. In my mind right now, everything should be shareable within a single process, as one could do in the Swoole example above, nothing stopping you defining a global in that script that could cache data in-process. NodeJS, Python (wsgi) and others work fine using this model and allow sharing of data within the same process. Trying to limit it to only some types of things would be more complex as each type of thing would end up having a different programmatic interface. Changing the execution model would also allow PHP to natively handle web-sockets natively without 3rd party implementations, which are all based around long running processes. I got the following from the Swoole docs: ------------------------- on('open', function($server, $req) { echo "connection open: {$req->fd}\n"; }); $server->on('message', function($server, $frame) { echo "received message: {$frame->data}\n"; $server->push($frame->fd, json_encode(["hello", "world"])); }); $server->on('close', function($server, $fd) { echo "connection close: {$fd}\n"; }); $server->start();