magento / magento-cloud

Magento Cloud
Open Software License 3.0
206 stars 237 forks source link

FEAT: Opcache cron #513

Closed damienwebdev closed 1 year ago

damienwebdev commented 4 years ago

Whatever backing infra belies the Cloud for storage has some nasty latency, as several of my perf issues and CPU consumption problems come from cron:run as a result of includeFile (resulting in an include).

As a result, I asked myself why? Why are you calling includeFile so often?

The answer to this question is that cron:run is called from a CLI context, where opcache is essentially disabled.

As such, all the awesome perf benefits of opcache are disabled in the cron context as currently configured by cloud.

Now, someone may naively recommend opcache.enable_cli -- this would be a mistake. opcache.enable_cli caching only applies within the context of a single run of a cli command (the cache is lost when the command completes).

We'd need a way to store the result of the opcache during a cron:run and then reload it once we start the next run.

Any chance that we can store the opcache for cron in tmpfs or on disk?

This would update the .magento.app.yaml to something like:

# Default Magento 2 cron jobs
crons:
    cronrun:
        spec: "* * * * *"
        cmd: |
           php \
         -d opcache.file_cache_only=1 \
         -d opcache.enable_cli=1 \
         -d opcache.file_cache=/mnt/tmpfs \
         -d memory_limit=-1 \
         bin/magento cron:run

or

# Default Magento 2 cron jobs
crons:
    cronrun:
        spec: "* * * * *"
        cmd: |
           php \
         -d opcache.file_cache_only=1 \
         -d opcache.enable_cli=1 \
         -d opcache.file_cache=/mnt/disk-any-where-just-let-me-mount-something-so-i-dont-recompile-on-every-cron-run \
         -d memory_limit=-1 \
         bin/magento cron:run

cc: @shiftedreality

NadiyaS commented 4 years ago

Hi @damienwebdev, thank you for reporting about this issue. Internal ticket for investigation is MCLOUD-7103

jordanvector commented 1 year ago

@NadiyaS Did anything ever come from this?

damienwebdev commented 1 year ago

I don't care about this issue any more, closing.