memcached concept, function, operation principle, characteristics, insufficiency simple carding (1)

Source: Internet
Author: User
Tags memcached value store

People may have known about the memcached product, or have been used in their own website, but some friends have never heard or used.
It doesn't matter, this article is intended to introduce this product from various angles, as far as possible, if you can help in the present or future work, I will feel extremely honored.

memcached concept, function, operation principle, characteristics, insufficiency simple carding (1)

memcached download installation, net to memcached for CRUD operations (2)

memcached session data, access security, Usage scenario summary (3)

First, the concept of Memcached

The official explanations are as follows:

What is Memcached? Free & Open Source, High-performance, distributed memory object caching system, generic in nature, and intended for us E in speeding to dynamic Web applications by alleviating database load. Memcached is a in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database C Alls, API calls, or page rendering. Memcached is simple yet powerful. Its promotes quick deployment, ease of development, and solves many problems facing large data caches. Its APIs are available for most popular languages.

Memcached is an open source, high performance, distributed memory object caching system.

Website address: http://memcached.org/

: http://www.memcached.org/files/memcached-1.4.25.tar.gz

What's the difference between Memcache and memcached?

Memcache is a danga.com project, the first to serve LiveJournal, many people around the world use this cache project to build their own heavy load of the site, to share the pressure of the database.

Memcached is an open source, high performance, distributed memory object caching system

Memcache is the name of this project, and memcached is its server-side main program file name

Second, the role of Memcached

Memcached is a daemon that runs on one or more servers and accepts client connection operations at any time. The client first establishes a connection with the Memcached service and then accesses the object. The objects that are saved in Memcached are placed in memory, not on the hard disk.

After the Memcached process runs, it will pre-request a larger memory space, manage it yourself, use it and then apply it, not every time you need to go to the operating system to apply. Memcached saves objects in a huge hash table, and it uses the Newhash algorithm to manage the hash table for further performance gains. So when the memory allocated to memcached is large enough, the memcached time consumption is basically just a network socket connection.

In summary, memcached is used for dynamic Web applications to mitigate database load. It improves the speed of dynamic, database-driven Web sites by caching data and objects in memory to reduce the number of times a database is read.

Three, Memcached operation principle

Memcached processes atoms are each (key,value) pair (hereinafter referred to as KV pair), key will be converted to Hash-key by a hash algorithm, easy to find, compare and do as much as possible hash. At the same time, Memcached uses a two-level hash, which is maintained by a large hash table.

Memcached has two core components: server and client, in a memcached query, the client first determines the Server location of the kv pair by calculating the hash value of the key. When the server is determined, the client sends a query request to the corresponding server, allowing it to find the exact data. Because there is no interaction and multicast protocol, the impact of memcached interaction on the network is minimized.

Iv. Characteristics of Memcached

1. Open source

Open Source Address: Https://github.com/memcached/memcached/wiki

2. High performance

No matter what kind of database (oracle,mssql,mysql,db2 ...), how to optimize, and finally can not open and slow hard disk for data exchange, but often once involved in the hard disk IO operation, access performance will drop sharply. The whole operation of memcached is in memory all the while, so it is very efficient to access data.

Of course, large Web sites are optimized for database operations (read-write separation, according to the business sub-database table).

3. Distributed

Distributed system on-line comparative professional explanation is: a kind of computer hardware configuration and the corresponding function configuration method. It is a multiprocessor computer system in which each processor forms a unified system through an interconnected network. The system adopts distributed computing structure, that is, the task of processing the CPU in the original system is distributed to the corresponding processor, and the various processors of different functions are coordinated with each other, and the peripherals and software of the system are shared. This accelerates the processing speed of the system and simplifies the logical structure of the host.

The distributed features of the memcache are: the memcached server can be installed on any number of servers, providing parallel storage and computing capabilities, memcached client and server side can be installed on any separate server.

V. Lack of Memcached

1, the data is stored in memory, once the service process restarts, the data will be lost all

Countermeasure: Can take change memcached source code, increase the function that write to hard disk regularly

2, memcached run with root privileges, and memcached itself does not have any rights management and authentication functions, security is insufficient

Countermeasures: The memcached service can be bound to the intranet IP, through the firewall to protect

memcached concept, function, operation principle, characteristics, insufficiency simple carding (1)

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.