Test environment:
Test client A:HP dl380g4,2 dual-core CPU,4G ram,2 Block 10k RPM SAS disk for RAID 1,EXT3
Nginx Server B:dell r710,e5620 * 2,32g ram,6 block disk 15K RPM SAS disk do raid 1+0,XFS
memcached Server C:dell r710,e5620 * 2,32g ram,6 block disk 15K RPM SAS disk do raid 5,EXT4
Nginx setting: KeepAlive 8192
PHP fpm Settings: listen.backlog =-1
memcached Startup parameters: Memcached-d-M 24576-p 12000-c 10240
Kernel Parameters:
net.ipv4.tcp_tw_recycle = 0
Net.ipv4.tcp_tw_reuse = 0
Net.ipv4.tcp_timestamps = 1
The explanations for these kernel parameters correspond to the following: 2.12. Reduce TCP Performance Spikes
Test Scenario:
Use PHP to connect with local Nginx proxy, access remote memcached data;
Direct connection to remote memcached server using PHP;
Initiate concurrent testing with AB from the test client;
Concurrent threads start at 64, until 2048, respectively, 64 n times;
Each concurrency pattern is tested in 5 rounds, and the final average is taken;
The key length stored in memcached is 96 characters, the value length is 400 characters, always randomly generated;
Test results:
Conclusions and recommendations:
PHP programs through the HTTPMEMCMC access to memcache and direct access to memcached is not much of the loss of efficiency, the use of direct access to PHP memcached, the number of failures compared to through the HTTPMEMCMC has a greater increase, Should be HTTPMEMCMC in the keepalive aspect has the advantage; follow-up will be a test, adjust nginx, PHP and kernel-related parameters, and then compare; This test does not mix with the normal HTTP request, the test result does not have the absolute reference value;
Judging from the results of this test alone, HTTPMEMCMC is worth having
Result Update:
Adjust the several kernel parameters above:
net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_timestamps = 1
By adjusting the kernel parameters and adjusting the multiplexing of TCP connections to improve TCP efficiency, the new test results are as follows:
Note: Because of the 2 test cases, each concurrent thread request number is different, so you will find that the data on both sides can not be directly compared, this is my mistake, sorry.
Supplementary Summary:
After adjusting the kernel:
1. It can be found that the average efficiency of HTTPMEMC is only NATIVEMC 72.62%;
2. Adjusting the kernel TCP parameters is very helpful to improve TCP efficiency, and the number of Failed requests is completely 0;
3. Since it is possible to improve the memcached connectivity and the benefits of transparent procedures, the loss is not very severe and is still acceptable, even if HTTPMEMC performance is inferior to NATIVEMC;