End of life for on-premise instances
At the end of March 2023, we cease on-premise hosting for Xentral instances. We encourage you to migrate your Xentral instance to our cloud - please do not hesitate to contact account@xentral.com for discussing and scheduling your cloud migration, or refer to our website or to our Community for more information.
Be aware that at the end of March 2023 we will stop any support services for on-premise hosted instances. There will be no further bug fixing or updates available. Likewise, we will not issue any further open source versions.
Xentral 22.1 comes with a queue component to normalize workloads. The queued jobs are executed by a long running worker process.
To start the worker manually, use the following command in the command line interface:
php /xentral_root_dir/artisan queue:work
To stop the worker manually, use the following command in the command line interface:
php /xentral_root_dir/artisan queue:restart
Note
Even though the command is called “restart”, it will only stop the process.
For more information and command options visit the Laravel documentation.
We recommend using a process control system or a process monitor to restart workers when they shut down or crash.
For this, you can use any system capable of automatically re-starting a process via a console command that is not running or has crashed.
You may define and run a service as the process control system using systemd
on Linux. This is a typical and easy to implement way of setting up such a process control system.
Proceed as follows:
-
Create a file for the definition of the service with the following path and filename:
/etc/systemd/system/queue_worker@.service
Important
The filename must contain the
@
symbol! -
Enter the desired configuration into the file as in the example below.
Remember to replace
/var/www/xentral
with the root directory of your xentral installation. In addition, if needed, replacewww-data
with your actual web server user.[Unit] Description=Runs and keeps alive the artisan queue:work process [Service] Restart=always RestartSec=1 StartLimitIntervalSec=0 WorkingDirectory=/var/www/xentral/ User=www-data ExecStart=php /var/www/xentral/artisan queue:work --max-time=3600 [Install] WantedBy=default.target
-
Once you have saved the configuration in the file, you need to reload the daemon using the following command.
systemctl daemon-reload
-
Now you can run one or more workers.
To run the first worker, use this command:
systemctl start queue_worker@1 # enable service on every boot systemctl enable queue_worker@1
You can run additional workers by using repeating these commands but with sequential numbers after the
@
symbol.systemctl start queue_worker@2 systemctl enable queue_worker@2 systemctl start queue_worker@3 systemctl enable queue_worker@3 . . .
As an alternative to using Systemd, you can use Supervisor as process control system to configure the queue process.
Visit the Supervisor Documentation for more information on how to use Supervisor.
Sample configuration:
[program:queue-worker] process_name=%(program_name)s_%(process_num)02d command=php /var/www/xentral/artisan queue:work --max-time=3600 autostart=true autorestart=true stopasgroup=true killasgroup=true numprocs=2 redirect_stderr=true stdout_logfile=/var/www/xentral/storage/logs/queue-worker.log stopwaitsecs=3600
Visit the Laravel Documentation for more information on the configuration.
When using a process control system, you must regularly stop and restart the worker process to avoid issues. A good way of implementing a regular stop/restart procedure is to use the following options of the artisan queue:work
command:
-
--max-jobs=1000
: The worker stops after processing the designated number of jobs. More Information -
--max-time=3600
: The worker stops after the designated time period (in seconds). More Information
A combination of both options is possible.
Tip
You might need to try out different settings in order to find out what works best in your environment. For example, if a worker often exceeds its memory limit, you should consider restarting the workers more often.
You can run multiple worker processes at the same time. However, different process control systems handle this in different ways: For Systemd you need to start several services; Supervisor uses the numprocs
property.
To determine how many workers should run, consider the following aspects:
-
How many unprocessed jobs are there?
Queued jobs are stored in the
queue_jobs
table. If too many jobs are queued, you might want to add more workers. -
Performance
The more workers are running, the more CPU and RAM will be used. This might affect the overall response time of the application.