Baldinof / roadrunner-bundle

A RoadRunner worker integrated in your Symfony app
MIT License
255 stars 46 forks source link

phpfpm faster than roadrunner #143

Closed mpoiriert closed 3 weeks ago

mpoiriert commented 4 weeks ago

I am trying roadrunner for the first time.

I am using it via my docker local setup.

I have both phpfpm and roadrunner running.

When refreshing a page vai phpfpm the reponse time is about 35-40 ms (using profiler of symony) In roadrunner I sometime get 19ms (which is great) but sometime 115ms. the average is higher than the one from phpfpm

I have "hack" symfony to have profiler but the config cache debug is set to false. That way I can mimic what will happen in prod but still have the profiler.

Symfony initialization take about 5 ms for phpfpm and 1ms (constantly) for RR. But all the other code are pretty constant for phpfm but are not for rr:

PHP FPM

image

Road Runner

image

This is a small project sandbox so the gain for the symfony initialization is not great. for bigger project I am assuming symfony initiliazation will see better gain but I am not sure it will overcome the setting.

Also note that I am using rr serve and not rr server -c .rr.dev.yaml

Using rr with dev goes to 180 ms per request, I am assuming the "file change check" is way slower that what symfony does.

Apcu is enable for cli, so this is not the issue.

No query to doctrine for this specicific page

rmikalkenas commented 3 weeks ago

@mpoiriert you should write the issue directly to roadrunner: https://github.com/orgs/roadrunner-server/discussions it's not related to this bundle

mpoiriert commented 3 weeks ago

I thought that maybe some things are specific to Symfony that's why I asked here.

On Tue, Jun 4, 2024, 8:48 a.m. Rokas Mikalkėnas @.***> wrote:

@mpoiriert https://github.com/mpoiriert you should write the issue directly to roadrunner: https://github.com/orgs/roadrunner-server/discussions it's not related to this bundle

— Reply to this email directly, view it on GitHub https://github.com/Baldinof/roadrunner-bundle/issues/143#issuecomment-2147453314, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA73OAHPWOWRO3SIRHOEGLTZFWZTFAVCNFSM6AAAAABIVFJNISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBXGQ2TGMZRGQ . You are receiving this because you were mentioned.Message ID: @.***>

Kaspiman commented 3 weeks ago

@mpoiriert Hello, please show your rr.yaml config

mpoiriert commented 3 weeks ago

Here is the file:

version: "3"

server:
  command: "php public/index.php"
  env:
    - APP_RUNTIME: Baldinof\RoadRunnerBundle\Runtime\Runtime

http:
  address: 0.0.0.0:8080
  pool:
    debug: false
    num_workers: 8      # Adjust based on your system's CPU cores
    max_jobs: 4000        # Maximum number of jobs a worker can handle before being recycled
  middleware: [ "static", "gzip" ]
  uploads:
    forbid: [ ".php", ".exe", ".bat" ]
  static:
    dir: "public"
    forbid: [ ".php", ".htaccess" ]

logs:
  mode: production
  channels:
    http:
      level: debug # Log all http requests, set to info to disable
    server:
      level: info # Everything written to worker stderr is logged
      mode: raw
    metrics:
      level: error

# Uncomment to use metrics integration
# rpc:
#   listen: tcp://127.0.0.1:6001

# Uncomment to use metrics integration
# metrics:
#   # prometheus client address (path /metrics added automatically)
#   address: "0.0.0.0:9180"
Kaspiman commented 3 weeks ago

The application process starts quickly. However, the first request for every process may be slow, further ones will be executed quickly. If you have 8 processes, the first ~8 requests will be a little slower until each process warms up the opcache. Why? There is no opcache on the CLI. Every process should do some opcache work separately.

Try to execute many queries, for example 100 or 1000. Look at the result - does this delay persist? It is best to use the utility like Apache Benchmark for load testing.

mpoiriert commented 3 weeks ago

I made 1 process to check by refreshing often and the average is about 28-30.

I will do better load test when we are in the real infra (not my local docker).

There is a

opcache.enable_cli

Which is on and also show up in symfony profiler and it's on.

But any the first request is a lot slower (like 200 ms) than it goes to the averaged mentioned above.

I'll close the issue but I might comment to give more info once I do the proper test in a couple of weeks.