Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114008 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 23991 invoked from network); 9 Apr 2021 16:48:09 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Apr 2021 16:48:09 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5B0BF1801FD for ; Fri, 9 Apr 2021 09:47:57 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.9 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_KAM_HTML_FONT_INVALID autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 9 Apr 2021 09:47:57 -0700 (PDT) Received: by mail-ej1-f49.google.com with SMTP id e14so9657170ejz.11 for ; Fri, 09 Apr 2021 09:47:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=//AfgFNVgRtGcT/P2T+TTjuIB21ajCpF98uZfw5J0GU=; b=l98RfjSOnCGoUK/LnlBnvFGvboJo7Ce6HSuEwKy4uXyls+xHJtU2nZIZSu906xjjsu qzjAE73k9LMDLeULNPOYolSOrbfoVhRnKgHN0brzPlkPiREsTDxZHCVo3igRAIqlVrjz JzQeQTDiAtroQja+VKq0eUbxK59dreivWcq4iZETHnziPUzvbg+Fj9q7jgL9pWuVk32s 7r/SrO+lJaJs8w6y6naU6CJuYtogQP01tlizCiwl6anSTny6qm18mOMW9ZFjnNMcO59m Z0S3zNiQou3tSBVvofbtK3d5YCUQh8KOwUUEDfCy9HgMuOJ0Nou4i/NEmTZGiNCxilx9 X6cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=//AfgFNVgRtGcT/P2T+TTjuIB21ajCpF98uZfw5J0GU=; b=c9FYTJFMqg0WriWmbnoutKVsiDYXc1nTjGN90lrrgZ0GF733KNlMj2Rb9xw4Xt0z7w A+E0ckasSPrgSCJPiwEus8FDRdVJfmbZPRwC1mgxm+B4uB0cXnV/xeyzB6ldp8VnsKbZ xjVtINFXXinb5fTjUuM1n4MiPNuIBsErzQUpJKKTWMJ83+upucXuV8JmD81hQj9T+9NK 74ave662QrOzuMyVe5uaUj247DlCXDT3ZGS+p05EIyvizhyZCyv/s7yUiQ4S1Z1JOK5z oSbl7Ixjm2eTSF62OZBGmQT5Tt8R0lstB7HIHKJUzDNqBo9XSJMZnC/vvgHsbvgCcr5r gEyA== X-Gm-Message-State: AOAM532Nb2UsM2lOA9us/SHfoOLo0M6on07vWX3iNhJPUcxpRCQ/gnS4 2pcJEPr1Aip7w3nPWkdxgpU+IajL4ZLG0xOwk6zNHz/5lxGMBAfN X-Google-Smtp-Source: ABdhPJzdT7A3mhu5HJEO+Pw5x92zUaCQcKXwmrtkwC+RM7HHam34fCGYTqlRdABhCQ/BOiXa1XTvWY4K/gWvsct4Iig= X-Received: by 2002:a17:907:213a:: with SMTP id qo26mr16682152ejb.547.1617986873859; Fri, 09 Apr 2021 09:47:53 -0700 (PDT) MIME-Version: 1.0 Date: Fri, 9 Apr 2021 21:17:42 +0430 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000de220205bf8cec77" Subject: FPM: Three-Phase running idea for faster frameworks From: bluemmb22@gmail.com (Mohammad Eftekhari) --000000000000de220205bf8cec77 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi and thanks for the latest great features. Idea visualized: https://drive.google.com/file/d/1twuCTk2ssNl5damTydP-aOmOeJ5hWr9r/view?usp= =3Dsharing This is an idea and it's simple on the paper: *To run the requests coming to PHP Frameworks in three phases. * Let's say FPM pool child processes can run PHP instances in two-phase: - Initialization Phase: It runs an instance of our PHP code with no request information given. The running PHP code is interrupted by some k= ind of input mechanism which is put deliberately by the developer into the code. FPM will keep this process on RAM waiting for a request to come in= . - *Waiting Phase* - Running Phase: There are a bunch of code instances in the waiting phase, one of them should be given the request to handle and respond back. Now this will give us the ability to write codes or frameworks that run faster. Let=E2=80=99s say that Laravel (any PHP project or framework) works= like this: - It loads all its dependencies, providers, routes, configs and creates a connection to the database and the cache systems and any other have-to-r= un things which are necessary to handle a request - Then it waits for the request by simply putting something like a =E2=80=9Cfgets(STDIN)=E2=80=9D *( any mechanism proposed by FPM )* - When input/request is given in some format, it continues running, handles the request, and responds back With this approach, we can remove the part of the time that PHP spends on Initializing frameworks for every single request and improve response times= . I think that having *Opcache + Preloading Files + This Proposal* can significantly improve frameworks response times. The benefit of this approach over Ratchet, Fiber, or other RealTime works, is that it doesn't depend on PHP's memory handling problems so that can be used in production with more confidence. Please let me hear your feedback, thanks. Best wishes, Mohammad Eftekhari --000000000000de220205bf8cec77--