Analysis of the high performance technology architecture in cloud two

Source: Internet
Author: User

This paper mainly introduces the memcached technology in the cache.

1 Memcached

1.1 Memcached Introduction

Memcached is a high-performance distributed object caching system for dynamic Web applications to offload database load [1]. It improves the performance of your Web site by caching data and objects in memory to reduce the number of times the application reads the database. 1 is the location of memcached in the site.

Figure 1 Memcached position

memcached data (or objects) is cached in memory as a key-value pair, although multiple service nodes are used, but unlike the general distributed cache system, each piece of data has only one copy in Memcached, and each memcached service node is invisible to each other. Therefore, the key value of each piece of data in memcached is unique.

In short, memcached is similar to a typical non-relational storage system that can be classified into content-based key-value pair storage type [2].

1.2 Memcached Working principle

When the high concurrent external request accesses the server, the Load Balancer server will allocate and forward according to the usage of each application server, if it needs to read the data, the application server will calculate the result of the key value according to a certain hash algorithm, and access a service node of memcached according to the calculation result. The service node computes the second hash value of the key value again, and then reads the data according to the result of the calculation, and if the data in the cache is returned directly to the application, it is necessary to fetch the data from the database and write the obtained data to memcached [3].

Figure 2 How memcached works

2 Performance Analysis

With memcached installed on this machine, the client uses the interface provided by memcached to store and access data and compare it to the way it is obtained directly from MySQL.

2.1 memcached Installation

Since memcached is mainly used for servers, and most of the server-side operating systems are Linux, most tutorials on the web are about installing using memcached on Linux. Installing on Windows is simpler, just find the version of the corresponding operating system [4].

After installing the memcached, the service can be opened to use the corresponding function, memcached the default listening 11211 port, if it is on this machine, directly using 127.0.0.1:11211 can be accessed, which is very similar to MySQL.

Memcached provides a number of high-level language interfaces that can be used to store and access data based on these interfaces.

2.2 memcached and MySQL performance comparison

In order to compare the performance of accessing data before and after using memcached, the following simulation experiments are carried out.

Hardware conditions:

      1. Cpu:intel Core 2.60GHz;
      2. Memory: 2GB;

Software conditions:

      1. Operating system: Window 64;
      2. memcached maximum memory: 64MB;
      3. memcached Maximum number of connections: 1024.

MySQL has 29,120 records that use multithreading to simulate concurrent access for users, and each user requests 100 reads of data. Table 1 is the result of testing that all requests have finished processing the time t when the number of users is N.

Table 1 Test Results

Three method Description: MySQL indicates that all data requests are returned directly by accessing the database; Random mem means that after the addition of the memcached cache, there is no relationship between the data and 100 requests per user, completely random; 28 Law mem means the user's request follows the 28 law, That is, the average of 100 requests, there are more times access to the same data, which can be simulated by the program, access to control the corresponding number of times to access the same data.

Figure 3, Figure 4 corresponds to the two data representations of table 1 respectively.

Figure 3 Bar chart showing results

Figure 40 percent line shows the result

Since the data hit rate is very low (almost 0) at full random access, each request needs to be fetched from the database and the requested data is saved in the cache, making it less efficient than getting it directly from the database. But when the user requests the same data multiple times, using memcached is significantly more efficient than getting directly from MySQL.

There are some deficiencies in the entire testing process:

      1. Limited by the actual conditions, the number of memcached service nodes is only 1;
      2. In addition, the data volume level in the database is not very large;
      3. There is no test data written in the case
3 Key Issues

The above analysis shows that memcached has a great effect on improving data access efficiency under some conditions. For those infrequently variable access frequency and very high data, put it in the cache, can be very good to alleviate the pressure of the database, and thus improve system performance. But at the same time, there are some shortcomings in memcached itself.

      1. Since memcached is caching data in memory, the data disappears immediately when a power outage occurs [5];
      2. All data in memcached only one copy, so the reliability is not very high, once a service node fails, the corresponding data will be lost;
      3. Memcached at the beginning of the design of the value of each key is 1MB, with the current data volume of rapid growth, large cache data files , such as audio, video and so there is a great shortage.
4 References
    1. Hu Hua. Application of Memcached in large-scale website [J]. Science and technology information, (1), P70.
    2. Wang Niugen. Research on key technologies of Web backend performance optimization [D]. Zhejiang University, 2012.
    3. Http://en.wikipedia.org/wiki/Memcached
    4. http://blog.csdn.net/zhaotengfei36520/article/details/41315329
    5. Xu Jianqiang, Wei Weiping. Study on application of memcached [J]. Science and Technology Plaza, (7), p95-97.

Analysis of the high performance technology architecture in cloud two

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.