Community

Why Background Tasks Like Import Sometimes Hang and How to Fix It

Showing 1 of 1
Why Background Tasks Like Import Sometimes Hang and How to Fix It
by Nicholas
26 days ago
N

Nicholas

Support Dept.

Some servers experience situations where the Import Tool or other background tasks would appear to hang, stop unexpectedly, and remain locked indefinitely. The issue is caused by very low PHP-FPM process limits on the hosting environment.

Many shared hosting environments, especially cPanel-based servers, configure PHP-FPM with very restrictive default settings, such as extremely low pm.max_children limits. Hosting providers do this intentionally to prevent any single customer from using too many server resources. While this works for simple websites, it often causes problems for background operations like imports or any task that takes longer than a few seconds.

When pm.max_children is too low, PHP-FPM quickly runs out of worker processes and begins terminating long-running scripts. This interrupts background tasks and can leave them in a locked or incomplete state.

To reduce server load, phpListings 1.1.0 introduced a redesigned Import Tool that:

  • Processes 50 listings per cycle

  • Sleeps for the remainder of a 2-minute window

  • Adapts better to limited hosting environments

However, if PHP-FPM limits are too restrictive, the underlying issue may still occur. This guide explains how to diagnose the problem, adjust PHP-FPM settings, and prevent background tasks from hanging.

How to Identify the Issue

PHP-FPM worker exhaustion is the cause of hanging or locked background tasks.

Where to Check Logs

cPanel:

  • /usr/local/cpanel/logs/php-fpm/error.log

  • /opt/cpanel/ea-php81/root/usr/var/log/php-fpm/error.log (path varies by PHP version)

Ubuntu / Standard Linux:

  • /var/log/php8.x-fpm.log

  • /var/log/php-fpm/error.log

Error Messages That Indicate the Problem

Look for any of the following:

  • server reached pm.max_children setting

  • pool <name> seems busy

  • child exited with code ...

  • unable to fork

If these appear around the time an import or other background task should be progressing, PHP-FPM limits are the reason.

Fixing the Issue on cPanel Servers

cPanel often sets very low PHP-FPM worker limits, sometimes as low as 1 or 2 children per domain. This is insufficient for background processing.

How to Increase PHP-FPM Limits (WHM)

  1. Log in to WHM.

  2. Go to:
    Home → Software → MultiPHP Manager

  3. Find your domain and click Manage Settings.

  4. Increase:

    • pm.max_children → recommended minimum: 10

  5. Save the changes.

  6. Restart PHP-FPM for the PHP version in use.

If you do not have access to these settings, your hosting provider will need to adjust them for you.

Fixing the Issue on a Standard Ubuntu Server

Servers running PHP-FPM via apt use configuration files located at:

/etc/php/8.1/fpm/pool.d/www.conf

Steps to Update PHP-FPM Limits

  1. Open the configuration file:

sudo nano /etc/php/8.1/fpm/pool.d/www.conf

  1. Adjust the settings:

pm = dynamic

pm.max_children = 10

pm.start_servers = 2

pm.min_spare_servers = 2

pm.max_spare_servers = 4

  1. Restart PHP-FPM:

sudo systemctl restart php8.1-fpm

  1. Check status:

systemctl status php8.1-fpm

Showing 1 of 1
pixel image