Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122040 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 100 invoked from network); 25 Dec 2023 19:14:11 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Dec 2023 19:14:11 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 42DC218004E for ; Mon, 25 Dec 2023 11:14:35 -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-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) (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:14:34 -0800 (PST) Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-67f9ace0006so18483996d6.0 for ; Mon, 25 Dec 2023 11:14:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunglas-fr.20230601.gappssmtp.com; s=20230601; t=1703531649; x=1704136449; 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=zNl6z7W9sj8TRIzsE74LrjwdyB+c77uoyMlE5i3O6eY=; b=nJ6EpTqX4dNa65TLQxYy6G8BtsoZN/JHcsXtz7a+Z6ApFr3UHX4d86yYLsdQK7x13a 7OFlTC05XTMEtEPiTWN9TJ/CXWKicTj8eP+qGk4ig/t9ORLScSewg7B4N6nqN+BEG9dS L8WoAGzJjvpFk/uyA3OhX1advo0FAJ4XyzMq31UUifybbViyCdvgy8/gO/kfAkhsWGHh Djv6e23Z3VoqoLjyGPIdLqNDcdp/+94UpZ5gzI53z75eKbW/HXR04F8gQcMBj4ooF3dL T833Kqo34f6RZp4nRnfX5JiagQ1lyxtJZa993HuqIfsBGdUAKwLCyvY9EE48WP+Mi+yn HxWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703531649; x=1704136449; 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=zNl6z7W9sj8TRIzsE74LrjwdyB+c77uoyMlE5i3O6eY=; b=UlOS7RTW0xm5sQvLbLDauonhmbwwOQNJjnk92WPOLYPPZAMG21ZPFnmO2rKlpszAnq x2XMhZYl1K+puFewGUuVHspfBfJJND8iKgWPAl6i4o0OYiI5mFLuuSwDxzCjmXlPW0Eo YEHIUpOZSNiQgUp4CT6/FRfSHR/m+/OWG/8NxAcWEMW1o9Tn2agAvqb9SGsRT99dBUTO leVufmtTcq5SqIba+UD65zR3UHnBDeO3XnEi8k2vqU6uGdBtlJE+jF/cmHgzB3tehY9a pY8IfYYIQUwBvTB/v1lKxtF3T0CNX83kbQa3N3M+LmJ08XMDWmYOpCuzCBFq1O8iKpME GSBA== X-Gm-Message-State: AOJu0YzXRUyWUBFjpvy4XcZ+/2ubMdI0MFaKbYJa1/x/eFWv2Moctyi4 TFfy7pKQ3P88VyuzBSR3NTUB7GAR0U/inOc6a/pdvjaG4Ye/v1y6t4fCmoNF9Ec= X-Google-Smtp-Source: AGHT+IGqA/Jbi9FOBmpl+ni6ZC2nq+/LcYJ80yOZtySA9EEbqIgbnagJCRtM23hOB51qugqrbsv+h/U4GKJn+S37spQ= X-Received: by 2002:a05:6214:4a5d:b0:67f:b871:ff74 with SMTP id ph29-20020a0562144a5d00b0067fb871ff74mr3279251qvb.90.1703531649156; Mon, 25 Dec 2023 11:14:09 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 25 Dec 2023 20:13:58 +0100 Message-ID: To: Jordan LeDoux Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000cfdb4c060d5a5e5e" Subject: Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs From: kevin@dunglas.fr (=?UTF-8?Q?K=C3=A9vin_Dunglas?=) --000000000000cfdb4c060d5a5e5e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Dec 25, 2023 at 7:56=E2=80=AFPM Jordan LeDoux wrote: > > > On Mon, Dec 25, 2023 at 8:19=E2=80=AFAM K=C3=A9vin Dunglas wrote: > >> >> On Sun, Dec 24, 2023 at 10:44=E2=80=AFPM Jordan LeDoux >> wrote: >> >>> >>> >>> On Sat, Dec 23, 2023 at 12:34=E2=80=AFPM K=C3=A9vin Dunglas wrote: >>> >>>> Hello and Merry Christmas! >>>> >>>> One of the main features of FrankenPHP is its worker mode, which lets >>>> you >>>> keep a PHP application in memory to handle multiple HTTP requests. >>>> >>>> Worker modes are becoming increasingly popular in the PHP world. Symfo= ny >>>> (Runtime Component), Laravel (Octane), and many projects based on thes= e >>>> frameworks (API Platform, Sulu...) now support a worker mode. >>>> >>>> In addition to FrankenPHP, projects such as RoadRunner and Swoole >>>> provide >>>> engines supporting worker modes. >>>> >>>> According to benchmarks, worker modes can improve the performance of P= HP >>>> applications by up to 15 times. >>>> In addition to FrankenPHP, which is basically a SAPI for Go's integrat= ed >>>> web server, a new generation of SAPIs is currently under development. >>>> Several SAPIs written in Rust (including one by the RoadRunner team) a= re >>>> currently under development. >>>> >>>> These SAPIs, along with existing SAPIs, could benefit from a shared >>>> infrastructure to build worker modes. >>>> >>>> >>>> >>>> The FrankenPHP code is written and should be easy to move around in PH= P >>>> itself, to enable other SAPIs to use it. >>>> >>>> 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 worke= r >>>> scripts that work with all SAPIs that rely on this new feature. >>>> >>>> SAPIs will still have to handle fetching requests from the web server >>>> and >>>> pausing the worker to wait for new requests (in FrankenPHP, we use >>>> GoRoutines for this, in Rust or C, other primitives will have to be >>>> used), >>>> but almost everything else could be shared. >>>> >>>> For reference, here's the FrankenPHP code I propose to integrate into >>>> libphp: >>>> https://github.com/dunglas/frankenphp/blob/main/frankenphp.c#L245 >>>> >>>> The public API is documented here: >>>> https://frankenphp.dev/docs/worker/#custom-apps >>>> >>>> I'd like to hear what the community thinks about this. Would you be >>>> interested in this functionality in PHP? Should I work on an RFC? >>>> >>>> If there's interest, I can work on a patch. >>>> >>>> Cheers, >>>> -- >>>> K=C3=A9vin Dunglas >>>> >>> >>> Much like Larry, I'm curious what sort of scope you imagine for this. >>> Are you imagining something that is geared specifically towards HTTP >>> requests, or would this be a more generic "PHP Application Worker" that >>> might be spawned to handle other types of applications? Could we have a >>> worker listen to a specific port and respond to or handle all requests = on >>> that port/device? >>> >>> Jordan >>> >> >> Ho Jordan, >> >> Yes, the scope I imagine is geared specifically towards HTTP requests. >> Something more generic than common primitives for SAPIs and a shared pub= lic >> API to handle HTTP requests with a long-running PHP worker script will b= e >> hard to do outside of SAPIs because they depend on a lot of external >> concerns such as the programming language the SAPI is using. >> > > So you want to introduce a SAPI that doesn't work with any of the existin= g > HTTP solutions people use that only supports HTTP requests? Or am I > misunderstanding something? > > This sounds a bit like you want to merge in a tool that is designed for > your personal product directly into core. FrankenPHP may be incredible an= d > awesome, but the world runs on Apache and Nginx for HTTP requests. > > Jordan > As explained in the initial message and in my reply to Jakub, the main targets are emerging SAPIs. We have no interest (quite the contrary) in moving this code from FrankenPHP to PHP core (harder maintenance, slower iterations as more collaboration will be involved...), but I do think that having a "standard" and shared infrastructure and API for worker modes between new generation SAPIs will be beneficial to the community as a whole (no need - as at present - to write a different worker script for each engine having a worker mode, sharing of optimizations, security patches etc...). We're talking roughly about a C function of a few dozen lines, not something very big. --000000000000cfdb4c060d5a5e5e--