Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122037 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 92273 invoked from network); 25 Dec 2023 17:30:36 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Dec 2023 17:30:36 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7214018004E for ; Mon, 25 Dec 2023 09:31:00 -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=-0.9 required=5.0 tests=BAYES_00,DMARC_MISSING, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, 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-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (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 ; Mon, 25 Dec 2023 09:30:59 -0800 (PST) Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-55517259e31so28037a12.0 for ; Mon, 25 Dec 2023 09:30:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703525433; x=1704130233; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IRjuLnP2oePnTBEa9eA4SPW01A0aK7Mk7KEVVNcEv+0=; b=TTFDDRDwjqnqzwlC/+0qHwkG8rFrR/ct7APtko7IA0O7Q02kLcjxcql2uwzL9tmmT+ 78gRTe/5Tj6jl6k2rzp4I3S0QTzE/1mYsjSgFj4Ympx7bsQDvcNgAByK7J8EOIqA1KWd YqM6WBoWYKGLC3x8TCnN0KHiLmliwfKgMU39OoY5z7bHuKlzzAa3gV/KU/sQ2mWSW2NA n1TC9iDsLrQ4iLLx2FCBAOryy5dR2GpmQ4c0N5hyWiqQE3KGnn+XntoGFCTERnXm/h+o vbbG1z4Ox2y4xle+1tZsTTr0lQ5lhpKxk5Rgng28JbPYpDBycxtaYdWCObCJv0BYqk5j q+JA== X-Gm-Message-State: AOJu0Yy4CVhctIlDtnmlEZWG7Oq4L3OnNGfgu4kxKNVb5SQoqfPD5bGc UUYXi1A82EuguSHO5KWQy1f7dbNrVA1zOstPVzdCP0Jh0kg= X-Google-Smtp-Source: AGHT+IGceJRNbD5fdxCbPOzrVOutlwdMmmfgJC62YsQ04SV2h07SVV3YPLsu74KaNYq/VS4YSpv4NMIYot76yMW8FEs= X-Received: by 2002:a50:aa9b:0:b0:553:a3ec:85fc with SMTP id q27-20020a50aa9b000000b00553a3ec85fcmr4718139edc.12.1703525433272; Mon, 25 Dec 2023 09:30:33 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 25 Dec 2023 17:30:22 +0000 Message-ID: To: =?UTF-8?Q?K=C3=A9vin_Dunglas?= Cc: Larry Garfield , php internals Content-Type: multipart/alternative; boundary="00000000000050ec74060d58ecfa" Subject: Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs From: bukka@php.net (Jakub Zelenka) --00000000000050ec74060d58ecfa Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Dec 25, 2023 at 12:34=E2=80=AFPM K=C3=A9vin Dunglas wrote: > On Sun, Dec 24, 2023 at 4:21=E2=80=AFPM Larry Garfield > wrote: > > In practice, I want to understand the implications for user-space code. > > Does this mean FPM could be configured in a way to execute a file like > that > > shown in the docs page above? Or would it only work with third party > SAPIs > > like FrankenPHP? > > > In theory, PHP-FPM and the Apache module could - like all other SAPIs - b= e > enhanced to add a worker mode operating as described in the FrankenPHP do= c > thanks to these new primitives. > I have been thinking about something similar for FPM and if you had some sort pool manager process, you could maybe do some sort of initial execution but then it gets really tricky especially with sharing resources and managing connections. I think it would be a big can of worms so I don't think this is going to happen anytime soon. I could imaging that there will be similar issues for Apache prefork which is likely the most used MPM for legacy apps. Effectively it means that this function won't be working on most installations as two of the likely most used SAPI's won't support it. I think it should be pretty clear from the beginning. > However, I suggest doing this as a second step, because as described in m= y > first post, it will still be the responsibility of each SAPI to manage > long-running processes and communication with them. This is simple to do > with Go's GoRoutine and Rust's asynchronous runtimes such as Tokio, it's > definitely more difficult in cross-platform C. I suggest starting by addi= ng > the primitives to libphp, then we'll see how to exploit them (and whether > it's worthwhile) in the built-in SAPIs. > The problem with this is that we would add some code that won't be used by any of the built in SAPI which means that that we won't be able to have automated tests for this. So the minimum should be to have at least one core SAPI supporting this new functionality. I wouldn't mind if it's just a SAPI for testing purpose which might be actually useful for testing embed SAPI code. I think that should be a requirement for accepting a PR introducing this. It would be also good to put together some base design PR for this as currently SAPI common functions are implemented separately in each SAPI (e.g. apache_request_headers). From the linked functionality, it is is not a big amount of code and seems somehow specific to the FrankenPHP so why couldn't each SAPI just implement this function separately? I know that this is not ideal but it's what is already used for apache_request_headers. I think otherwise you would need some hooking mechanism that should have some default (which would probably just throw exception) because it is not going to be implemented by all SAPI's. I think it would be really good if you could provide more details about planned implementation for this. > I personally have less interest in working on FPM/CGI/mod_php as the othe= r > possibilities offered by modern SAPIs like FrankenPHP are more important > (better deployment experience as you have a single static binary or Docke= r > image, Early Hints support, high-quality native HTTP/3 server etc) > > Except that those are all threaded SAPIs so they offer less separation and protection against application crashes in addition to the fact that thread management in PHP still has got its own issues. They are certainly some advantages especially for thin services but if you have huge monolith codebase like some big CMS and other projects, then I would probably stick with process separation model. Cheers Jakub --00000000000050ec74060d58ecfa--