Figured I would register here and post my success with PHP7 and phpBB 3.1.6. I have been comissioned to build, tune and move a client's phpBB forum to a high availaibility cluster, this forum boasts a 32GB database with over 30 million posts, and during peak periods exceeds 20,000 concurrent users.
Before we started their old configuration was:
- Front End Reverse Proxy
- 2x Apache Web Servers
- 1x MySQL 5.1 database.
First stage of the migration was to move from Apache to Nginx + PHP5.6 fpm. This gave conciderable performance increases tripling the throughput of the website, but it was still not enough as the servers were still getting overloaded.
My client agreed to move away from their clould VM environment to a cheaper, yet much more powerful dedicated server enivornment consisting of a total of 6 servers configured as follows:
- 2x frontend load balancers with a floating IP for high availaibility.
- 2x 16 core (32 threads) web servers with 32GB of ram.
- 2x 16 core (32 threads) database servers with 64GB of ram.
- All servers on a 1gbit private LAN for internal communications.
For the databases we used percona-server with galera clustering, and a HAProxy to distribute the load to the two servers. The servers were configured to use hugepages and are capable of keeping the entire database in ram which we converted to InnoDB. We did initially experiment with ProxySQL but found its performance to be rather lacking and did not handle network saturation well, thus the switch to HAProxy. A floating IP was also assigned to the database servers, and keepalived was configured to keep it online. This IP was used as the phpBB database host.
On the web servers we initially got things working using Nginx + PHP5.6 fpm, and saw some fairly decent performance metrics when testing with apachebench, on average we were 3.5x faster then the old configuration at this point per server, not across all servers
At this point we were obtaining around 400 requests per server (total of 800) at a concurrency of 30, which was saturating the CPU resources on the web servers. We next performed some profiling and found a some methods that could have done with a tune up (specifically get_moderators), this increased the server throughput to around 450rps.
As an experiment we decided to trial PHP7 on one of the servers and saw a large performance improvement, but obviously the preg_replace issue everyhone else here has reported. We spent the next day patching every occurance of preg_replace with the 'e' modifier to use preg_replace_callback with Closure methods, retaining 100% compatibility with the existing code, which gave us a fully working phpBB3 forum on PHP7.
The net result of all this is, each server is able to serve 655 requests per second, which fully saturates the private 1gbit network between servers. If we were to move to a 10gbit network we would be capable of 1,300 requests per second.
It was discovered that the database connection was actually the bottleneck with full network saturation, so we enabled compression on the connection (MYSQLI_CLIENT_COMPRESS on mysqli_real_connect) which gave us a futher performance increase, we now see over 1000 requests per second per server
, giving a net total of 2000 requests per second capacity
. Unfortunately at the load balancers we still only see a little over 1000 requests per second due to network saturation between the web servers and load balancers.
We hope to go live with the new environment in the coming week, when we do I will update this forum with the details if my client permits.