• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Issue How to use multiple Cores for PHP

Xav2c

Basic Pleskian
Server operating system version
Ubuntu 20.04.4 LTS
Plesk version and microupdate number
Version 18.0.44
Hello,

I recently switched one of our servers from WHM on CENTos7 to a brand new Ubuntu 20.04 :
Ubuntu 20.04.4 LTS
Plesk Obsidian
Version 18.0.44 Update #3

We use this server for as a Wordpress preproduction environnement, and as soon as I switched, i realized that the thumbnail regeneration was very slow on the new machine.
On the same website, on the old server (8 cores of an old 2012 Xenon), the regenaration happens on all cores and takes around 6 minutes to complete. On the new one, it happens on only one core (2021 12 cores Xenon), and it takes around 35 minutes to complete !

i'm mainly using PHP 8.0.20 FPM application, but i tried several settings ranging from PHP7 fastCGI, dedicated FPM... it always uses only one core.

Tried several other things regarding PHP and Apache (event, prefork...) but I cannot find how to solve this issue.
I'm running another Plesk Obsidian server on ubuntu 18.04 and i'm not having this issue.

What did I miss ? Is this a kernel issue ?
Any help appreciated.
 
How many workers are in your pool? You need at least as many workers as the (v)cores you want to use, because a worker can not run on more than one core at a time.
 
Are you talking about this setting ?
shot.png

Also, I forgot to mention that the regeneration only use one core wether I use wp-cli or PHP, which make me think this might have something to do with kernel configuration.
 
Apparently, Wordpress and PHP are not by design multithreaded, unless the module or the core has been developped or tweaked to achieve multithreading.

What I don't understand, is I did not do anything on those two other servers (the WHM on Centos7 and Plesk on Ubuntu 18.04) to achieve multithearding, but every task runs on all cores (as whitnessed with htop), especially the thumbnail regeneration process, wether i'm using WP-CLI or the Regenerate Thumbnails module.

But when I run those tasks on the brand new server (which has 12 cores of pure 4Ghz power), they run only on one core at a time. And the regeneration process on a WP site with 1000+ images takes ages. I'm losing it.
 
In general, it depends a lot on the application. If the generation is done via php-fpm, maybe it doesn't have enough workers in the pool. Maybe the architecture of the application is bad.
In general PHP by itself is not designed to efficiently load all CPU cores.
 
That's where I don't get it, it is a WHM => Plesk migration, the same application (Wordpress) does multithread on one server (WHM) and not on the other (Plesk).

Can you elaborate more about workers and pool ?
I need to find a solution or i'll switch back to my old panel.
 
Forget about workers and pools, as this is not your problem, unless you have set php-fpm to spawn only one worker (pm.max_children), but you don't have as I can see from the screenshot in #3
Moreover you would then not have the same issue when using FastCGI

PHP in a webserver environment is in general purely singlethreaded and thus a request only ever runs on a single core.
The only way to use more cpu cores, is to run more than one php script at once.
And if you yourself do not fire up multiple requests at once, then your "Regenerate Thumbnails" extension or the WP-CLI would need to do that for you, in order to use more than one cpu core.

The OS, the PHP bits installed on it, or Plesk do not have anything to do with your problem.

If you run such a regenerate process, how many spawned "pool" processes for your website do you see with "ps axfu" on the server?
 
shot.png
These are the settings I actually have, I tried several options such as Ondemoand (default), static and dynamic and increase the values in the fields, it does not change the result.
 
Forget about workers and pools, as this is not your problem, unless you have set php-fpm to spawn only one worker (pm.max_children), but you don't have as I can see from the screenshot in #3
Moreover you would then not have the same issue when using FastCGI

PHP in a webserver environment is in general purely singlethreaded and thus a request only ever runs on a single core.
The only way to use more cpu cores, is to run more than one php script at once.
And if you yourself do not fire up multiple requests at once, then your "Regenerate Thumbnails" extension or the WP-CLI would need to do that for you, in order to use more than one cpu core.

The OS, the PHP bits installed on it, or Plesk do not have anything to do with your problem.

If you run such a regenerate process, how many spawned "pool" processes for your website do you see with "ps axfu" on the server?
Sorry I did not see your answer as I was posting my reply, it seems like there are 10 processes but only one is running :
Code:
root     3781852  0.0  0.1 241600 41252 ?        Ss   Jun17   1:11 php-fpm: master process (/opt/plesk/php/8.0/etc/php-fpm.conf)
indigo    190668  0.0  0.5 415212 179580 ?       S    00:00   0:05  \_ php-fpm: pool mywebsite.com
indigo    190669  0.0  0.5 417360 181492 ?       S    00:00   0:04  \_ php-fpm: pool mywebsite.com
indigo    190670  0.0  0.6 443512 211700 ?       R    00:00   0:03  \_ php-fpm: pool mywebsite.com
indigo    190671  0.0  0.3 344320 109512 ?       S    00:00   0:01  \_ php-fpm: pool mywebsite.com
indigo    190672  0.0  0.3 341832 102828 ?       S    00:00   0:01  \_ php-fpm: pool mywebsite.com
indigo    190673  0.0  0.3 355532 121996 ?       S    00:00   0:01  \_ php-fpm: pool mywebsite.com
indigo    190674  0.0  0.5 422360 190268 ?       S    00:00   0:03  \_ php-fpm: pool mywebsite.com
indigo    190675  0.0  0.3 344640 112972 ?       S    00:00   0:01  \_ php-fpm: pool mywebsite.com
indigo    190676  0.0  0.3 366140 129200 ?       S    00:00   0:03  \_ php-fpm: pool mywebsite.com
indigo    190679  0.0  0.5 419376 187804 ?       S    00:00   0:05  \_ php-fpm: pool mywebsite.com

Which is not what it shows in htop, and also not what is expected performance wise (5-10 times the time to complete the task compared to other servers)
 
Sorry my answer is messed up :
There are 10 processes because I tried to set "PM" setting to static, I put it back to "Dynamic". and now there's only one process in the pool.
 
Did you already compare the lists of installed PHP modules on those servers? Could be that the script only runs in parallel when certain modules are present.
 
Did you already compare the lists of installed PHP modules on those servers? Could be that the script only runs in parallel when certain modules are present.
Thanks for your answer, yes in fact I did.
Nothing relevant here.
 
Just in case someone stumbles upon my post with the same issues, I found a workaround by using this WP module : ImageMagick Engine
It replaces the default GD engine to regenerate thumbnails, and not only does it uses multiple cores, it is amazingly fast!
You must have imagick apache module enabled but that's the default with Plesk so no issues.
I was starting to be desperate...
But i suppose on my old server, I must have disabled GD and forced it to use imagick on all image processing, but I don't remember when and how.
 
Back
Top