Nginx HttpMemcModule and direct access to Memcached

Source: Internet
Author: User
Tags nginx server dell r710 e5620

  • Test environment:
  1. Test Client A: HP dlrjg4, two dual-core CPUs, 4G Ram, two 10 k rpm sas disks for raid 1, ext3
  2. Nginx server B: DELL R710, E5620 * 2, 32G Ram, 6 disks, 15 K RPM SAS disks, raid 1 + 0, xfs
  3. Memcached server C: DELL R710, E5620 * 2, 32G Ram, 6 disks, 15 k rpm sas disks, raid 5, ext4
  4. Nginx: keepalive 8192
  5. Php fpm settings: listen. backlog =-1
  6. Memcached startup parameter: memcached-d-m 24576-p 12000-c 10240
  7. 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

  • Test Plan:
  1. Connect to the local nginx proxy using php to access remote memcached data;
  2. Use php to directly connect to the remote memcached server;
  3. Initiate a concurrent test with AB from the test client;
  4. The number of concurrent threads starts from 64 to 2048, Which is N times that of 64;
  5. Each concurrency mode performs five rounds of tests, and the final average value is obtained;
  6. The key stored in memcached is 96 characters in length and the value is 400 characters in length, which is always randomly generated;
  • Test results:

Conclusion and suggestions:

  1. The efficiency of accessing memcache and directly accessing memcached through HttpMemcMC by Php programs is not too high;
  2. Using php to directly access memcached increases the number of failures compared with HttpMemcMC. It should be because HttpMemcMC has more advantages in keepalive;
  3. In the future, we will conduct a test to adjust nginx, php, and kernel-related parameters for comparison;
  4. 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

  • Result update:

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.

  • Summary:

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.