Boost Performance

Background task manager

The system has many tasks that take more time to execute and makes users waiting to get feedback like sending an email. After configuring this tool the system will push all the time-consuming tasks to a job queue and return to the user soonest possible time. A background task manager will manage the queue and execute tasks one by one.

Info To do this configuration you must have root access to your server and have permission to install new tools.

 

To get started login into the server and run this command to install a supervisor that’ll make sure your background task manager is running all the times, even after a server crash.

sudo apt-get install supervisor

If installed successfully, after installation supervisor should start running automatically. To check if the supervisor is running run following command.

ps -aux | grep "supervisor"

The outpute will be like this:

Supervisor is running!

After successfully install the supervisor, it’s time to configure it. A sample configuration file named supervisor-example.conf is included on your project root directory.

[program:incevio-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/incevio/artisan queue:work default --sleep=3 --tries=3
autostart=true
autorestart=true
user=root
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/html/incevio/storage/logs/job-worker.log
stopwaitsecs=36000

 

Warning! Be careful when edit the sample configuration file. Don’t break the code stracture. Take the backup copy before made any changes.

 

Open the /path/to/your/application/supervisor-example.conf file with an editor and replace the /var/www/html/incevio in line number 3 and 9 with your /path/to/your/application. Also change the user=root in line number 6 if your root username is different. Save the file.

Now you need to move this configuration file to the supervisor’s config location. By default the configuration files are typically stored in the /etc/supervisor/conf.d directory on your server.

On your project root run following command to copy the configuration file to its location.

sudo cp supervisor-example.conf /etc/supervisor/conf.d/incevio-worker.conf

This command will create a copy of the sample config file and move it to the /etc/supervisor/conf.d directory. This incevio-worker.conf file will be used to monitors the task manager process.
 

Run these commands one by one to restart the supervisor tool and load the new configuration.

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start incevio-worker:*

You have successfully configured the background task manager. Your visitors will be happy for sure! 🙂

 
 

Cache all configurations

Warning! Do this only if you’re done with all the configurations and ready to go live. You need to run this command every time after you make any changes in configuration.

 

As you’re done with all the configurations and other staff your system is now ready. It’s time to do a performance boost to make the application shiny and smooth. Open the terminal on the project directory on the server and run below commands:

php artisan incevio:boost

 
 
 

Was this helpful to you?

Leave Comment