Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122061 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 25714 invoked from network); 29 Dec 2023 19:14:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Dec 2023 19:14:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 79D00180059 for ; Fri, 29 Dec 2023 11:15:01 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 29 Dec 2023 11:15:00 -0800 (PST) Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-40d5b159350so30455355e9.2 for ; Fri, 29 Dec 2023 11:14:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703877272; x=1704482072; darn=lists.php.net; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=X0yEgpknL5xkGzr9PKCpi3v0AUflQ6n12dxna38uxFY=; b=Q3KgLyaAVEtxDxY2mWGMwMi//Ny7rLWQZqIge0Av6JMizNZwG9rof+X+B94ou/1E+1 NAw+ZeFNKEoVy35loeW6JfZtq4tYSlKvlC7ADvRcTZ7u706SA0k7u66aaYkzbOS6WUgz VhRe8H5hmLHi0kkiyVAh2meGdSptSNiugx3UMa3m0g3xXxzUL7ZnePuoXfxV9Gk8VBRC hYcaTo4mdZNB4TSvGxtKs5nV+1x2g4/4khtD8/SVK+9wNieiLLGv2Wks0STpJ+t4gy0B AN3/R88hOFYXEmMpdoGjW3E9quR7wee2Endx98MUUpWmvv92d98VYQtnpLd86RzUYQhv hKpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703877272; x=1704482072; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=X0yEgpknL5xkGzr9PKCpi3v0AUflQ6n12dxna38uxFY=; b=E8r0pjHzakgsK/pBb2c3r+XSZLPitIZLk7DiGY2jxtngxsFoRNXJI3f/WZesgEXZjx fMqnBoAmH24aY5flYVSD+4/CLJPLuVqKyiJZkl/ti61oxdSojZ6H6zWo+u6/7zk2BpZY UTYxY6tOVyT+lzaZTA8jen+jKi9Ef43v2Sk7eFhaAMydPswPg6XcDssH/0sZZwDJTAHd JskJKioehJgFYbMWSNIYrvikct+RNeD+AwxSGF0/Tjn3uXOdBTnm9+PO0wzgnI191YsW alqOIYklQCQIYbzjBfsSWV7H/MMl5CDwr2aN4Srs2NWzR6PhxKFSzUKWmCkG5x+XqOMZ qKpQ== X-Gm-Message-State: AOJu0YwFyDQGKS6lzcJ8k6+EKdj0f3NeF7druSbqX1nqNIU8N8tnDUtA TwKFdNVqh/7gM7AlucBhspknI6yBC0A= X-Google-Smtp-Source: AGHT+IEmqMrS1K8oJp43/6XOCwO5DAX8veg0kfdsv3/pC14jO+79/LLAVktewJXh7jGiN0riA43pFA== X-Received: by 2002:a05:600c:46cf:b0:40d:81c0:9e5a with SMTP id q15-20020a05600c46cf00b0040d81c09e5amr80159wmo.137.1703877271760; Fri, 29 Dec 2023 11:14:31 -0800 (PST) Received: from [192.168.0.22] (cpc83311-brig21-2-0-cust191.3-3.cable.virginm.net. [86.20.40.192]) by smtp.googlemail.com with ESMTPSA id l15-20020a05600c4f0f00b0040d578a184bsm16363865wmq.22.2023.12.29.11.14.30 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Dec 2023 11:14:31 -0800 (PST) Content-Type: multipart/alternative; boundary="------------V0YC0qFBECltzOeUtFrJuEwA" Message-ID: <5060b986-2e5a-46e4-9c83-763e5b155e83@gmail.com> Date: Fri, 29 Dec 2023 19:14:30 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: internals@lists.php.net References: Content-Language: en-GB In-Reply-To: Subject: Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs From: rowan.collins@gmail.com (Rowan Tommins) --------------V0YC0qFBECltzOeUtFrJuEwA Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 23/12/2023 20:34, Kévin Dunglas wrote: > In addition to sharing code, maintenance, performance optimization, etc., > the existence of a common infrastructure would standardize the way worker > scripts are created and provide a high-level PHP API for writing worker > scripts that work with all SAPIs that rely on this new feature. While this seems like a noble aim, there doesn't seem to be much consensus on what such an API should look like; from what I can see: - FrankenPHP expects the user to manage the main event loop, repeatedly passing the server a function to be called once; it doesn't pass anything into or out of the userland handler, instead resetting global state to mimic a non-worker environment [https://frankenphp.dev/docs/worker/#custom-apps] - RoadRunner doesn't use a callback at all, instead providing methods to await a request and provide a response; it directly uses PSR-7 and PSR-17 objects [https://roadrunner.dev/docs/php-worker/current/en] - OpenSwoole manages the main loop itself, and uses lifecycle events to interface to userland code; the HTTP 'Request' event is passed custom Request and Response objects [https://openswoole.com/docs/modules/swoole-http-server-on-request] It also seems relevant to mention the situation in Python: - WSGI specifies a Python-level interface between a web server and a web application / framework. The server side is expected to provide the event loop (unlike in FrankenPHP), and passes the application an environment dictionary (based on CGI) and a start_response callback. [https://peps.python.org/pep-3333/] - The newer ASGI generalises this interface into an asynchronous event handling system, including support for WebSockets. [https://asgi.readthedocs.io/en/latest/introduction.html] Out of all of these, the FrankenPHP approach seems to be the most basic, providing good backwards compatibility with PHP's normal "shared nothing" approach, but not much forwards compatibility - I can't see how it would be adapted for an async PHP environment, or with WebSockets, for instance. I'm sceptical how many SAPIs would actually implement it, rather than providing more powerful APIs. Regards, -- Rowan Tommins [IMSoP] --------------V0YC0qFBECltzOeUtFrJuEwA--