Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 11 17:43
    keywan-ghadami-oxid commented #539
  • Apr 01 17:02
    Jonas18175 opened #552
  • Mar 16 10:45
    andig closed #549
  • Mar 16 10:45
    andig commented #549
  • Mar 16 10:44

    andig on 2.4.0

    (compare)

  • Mar 16 10:01

    andig on andig-patch-1

    (compare)

  • Mar 16 10:00

    andig on master

    Upgrade fixer (#550) (compare)

  • Mar 16 10:00
    andig closed #550
  • Mar 16 05:30
    javaDeveloperKid commented #549
  • Mar 04 16:44
    javaDeveloperKid commented #549
  • Mar 04 16:38
    andig review_requested #550
  • Mar 04 16:38

    andig on master

    Fix trim(nil) deprecated causin… (compare)

  • Mar 04 16:38
    andig closed #551
  • Mar 04 16:19
    andig labeled #549
  • Mar 04 16:09
    javaDeveloperKid opened #551
  • Mar 04 16:00
    andig commented #549
  • Mar 04 15:51
    javaDeveloperKid commented #549
  • Mar 04 15:22
    andig commented #547
  • Mar 04 15:11
    javaDeveloperKid commented #549
  • Mar 04 15:10
    javaDeveloperKid commented #549
Matthieu Napoli
@mnapoli
Hi everyone! Here is very vague question that may be related to PHP-PM :) Since the "cons" listed in PHP-PM are, for example, memory management, would it be possible to implement a FCGI server (or something similar) based on forking PHP processes to save the cost of file inclusion/framework bootstrap? Here is the idea: a PHP script starts and runs the bootstrap (autoload classes, init framework, etc.). Then it goes in a loop where it listens to incoming requests. Each time a new request comes in, the process creates a fork -> the fork handles the request and dies, while the original script loops and handles new requests.
The pros:
  • vs PHP-FPM: we save the bootstrap time
  • vs PHP-PM: applications don't need to be adapted to better manage their memory/global state since the "one process per request/scratch everything" is kept
I'd love to hear what you think of that and if it's something you considered for PHP-PM, or if it's impossible.
Marc J. Schmidt
@marcj
The performance does not come from saving bootstrap time of declaring symbols, but from saving initializing those objects, loading config files, calling methods etc. Exampe: we tried resetting symfony's container
service container after each request: performance dropped to php-fpm speed
Matthieu Napoli
@mnapoli
ah sorry, by "bootstrap" I meant creating the container, parsing config files, pre-loading common services (event-dispatcher, maybe DB, etc.)
so I meant to do all that, and only then listen to incoming requests
so the bootstrap time is taken off the total response time
(autoloading of common files too would be avoided in the "response time")
Marc J. Schmidt
@marcj
yeah but then you have again memory issues in terms of the developer needs to be aware of having a service in memory over longer time
Matthieu Napoli
@mnapoli
but the services wouldn't do anything until the request comes in right?
Marc J. Schmidt
@marcj
yeah as right now in the current implementation
Matthieu Napoli
@mnapoli
OK I thought memory leaks were because the same process would handle many requests? Do you mean memory leaks happen if a process has just started (handled 0 request before) and is waiting for a request?
(by the way thanks a lot for answering those questions, it's been a very long time I wanted to find someone would could answer them :))
Marc J. Schmidt
@marcj
memory leaks only happen if the developer of a library/the application is not aware that the app is handling several request over linger time. php itself does t have issue with it
its completely user land related
you re welcome, i'm currently on the phone at a quite place xD
Matthieu Napoli
@mnapoli
right! OK then we are on the same page. And to me it seems like a big issue: it's hard to rewrite all frameworks, libraries and especially applications to work with PHP-PM. That's why I'm wondering if there's not a solution were we could keep the "1 process handles only 1 request" (so no memory issue/global shared) while also avoid bootstrap time in the response time
so the idea is basically let PHP scripts "do something" (bootstrap) before being made available to PHP-FPM (or any other handler)
Marc J. Schmidt
@marcj
one process = one request basically destroys the whole approach and the speed gain
and one process =one request is already what php-fpm is doing
Matthieu Napoli
@mnapoli
that's what I don't understand: the speed gain is due to the fact that we don't do the bootstrap of the application anymore right?
oh ok
now I'm lost again
I knew you could have one process = one request in PHP-PM but I thought it wasn't really the best setup, I need to re-read again the docs then
Marc J. Schmidt
@marcj
yeah the fact that all of your services are eager loaded, as in java for exame
Matthieu Napoli
@mnapoli
then I don't see where the memory leak is with PHP-PM if a process only handles one request
that's what you said above:
memory leaks only happen if the developer of a library/the application is not aware that the app is handling several request over linger time. php itself does t have issue with it
so if PHP-PM processes only handle 1 request no memory issue?
ahhhh nevermind!

and one process =one request is already what php-fpm is doing

I read that as php-pm

damn sorry!
Marc J. Schmidt
@marcj
php-pm itself has no memory leaks nor php has, but if your applications loads tons of services and never cleans up then you built memory leaks
Matthieu Napoli
@mnapoli
right
Marc J. Schmidt
@marcj
for example internal caches which could be useful for one process=one request use cases need to be resetted after each request in php-pm ( for example in the onTerminate event of symfony) but most user are not aware of this event
Matthieu Napoli
@mnapoli
yeah I definitely see what you mean
Marc J. Schmidt
@marcj
and thats how most memory leaks happen
Matthieu Napoli
@mnapoli

so do you think it would make sense to try to find a middleground between PHP-FPM and PHP-PM? Like this:

  • keep one process = one request (to simplify everything, avoid memory issues)
  • but keep the perf improvement by running the bootstrap before the process handles the request

?
I can see several options for how, but I want to make sure the premise is all right?

Marc J. Schmidt
@marcj
I tried hard but haven't found that golden way. the biggest improvement comes really when you work with php as you would with java where your whole apllication is in memory prepared waiting for incoming requests
Matthieu Napoli
@mnapoli
here are ideas, I have no idea if they are doable:
  1. add a new feature in PHP-FPM so that PHP scripts can be run when PHP processes are spawned, until a special instruction that signals to PHP-FPM that the process is now fully initialized and can be added to the pool of PHP processes (i.e. an inverse of fastcgi_finish_request(), maybe like fastcgi_request_ready()) -> PHP-FPM stops the process and waits for a request -> when a request comes in, PHP-FPM populates the global variables ($_GET, etc.) and resumes the execution of the PHP script right were it stopped
  2. implement a FCGI server (much like PHP-PM, that's why I'm asking you today) where the "LoadBalancer" process inits the framework, then loops for each incoming request -> on each request it forks -> the fork handles the request and then dies (1 process == 1 request), while the original process (LoadBalancer) waits for the next request
in both cases we keep one process == one request, but each process only handles 1 request so no memory issue (and we have the perf improvement because bootstrap is not part of the response time)
Matthieu Napoli
@mnapoli
I'm also wondering if there's a solution n°3 with pthreads, but I'll need to read more about that extension
Luke Rotherfield
@LRotherfield
Hi Guys, has anyone had any success running Oro Platform with php-pm?
Marc J. Schmidt
@marcj
@LRotherfield I don't think so
Luke Rotherfield
@LRotherfield
OK, fair enough, thanks for the response
kugu
@kugu

[www-data@sp-prod1 backend]$ composer.phar update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1

- php-pm/php-pm dev-master requires react/http dev-master#cd15204bd15d106d7832c680e4fb0ca0ce2f5e30 -> satisfiable by react/http[dev-master].
- php-pm/php-pm dev-master requires react/http dev-master#cd15204bd15d106d7832c680e4fb0ca0ce2f5e30 -> satisfiable by react/http[dev-master].
- Removal request for react/http == 9999999-dev
- Installation request for php-pm/php-pm dev-master -> satisfiable by php-pm/php-pm[dev-master].
kugu
@kugu
--- Worker 5501 stderr ---
PHP Fatal error: Class 'React\Http\RequestParser' not found in /git/backend.fb/vendor/php-pm/php-pm/React/RequestParser.php on line 8
Fatal Error: Class 'React\Http\RequestParser' not found in /git/backend.fb/vendor/php-pm/php-pm/React/RequestParser.php:8
part of the problem
current composer install/update - broken
Marc J. Schmidt
@marcj
yeah I guess they broke something