Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122039 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 98503 invoked from network); 25 Dec 2023 19:06:29 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Dec 2023 19:06:29 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8BC60180053 for ; Mon, 25 Dec 2023 11:06:53 -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=-2.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,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-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (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 11:06:53 -0800 (PST) Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-67fdfed519dso14847616d6.2 for ; Mon, 25 Dec 2023 11:06:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunglas-fr.20230601.gappssmtp.com; s=20230601; t=1703531187; x=1704135987; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=19RY0N5ztOB24yPB+T154c7Q0xcOyXoklZTMhnfgZSQ=; b=QIRZeGgUIAQQ/iwrbUJWKoqD07Q3dJHBWgh4gtkBWVwPIvUrOmbrr6JaJeRqa/MWHc JymCB5zPY6rMGAzwr66iRAN+XeqUAt0ZTA+nY4rLFtfunYJWmWDZ5ZSXRVEspJTRu9um ckTksnbsnJMzX9hd6G/9iKumPocnrUKSUlvJBb20is6pCWDNJNZPeEFaCqFpNu9zgVJ4 OS2g64IAB1+I+HQ8yGliBGI26p1lS5qulnUQokXurFMH7Tjy0/wmQ7dJcKdo8zz4dZTj auJFyf88LXak7jB1JcPneLMqgyvLD2G3DqTngWptmHlOOXxjsEgdEFdRzRv07Ay6PlB2 5DTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703531187; x=1704135987; 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=19RY0N5ztOB24yPB+T154c7Q0xcOyXoklZTMhnfgZSQ=; b=cTIEdgLBFhi1T1bszsfajYs9/m0B+4SztuFg2bS6RXC8je517MODPrS+c4KDf6kQCV 0/fW3OU4UKMHPX9FJEAxDVq3EePD/iJPFVlSMs589ZAWH5X1bz/DnhcWosdVTx9bNLbf CE+I1oLqCdFKCOvgLcMpNXzKz3nX4sLcJ7qgMADsQfkt+nXsP8Pf8wazT60O4PBThRgo CKDHVq7RSH16EfxuWKTwSU7qrmmN8cQcUUktx8JMcJscsCcuMwRBeQkKH1kz7a1Y90Be vBfYS3sfr4msIBvwUM2FcYVkY7OwocfNIPOw9Hf9s7xAy0w681mRnfWBC+rGTgX2tB+F bu+A== X-Gm-Message-State: AOJu0YwQwouoDfNl4a3EBn9iFB//p45/VGKTCsZqg4MG5iB9ytVJ+r7e Qg5uDyEcl8JO8J8K0G4rTOnTrFLuo6Y0zvyZkAnQFknEdKIO4XTwFL5qkru6 X-Google-Smtp-Source: AGHT+IFZ2MVp2zVS1h4h5ytCZIBse832tObr5/YegD+FjoFluVYtO1VXc/ijYBsDH3Qi+g9zF8P0ifbrl3Y/zNQTK1s= X-Received: by 2002:a05:6214:da1:b0:67a:9bf3:f616 with SMTP id h1-20020a0562140da100b0067a9bf3f616mr11430267qvh.29.1703531187073; Mon, 25 Dec 2023 11:06:27 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 25 Dec 2023 20:06:16 +0100 Message-ID: To: Jakub Zelenka Cc: Larry Garfield , php internals Content-Type: multipart/alternative; boundary="0000000000004502e1060d5a436c" Subject: Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs From: kevin@dunglas.fr (=?UTF-8?Q?K=C3=A9vin_Dunglas?=) --0000000000004502e1060d5a436c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Dec 25, 2023 at 6:30=E2=80=AFPM Jakub Zelenka wrote= : > > > 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 - = be >> enhanced to add a worker mode operating as described in the FrankenPHP d= oc >> 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 resource= s > 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 wi= ll > be similar issues for Apache prefork which is likely the most used MPM fo= r > 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 = my >> 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 >> adding >> the primitives to libphp, then we'll see how to exploit them (and whethe= r >> it's worthwhile) in the built-in SAPIs. >> > > The problem with this is that we would add some code that won't be used b= y > 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 no= t > 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_header= s. > I think otherwise you would need some hooking mechanism that should have > some default (which would probably just throw exception) because it is no= t > 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 oth= er >> possibilities offered by modern SAPIs like FrankenPHP are more important >> (better deployment experience as you have a single static binary or Dock= er >> image, Early Hints support, high-quality native HTTP/3 server etc) >> >> > Except that those are all threaded SAPIs so they offer less separation an= d > protection against application crashes in addition to the fact that threa= d > 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 stic= k > with process separation model. > > Cheers > > Jakub > Sure, the main targets are new SAPIs like FrankenPHP and the one in Rust developed by the RoadRunner team. I thought it was clear in my previous messages but I'll be glad to make it bold in the RFC. Automated tests (likely through a test SAPI) will definitely be needed. Throwing if the current SAPI doesn't support (yet) the new userland function looks sensitive. Couldn't this shared code be put in "main", as it could (theoretically, I agree that it will be hard to do for existing core SAPIs) be used by all SAPIs? --0000000000004502e1060d5a436c--