- Test Client A: HP dlrjg4, two dual-core CPUs, 4G Ram, two 10 k rpm sas disks for raid 1, ext3
- Nginx server B: DELL R710, E5620 * 2, 32G Ram, 6 disks, 15 K RPM SAS disks, raid 1 + 0, xfs
- Memcached server C: DELL R710, E5620 * 2, 32G Ram, 6 disks, 15 k rpm sas disks, raid 5, ext4
- Nginx: keepalive 8192
- Php fpm settings: listen. backlog =-1
- Memcached startup parameter: memcached-d-m 24576-p 12000-c 10240
- Kernel parameters:
net.ipv4.tcp_tw_recycle = 0net.ipv4.tcp_tw_reuse = 0net.ipv4.tcp_timestamps = 1
For explanations of these kernel parameters, see: 2.12. Reduce TCP performance spikes
- Connect to the local nginx proxy using php to access remote memcached data;
- Use php to directly connect to the remote memcached server;
- Initiate a concurrent test with AB from the test client;
- The number of concurrent threads starts from 64 to 2048, Which is N times that of 64;
- Each concurrency mode performs five rounds of tests, and the final average value is obtained;
- The key stored in memcached is 96 characters in length and the value is 400 characters in length, which is always randomly generated;
Conclusion and suggestions:
- The efficiency of accessing memcache and directly accessing memcached through HttpMemcMC by Php programs is not too high;
- Using php to directly access memcached increases the number of failures compared with HttpMemcMC. It should be because HttpMemcMC has more advantages in keepalive;
- In the future, we will conduct a test to adjust nginx, php, and kernel-related parameters for comparison;
- This test is not mixed with normal http requests, and the test results do not have absolute reference value;
According to the test results, HttpMemcMC is worth
Adjust the preceding kernel parameters:
net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_timestamps = 1
Adjust the kernel parameters and tcp connection reusability to Improve tcp efficiency. The new test results are as follows:
Note: In the two test cases, the number of requests per concurrent thread is different, so you will find that the data on both sides cannot be directly compared. This is my mistake. Sorry.
After the kernel is adjusted:
1. We can find that the average efficiency of HttpMemc is only NativeMC 72.62%;
2. Adjusting the kernel tcp Parameters is very helpful for improving the tcp efficiency. The number of Failed requests is completely 0;
3. Because memcached's connection reuse rate can be improved and its benefits to program transparency, even if HttpMemc's performance is not as good as NativeMC, the loss is not very high and acceptable;
For details about Memcached, click here
Memcached: click here
Refer:
Memcached installation and startup script
Performance problems of using Memcached in PHP
Install Memcached in Ubuntu and its command explanation
Install and apply Memcached
Use Nginx + Memcached's small image storage solution
Getting started with Memcached