Blog

Performance Enhancement in phpFox 4.7.0

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.

phpFox 4.7.0 Performance Enhancement

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
  1. 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
    1. Intel® Core™ i7-4790 CPU, 4 cores / 8 threads
    2. 16G RAM
    3. 250G SSD
    4. Ubuntu 16.04 OS
  2. The server is installed the following software
    1. Nginx version 1.14 as the web server.
    2. 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“.
    3. MySQL Community Server version 5.7.22.
    4. Redis server version 3.x as the cache layer.
 II. Dataset
  1. We install phpFox 4.7 and use the in-house data generation script to simulate a phpFox social network site with the following data
    1. All phpFox’s default apps are installed.
    2. 10,000 users with 200,000 membership relationships.
    3. Each app (such as photo, forum, blog, polls, events, quizzes, etc.) has approximate 30,000 items.
  2. The site statistics is attached as follows 
 III. Testing Method
  1. 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.
  2. The test is conducted with the HTTPS protocol so that the cost for resolving SSL is also taken into place.
  3. Each virtual user will conduct the following activities
    1. First, visit the site home page.
    2. Next, login with his email and password. We force the locust script to pick different users for each session.
    3. 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.).
  4. 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:

  1. All requests must respond less than 15 seconds. If one single request exceeds 15s, the test is failed.
  2. No single failed request during 10 minutes at the “peak” load.
  3. 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:

phpfox-4.7 performance test result

Some detailed numbers are highlighted as follows:

  1. The system can handle more than 600 online users with the above configuration with no failed request.
  2. Average response times for all requests is ~ 7.x seconds.
  3. 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:

  1. We use HAProxy as the high-performance load balancer.
  2. 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.
  3. 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.
  4. 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.

 

Help Spread the Word
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Fox