roadrunner-server / roadrunner

🤯 High-performance PHP application server, process manager written in Go and powered with plugins
https://docs.roadrunner.dev
MIT License
7.86k stars 408 forks source link

[🐛 BUG]: High memory consumption with no load #1950

Closed speller closed 3 months ago

speller commented 3 months ago

No duplicates 🥲.

What happened?

Immediately after starting, RR consumes more than 1GB memory:

image

Version (rr --version)

2024.1.5

How to reproduce the issue?

Not sure, I'm just running it:

version: '3.8'

server:
  command: "php -d max_execution_time=${HTTP_TIMEOUT} index.php"
  # If you are not using symfony 5.3+ and the new Runtime component:
  # remove the previous `command` line above and uncomment the line below to use the deprecated command.
  # command: "php bin/console baldinof:roadrunner:worker"
  env:
    APP_RUNTIME: Baldinof\RoadRunnerBundle\Runtime\Runtime
    SERVER_NAME: _web_
    XDEBUG_TRIGGER: 1

http:
  address: 0.0.0.0:${CONTAINER_PORT}
  middleware: [ "headers", "static", "gzip" ]
  uploads:
    forbid: [ ".php", ".exe", ".bat" ]
  static:
    dir: "public"
    forbid: [ ".php", ".htaccess" ]
  pool:
    debug: ${RR_RELOAD_ENABLED}
    num_workers: ${RR_NUM_WORKERS}
    allocate_timeout: ${RR_ALLOCATE_TIMEOUT}s
    max_jobs: ${RR_MAX_JOBS}
    supervisor:
      exec_ttl: ${RR_JOB_TIMEOUT}s

logs:
  mode: ${RR_LOG_MODE}
  encoding: ${RR_LOG_ENCODING}
  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

PS: XDebug is not installed.

Relevant log output

No response

rustatian commented 3 months ago

Hey @speller 👋 Is that to happen only with 2024.1.5?

speller commented 3 months ago

@rustatian I saw this on 2023.3.10 as well. Updated to the latest version but it didn't solve the issue. For a short period of time, the memory consumption on startup is about 90MB, but then jumps to 1GB.

rustatian commented 3 months ago

Keep in mind, that the virtual memory size is not the same, as RSS memory. VSZ is all memory, which can be accessible by the process. To better understand what's happening, could you please show RSS memory consumption?

speller commented 3 months ago

It seems you're right, the rss memory consumption is low:

image

It also seems like the smaller AWS instance size (t3a.micro) is unreliable. When switched to the small size with 2GB memory, everything is working fine.

rustatian commented 3 months ago

In Go (and other compiled programming languages) you may find a technique called memory-ballast. This technique allows process to see (virtual memory size) much more memory, than it initially has. This allows to perform approximately 10 percent faster. You may read details here: https://blog.twitch.tv/en/2019/04/10/go-memory-ballast-how-i-learnt-to-stop-worrying-and-love-the-heap/

rustatian commented 3 months ago

Feel free to close the issue if your case was resolved 😀