As teased in the phpFox 4.7.0 Sneak peek, improving performance is one of the primary targets for phpFox 4.7.0 development. In this blog, we will discuss in more detail about performance enhancement in phpfox 4.7 by briefly describing the way we conduct the performance test, the test result and some further discussions about scalability with phpFox.
In recent years, phpFox is becoming the best platform for Niche Social Networks, and so there is an increasing amount of users all around the world. As you may know, performance has been one of the major care and we put a lot of effort for code restructuring for performance improvement in phpFox 4.4. In phpFox 4.7, we revised the platform performance again with the latest technologies and we realize that we can do it much better.
Testing Environment
I. System Environment
- To simulate a common use case in which the whole system is deployed in one single dedicated server, we take a standard server with the following configurations
- Intel® Core™ i7-4790 CPU, 4 cores / 8 threads
- 16G RAM
- 250G SSD
- Ubuntu 16.04 OS
- The server is installed the following software
- Nginx version 1.14 as the web server.
- PHP-FPM with PHP version 7.2. The pool process manager is set to “ondemand” instead of the default “dynamic” setting. Opcache and APCu are also enabled. The “request_terminate_timeout” is set to “15s“.
- MySQL Community Server version 5.7.22.
- Redis server version 3.x as the cache layer.
II. Dataset
- We install phpFox 4.7 and use the in-house data generation script to simulate a phpFox social network site with the following data
- All phpFox’s default apps are installed.
- 10,000 users with 200,000 membership relationships.
- Each app (such as photo, forum, blog, polls, events, quizzes, etc.) has approximate 30,000 items.
- The site statistics is attached as follows
III. Testing Method
- We use Locust as a load testing tool. The Locust software runs with 4 slave threads on an Intel Xeon E3-1270 v6 CPU @ 3.80GHz (4 cores/8 threads) to be sure the load is put to the site properly.
- The test is conducted with the HTTPS protocol so that the cost for resolving SSL is also taken into place.
- Each virtual user will conduct the following activities
- First, visit the site home page.
- Next, login with his email and password. We force the locust script to pick different users for each session.
- After login, the virtual user will continuously visit all landing pages of activity feeds, member list, and all default apps (such as photo, forum, blog, polls, events, quizzes, etc.).
- Each test runs continuously at least 10 minutes at the highest load.
IV. Acceptable Passing Criteria
A test can only consider being passed if it satisfies all the following criteria:
- All requests must respond less than 15 seconds. If one single request exceeds 15s, the test is failed.
- No single failed request during 10 minutes at the “peak” load.
- The software must handle at least 500 concurrent online logged-in users in one dedicated server with the above testing method.
Testing Results
I. The number
Tl;dr: phpFox 4.7.0 passed the performance test with 600 concurrent online users as in the following screenshot:
Some detailed numbers are highlighted as follows:
- The system can handle more than 600 online users with the above configuration with no failed request.
- Average response times for all requests is ~ 7.x seconds.
- The system can handle ~ 105 Requests Per Second (RPS).
II. Some Conclusions
The result between File Cache and Redis Cache settings are nearly the same in this system. However, when running on a non-SSD system with more writing operators, the Redis Cache setting proves to be better.
Comparing to the previous version (phpFox 4.6.1 – 27 RPS & 17s Average Response Time), phpFox 4.7.0 can handle more than 3x RPS and Average Response time is less than 1/2 on the same system configuration.
If your phpFox social network contains mostly browsing activities as in the test, the real online users might be higher since this test simulates concurrent online users.
The real concurrent number of users can also be higher this test since this test does not take the non-logged-in users into account. For non-logged-in requests, we can offload the application/database server by simply configuring your web server/proxy/load balancer to cache page content.
The test only focuses on “browsing” activities with no new content posting activities. Results will be different depending on the real member activities on different social network sites with different installed apps.
Further Discussions
We also conducted a similar performance test on a cluster of multiple servers. In this system, we utilize the following configuration to achieve much higher concurrent online users by splitting loads among servers:
- We use HAProxy as the high-performance load balancer.
- Nginx and PHP-FPM are used in application servers that serve phpFox source code. We also use Nginx micro cache for off-loading non-logged-in visits.
- For Database cluster, we utilize the latest MySQL Group Replication under a high-performance proxy to distribute database read and write loads among many database servers. Please be noted that supporting for MySQL Group Replication is only available from phpFox version 4.7.0.
- We utilize a Redis cluster for Caching purpose.
Maintaining a cluster of servers when users and the site traffic grows are tedious and complex work. So we always recommend our clients to move to a cloud-based environment such as Amazon Web Service when their site grows. Also, setting up an optimized environment for a growing social network with lots of user activities is not an easy task so we do provide all services for your growing site. Be sure to check our Services page to see what we are providing.
Final Words
As a result of the above tests on phpFox 4.7.0 performance, it’s a certainty to come up with a solid statement that this new version surely opens up a brand new and enjoyable experience to you when it comes to how well your social network handle requests and respond accordingly.
Share us your thought on how phpFox 4.7.0 performs on your Social Network by emailing us at hello@phpfox.com.