r/PHPhelp • • Apr 30 '26

PHP-FPM vs PHP-CLI

I'm running some simple PHP 8.5 tests (empty loop, open database connection, ...) on a MacBook Pro with Debian in a UTM VM.

With exactly the same code fragment, CPU usage is always 2–3 times higher with PHP-FPM than with PHP-CLI.

Is this normal? Or does it have to do with my settings?
4 Upvotes

20 comments sorted by

View all comments

Show parent comment

1

u/MartinMystikJonas May 02 '26

And results for fpm now with longer loop?

1

u/tc712bb May 02 '26

To my surprise, the difference has now (almost) disappeared.

loop:0.50585

loop:0.49523

loop:0.49789

loop:0.49981

So it turns out the problem is the duration of my tests.

1

u/obstreperous_troll May 02 '26

FPM does have slightly more startup overhead, part of it from initializing opcache, which CLI skips entirely. Under real-world workloads though, opcache will pay off, and you're likely to see FPM actually pull ahead, significantly if there's a lot of vendor packages involved.