Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122042 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 12615 invoked from network); 26 Dec 2023 00:29:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Dec 2023 00:29:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2896218004E for ; Mon, 25 Dec 2023 16:30:08 -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.1 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_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 16:30:07 -0800 (PST) Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a2370535060so905957666b.1 for ; Mon, 25 Dec 2023 16:29:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703550581; x=1704155381; 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=97nvvasgF8H94S2FNl/wzfa04o9XZwNZL92Fx/6eo6c=; b=NYMpFVnihCN6DXeiAmNwGqwq4flRY4+bX/0+I26LIahW6Rz3BqNSlEzl4SVrGyF8nm BdWa6mmam5mAlPZKdNqOQxxUbkKetV16ntm3FhMg2mhHLTHJYJ6eYd/dhksOCTFqEbuY Mrm2s1+Nmk/u6tgrO8mQ/xF6qawqJNLOejlk2iA2uFPqFjEhKxwcYaOs8lRIt0s3VnLB +ZuSunMhxyYg02CFayWGciMla/FhwWosJacLDYwqCh4JCwf6f5iiPQTKdlz2/Wsw9Nnd Ui6v+bqoyDMaSMf+/+6Kc9UzzUF17ByljbaynFEoL9YYicLsL9J8koY+/sP4hGNw1WvQ MZLg== X-Gm-Message-State: AOJu0Yw1QeO50BOQwNa76jvMcBovoPqwftD/YcVLIqKEU6Wwqw+Ohk8d ZDfRjqdFbbH+6wkrZ7ODLCXo30q6iA7rt992g/a55bie X-Google-Smtp-Source: AGHT+IHZ0IhKqG/trcwghI77YxoPDfIvhLcLj7q/Je86I1BQr396y4ZJw7fEWb+UW4quBY48i7Zg4RHfW3AjU16+GO0= X-Received: by 2002:a17:906:20dd:b0:a23:f17a:163c with SMTP id c29-20020a17090620dd00b00a23f17a163cmr5804232ejc.64.1703550580906; Mon, 25 Dec 2023 16:29:40 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 26 Dec 2023 00:29:29 +0000 Message-ID: To: =?UTF-8?Q?K=C3=A9vin_Dunglas?= Cc: Larry Garfield , php internals Content-Type: multipart/alternative; boundary="0000000000003b5f5d060d5ec728" Subject: Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs From: bukka@php.net (Jakub Zelenka) --0000000000003b5f5d060d5ec728 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Dec 25, 2023 at 7:06=E2=80=AFPM K=C3=A9vin Dunglas wrote: > > On Mon, Dec 25, 2023 at 6:30=E2=80=AFPM Jakub Zelenka wro= te: > >> >> >> 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 lik= e >>> 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 >>> doc >>> 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 resourc= es >> and managing connections. I think it would be a big can of worms so I do= n't >> think this is going to happen anytime soon. I could imaging that there w= ill >> be similar issues for Apache prefork which is likely the most used MPM f= or >> 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 i= t. >> 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 d= o >>> 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 wheth= er >>> 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 ha= ve >> 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 jus= t a >> SAPI for testing purpose which might be actually useful for testing embe= d >> 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 n= ot >> 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_heade= rs. >> I think otherwise you would need some hooking mechanism that should have >> some default (which would probably just throw exception) because it is n= ot >> going to be implemented by all SAPI's. I think it would be really good i= f >> you could provide more details about planned implementation for this. >> >> >>> I personally have less interest in working on FPM/CGI/mod_php as the >>> other >>> possibilities offered by modern SAPIs like FrankenPHP are more importan= t >>> (better deployment experience as you have a single static binary or >>> Docker >>> 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 certainl= y >> some advantages especially for thin services but if you have huge monoli= th >> codebase like some big CMS and other projects, then I would probably sti= ck >> 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. > The way how I read was that this would be eventually supported by all SAPIs which I think is not likely going to be the case. > 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. > > +1 > 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? > The main does not have a module but it could be probably added to standard ext like it's the case for other functionality related to main. Cheers Jakub --0000000000003b5f5d060d5ec728--