apache mod_php performance

Hello Everyone!

I have been doing some benchmarks with apache and php and found out that apache 2.4.29 (Remi repo) with php 7.2 is slower than apache 2.4.6 (Centos 7 repo) with the same version of apache. I even tried compiling apache with the same results. Does anybody have a clue why is this?. I also tried disabling almost all apache modules, same result.

thanks in advance

I am using CentOS 7.4.1708 (linux 3.10.0-693.5.2.el7.x86_64)
Ludwig DiehlSystems ArchitectAsked:
Who is Participating?
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
State which Apache MPM you're using with 2.4.29 + if you're using HTTP2.

I'm getting 1,000,000+ requests/minute out of Apache-2.4.29 + PHP-7.1.12 + WordPress right now.

Today I'm setting up an LXD + PHP-7.2 site + will post my speed test data when generated.

You may be hitting this https://bugs.php.net/bug.php?id=75488 Opcache bug.

I notice you mention using mod_php which will surely destroy your speed.

CentOS packaging tends to be... sigh... I'll say it... not ready for prime time...

I only use Ubuntu for client site hosting, because their packaging handles problems like I'm going to describe.

1) As of Apache 2.4.26 support for running HTTP2 + mod_php was deprecated, because it was always buggy.

2) Debian/Ubuntu packaging enforces this + RedHat/CentOS may incorrectly allow it. Also if you build from scratch you can force using mod_php + HTTP2.

3) The correct/fastest Apache Stack == Apache-2.4.29 + mpm_event + mod_http2 + PHP FPM.

This stack will easily produce many 1000s of requests/second throughput. If you try forcing mod_php into an HTTP2 stack, then your speed will circle the drain quickly.
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
PHP-7.2 speed tests... Respectable... 0 failures @ 1M+ reqs/min... Sufficient for most sites...

lxd: net11-ubuntu-zesty-php72 # h2speed --compact --count=1000 https://net11.ubuntu.zesty.php72.davidfavor.com/hello.php
h2load -ph2c -t16 -c16 -m16 -n16000 https://net11.ubuntu.zesty.php72.davidfavor.com/hello.php
finished in 900.59ms, 17766.13 req/s, 2.07MB/s
requests: 16000 total, 16000 started, 16000 done, 16000 succeeded, 0 failed, 0 errored, 0 timeout
status codes: 16000 2xx, 0 3xx, 0 4xx, 0 5xx
Requests per second: 17,766.13
Requests per minute: 1,065,967.8
Requests per hour  : 63,958,068

Open in new window

My LAMP Stack package details.
Ludwig DiehlSystems ArchitectAuthor Commented:
So you recommend using  Apache-2.4.29 + mpm_event + mod_http2 + PHP FPM. However I have read that mod_http2 consumes more memory and CPU.
Ludwig DiehlSystems ArchitectAuthor Commented:
btw should I use  the thread-safe or the non-thread version with the configuration you suggest?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.