In general, many update functions in Shopware 6 are regularly executed as a background process in the browser (message queue) when a user is logged in to the administration. However, this can lead to performance losses if several users are working simultaneously in the administration.
In addition, there are some functions that should only be carried out at a specific time. These are not performed from the message queue. Scheduled tasks can be used to perform these functions without the intervention of a user.
These can be e.g. the generation of the sitemap or the provision of product data for comparison portals.
The following settings are made right on the server. Since the possibilities of the server configuration depend on the hoster, we will explain this here in general. If you have any questions regarding the operation of the server configuration, the support of your hoster should be able to help you.
A cron job is set up on the server to perform the scheduled tasks. We recommend setting this up for regular execution every 5 minutes. The following command is used
php /pfad/zu/Shopware/bin/console scheduled-task:run --time-limit=295 --memory-limit=512M
The addition "--time-limit=295" ensures that the command is executed for 295 seconds. This means that it is finished when the new execution is started after 5 minutes.
With "--memory-limit=512M" the maximum memory used by this command is limited to 512 MB, which prevents the RAM from filling up.
The setup of the cronjob on the server can vary depending on the hoster. You should get further information from your hoster. Profihost describes this e.g. under https://wissen.profihost.com/wissen/artikel/wie-richte-ich-einen-cronjob-ein/.
In addition, depending on the configuration of the hoster, it may make sense to outsource the above command to a script and include the script in the cronjob.
If you do not want to process the messenger queue through background processes of the browser, the points in the following two sections should be implemented.
To deactivate the execution of the standard worker (browser background process), an adjustment of the file shopware.yaml in the /config/packages subdirectory of your shopware installation is necessary. If this file is not available, create it.
The following will be entered in the file
shopware: admin_worker: enable_admin_worker: false
Afterwards it is necessary to empty the shop cache.
This can be done with the command
php bin/console cache:clear
which you execute directly on the server (e.g. via SSH).
The message queue should be processed continuously. It is therefore recommended to restart the command every 5 minutes. So that not very many parallel processes are executed in the long run due to the regular start, the running process can be terminated shortly before with the addition "--time-limit=295".
php /pfad/zu/shopware/bin/console messenger:consume --time-limit=295
However, a memory limit can cause the process to be interrupted at an early stage. Therefore, a memory limit should not be set at this point.
Some hosters provide articles in their knowledge areas describing how to set up there.
At Profihost you can find more information about the setup under https://wissen.profihost.com/wissen/artikel/shopware-6-worker-im-hintergrund-laufen-lassen/
Hetzner provides the information under
Creoline provides the Informationen under