Memcache (i) overview

Source: Internet
Author: User
Tags apc memcached

Overview

Memcache is a distributed caching system that is based on a network connection (which, of course, can also be done using localhost), which is itself an application-independent program or daemon (daemon mode).

Local cache

Memcached is a "distributed" Memory object caching system, that is, those that do not need to be "distributed", do not need to be shared, or simply small to a single server application, memcached will not bring any benefits, but also slow down the system efficiency, because the network connection also requires resources, Even UNIX local connections are the same. Memcached local read and write speeds are dozens of times times slower than direct PHP memory arrays, and APC, shared memory is similar to direct arrays. It can be seen that the use of memcached is very uneconomical if it is just a local-level cache.

Concurrent connections

Memcached uses the Libevent library to implement network connectivity services, theoretically can handle an unlimited number of connections, but it is different from Apache, it is more time for stable continuous connection, so its actual concurrency capacity is limited. In a conservative case, the maximum number of simultaneous connections for memcached is 200, which is related to the Linux threading capability, which can be adjusted. Refer to the relevant documentation for Libevent.

Memory management memcached Memory usage also differs from APC. APC is based on shared memory and Mmap, MEMCACHD has its own memory allocation algorithm and management mode, it is not related to shared memory, there is no shared memory limit, usually, each memcached process can manage 2GB of memory space, if more space is needed, You can increase the number of processes. Reducing the database pressure memcached is often used as the database front-end cache. Because it is much less expensive than database SQL parsing, disk operations, and it is using memory to manage the data, it can provide better performance than directly read the database, in large systems, access to the same data is very frequent, memcached can greatly reduce the database pressure,  Improve the efficiency of system execution. Memcached is also often used as a storage medium for data sharing between servers, such as storing data in the SSO system as a single-point login, which can be saved in memcached and shared by multiple applications.  Applications because memcache are distributed, you can provide shared resources for different servers in a Web project. Because memcache is storing data directly in memory, in order to reduce the pressure of the database, you can add a layer of memcache cache between the Web and the database. And in Memcache, the data stored in memory is stored according to the hash, so the sales of the lookup data will be much higher than the database.

Memcache (i) overview

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.