The following five rules can help you optimize the installed Drupal server. Examples are provided to illustrate how to use these rules. Server optimization is a huge field that is constantly evolving. However, we can study and analyze some simple situations to understand complex situations.
Next we will focus on several variables to measure their impact on performance.
First rule: optimization is impossible if performance is not tested.
There are many tools available to accurately evaluate and test performance, but this article focuses on the most important tool: Apache Benchmark. You can use this tool to query a specific page on your website and even send cooki information to it to simulate authenticated users. You can use Apache Benchmark on the command line on the server that is being tested, and still obtain valid results because the tool occupies a small amount of CPU and memory resources. The following is a typical usage:
$ AB-n 1000-c 20 http://example.com/
The value here is as follows:
N = number of page requests
C = number of concurrent connections
The most important parameter is c, that is, the number of concurrent requests, and n must be large enough to provide stable results. The key lies in the use of different c values to test the website, starting from a small value, gradually increasing until the return value of "requests per second" starts to decline. For example:
$ AB-n 1000-c 20 http://example.com/| grep 'requests per second'
Requests per second: 45.29 [#/sec] average value)
$ AB-n 1000-c 40 http://example.com/| grep 'requests per second'
Requests per second: 46.91 [#/sec] average value)
$ AB-n 1000-c 60 http://example.com/| grep 'requests per second'
Requests per second: 8.55 [#/sec] average value)
$ AB-n 1000-c 80 http://example.com/| grep 'requests per second'
Requests per second: 2.21 [#/sec] average value)
We can use smaller increments to refine the c value, but it is usually enough to take 10 as the nearest multiple.