Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122034 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 83651 invoked from network); 25 Dec 2023 16:19:12 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Dec 2023 16:19:12 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7803018004F for ; Mon, 25 Dec 2023 08:19:36 -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-f48.google.com (mail-qv1-f48.google.com [209.85.219.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 ; Mon, 25 Dec 2023 08:19:35 -0800 (PST) Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-67f9ace0006so17836236d6.0 for ; Mon, 25 Dec 2023 08:19:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunglas-fr.20230601.gappssmtp.com; s=20230601; t=1703521150; x=1704125950; 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=o8+JODRxVaDhe9tNr7iZcvz4kbsiprszFgbDpt+DRPw=; b=IOTHsx+9gCushfBSDRRlQQTgUSNjRY6d+B4tQo9V9ZpLWGioqQhxRJSj/ovyCfQvf3 PTvl+YbHx3ZsdQgsETQHfrjDBmhO1BoC/ypWkU5/XLiy3rkoKmdbA/rRiB9ieh9UIgk6 dtT/duRXXyad16QD11xzHxltFQsvgni/L7P+q/sgaz8TRNmCr3Cp102KM08GP6f49P// E9Z4jSt/1C0iQx4/auhTaHQVns93h80WjeJRjjuUTPMnOi+m3cDWgY3kB2VwA01Y9SPA PMxruNUtz6O8qe2wwJ5yp10GzCBVzFI3NepAdgi/Ao2/cTiJG5voRek20ppHwgc9m45G 2lGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703521150; x=1704125950; 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=o8+JODRxVaDhe9tNr7iZcvz4kbsiprszFgbDpt+DRPw=; b=Y+k22+hYuJ5GBeWYsc2Teo9mU+uSew1gbTiPujgHSsV4UmYyUP5hG2KB7/9U+HquyM To6vmt9W9GRSzBTYvOProjLkRX6VDdg0IDDeSs7Z4HzNKDl/xcEgEETHjNXrh47UX617 kyVXpR5TkSmElnNR7rvSZMONTwvxsp0sXps3QKTfgOudGmdRrAjTRlRZ1v/qtyNwO9jc dqOkg4SSFcjM/cpZIObH4vigBwYwoamY+o4DHXePINI97ye/TIQh6QgEjv59ZRRDIXLE zifIgSu8HTKEdfo/0Q5smjO4uUClJHZNzblCd87Bf/iIfPCv8GKu3GvZ5k6kOWut32Vi YTcA== X-Gm-Message-State: AOJu0YxwqIvlBJyXhsbUMJfejz08kF1hqTostd1aOFN3vLTlA1ClAWiA mcGoCr0QUSOg/SrIxNAkjE9ur8YJo0Q8+H81Ih7K3Zst5O2SH7FHKR1J4JqNAfQ= X-Google-Smtp-Source: AGHT+IE0MvL41IUcbbgN3v1OaC+zeBJsTdzkLVdYyGEh1ddvqSLP0OEUz18QSprD8gR50ss3Ug289o3OEEgkn5uuG50= X-Received: by 2002:a0c:f988:0:b0:67f:ba7b:86fa with SMTP id t8-20020a0cf988000000b0067fba7b86famr3486275qvn.122.1703521150269; Mon, 25 Dec 2023 08:19:10 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 25 Dec 2023 17:18:59 +0100 Message-ID: To: Jordan LeDoux Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000078c48060d57ed9a" Subject: Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs From: kevin@dunglas.fr (=?UTF-8?Q?K=C3=A9vin_Dunglas?=) --000000000000078c48060d57ed9a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 yo= u >> keep a PHP application in memory to handle multiple HTTP requests. >> >> Worker modes are becoming increasingly popular in the PHP world. Symfony >> (Runtime Component), Laravel (Octane), and many projects based on these >> frameworks (API Platform, Sulu...) now support a worker mode. >> >> In addition to FrankenPHP, projects such as RoadRunner and Swoole provid= e >> engines supporting worker modes. >> >> According to benchmarks, worker modes can improve the performance of PHP >> applications by up to 15 times. >> In addition to FrankenPHP, which is basically a SAPI for Go's integrated >> web server, a new generation of SAPIs is currently under development. >> Several SAPIs written in Rust (including one by the RoadRunner team) are >> 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 PHP >> 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 worke= r >> 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. >> >> SAPIs will still have to handle fetching requests from the web server an= d >> 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#L24= 5 >> >> 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 public API to handle HTTP requests with a long-running PHP worker script will be hard to do outside of SAPIs because they depend on a lot of external concerns such as the programming language the SAPI is using. --000000000000078c48060d57ed9a--