Distributed cache Memcached
Distributed cache server, since data cache is used, it is obvious that you want to efficiently obtain data and store large data volumes. in order to cache a large amount of data and obtain data efficiently, the distributed cache database must solve the problem of horizontal and linear data expansion, which can expand the data capacity, the second is the performance of the cache in high concurrency. the distributed cache service needs to be considered as follows. If horizontal linear expansion is required, a reasonable routing algorithm is required to solve the Server Load balancer problem and provide data backup. In this way, when a node server is done, the copy can be started. in this way, we need to consider the data consistency issue. core Technologies of distributed cache include memory management, including memory allocation, management, and recovery mechanisms. The second is distributed management and distributed algorithms, and the second is cache key value management and routing.
Magent: As a memcached proxy server, it solves the Load Balancing Problem and automatically loads data to that node server. It also provides the data backup service, in addition, when a done Machine occurs, data is obtained from the replica set. Of course, each replica set and each server can be a proxy server.
I. Data collection: Cache
1. Definition of Cache
(1) narrow concept: it is a hardware device used for coordination between the CPU's relatively high-speed processing and the relative low-speed processing of the Main Memory (Main Memory.
(2) broad concept: it is used between two hardware with Large Speed differences to coordinate the structure of the data transmission speed differences between the two.
The narrow concept comes from the application scenarios of Cache 1967 for a long time. Because the data processing speed of the CPU is much higher than that of the primary storage, there will be a high-speed cache device between the CPU and the primary storage, or even a multi-level cache device. The broad concept is a widely accepted definition. In the broad concept, Cache is no longer limited to hardware or software. For example, it is used to coordinate the speed difference between relatively low-speed network transmission and relatively high-speed Disk transmission.
2. Essential Principles of Cache
It can be summarized in one sentence: the Cache puts the data to be retrieved from the slow device in advance to the fast device.
3. Several types of Cache
(1) CPU Cache: it is placed between the CPU and the primary memory to accelerate the relatively slow operation of the CPU on the primary memory.
(2) Browser Cache: it is placed between the client and the server to accelerate the relatively slow operation of the client on the server.
(3) Server Cache: it is placed between a network request and a local file to accelerate slow operations on local files by network requests.
(4) CDN: CDN is the Content Delivery Network. node Cache is set in different regions to accelerate the relatively slow operation on the service Network.
(5) Database Cache
(6) OS Cache: the buffer area in the memory for hard disk read/write.
Ii. What is Memcached?
Memcached is a high-performance distributed memory object Cache System for dynamic Web applications to reduce database load. It caches data and objects in the memory to reduce the number of reads to the database, thus improving the speed of dynamic and database-driven websites. Memcached is based on a hashmap that stores key/value pairs. Its daemon is written in C, but the client can write it in any language and communicate with the daemon through memcached protocol.
Iii. Typical usage
1. during User Login filtering, we use sesison to save the user login status to block users not logged in. however, the session is the data stored by the server through the sessionid stored by the cookie. If the session is still stored in the server cluster, requests sent from the proxy server are loaded on any server. Therefore, user login interception cannot be ensured. in this case, we can store data on the cache server through the tomcat session configuration.
2. data Persistence access layer second-level cache. when we need to improve the reading efficiency of the relational database, we may use the cache. for Mybatis, it provides a level-2 Cache and an interface. through the implementation interface, we can cache data to the database you want to cache. For this distributed cache database, the practicality is far from high.
Install and configure Memcached source code in CentOS 6.6
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
For details about Memcached, click here
Memcached: click here
This article permanently updates the link address: