What is memcached? Memcache What should I use? _php Tutorials

Source: Internet
Author: User
Tags apc
What is memcached?

Memcached is a set of distributed memory object caching systems developed by danga.com (the technical team of operations LiveJournal) to reduce database load and improve performance in dynamic systems. Many people use it as a storage carrier of the same form as sharedmemory, although memcached uses the same "key=>value" to organize data, but it differs greatly from local caches such as shared memory and APC. The memcached is distributed, meaning it is not local. It is based on a network connection (and of course it can also use localhost) to complete the service, which is itself an application-independent program or daemon (daemon mode).

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.

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.

memcached How do I use it?

In many cases, memcached have been abused, and it is inevitable that too many people have complained about him. I often see people posting on the forum, similar to "How to improve efficiency", reply is "use memcached", as to how to use? Where do you use it? For what? The answer to the detailed point is not a word. Here the author wants to clarify the point that memcached is not omnipotent, and that it is not applicable to all occasions.

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.

As shown in my previous test data, the memcached local read and write speed is dozens of times times slower than the direct PHP memory array, and the APC, shared memory mode is almost the same as the direct array. It can be seen that the use of memcached is very uneconomical if it is just a local-level cache.

Memcached is often used as a 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. In addition, memcached is 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.

It is important to note that Memcached uses memory to manage data, so it is volatile, when the server restarts, or the memcached process aborts, the data is lost, so memcached cannot be used to persist the data. Many people's misunderstanding, memcached performance is very good, good to the memory and hard disk contrast, in fact, memcached use memory does not get hundreds of read and write speed, its actual bottleneck is the network connection, it and the use of disk database system, the advantage is that it itself very "light "Because there is not too much overhead and direct reading and writing, it can easily cope with very large amounts of data exchange, so there are often two gigabit network bandwidth is full load, memcached process itself does not occupy much CPU resources.

Articles you may be interested in

    • PHP fatal error allowed memory size of ... How memory-deficient errors should be resolved
    • Installation and configuration tutorial for memcache under Windows
    • What does the body mean? "What does HTML > body mean in >css?
    • PHP calculates a function that is currently the first week of the year or January
    • MySQL Replace function replaces the use of a string statement
    • Comparison of performance when using In_array () foreach Array_search () to find out if an array is included
    • Mysql Database caching cache function analysis, debugging and performance summary
    • PHP string Escape function (Addslashes,stripslashes) detailed

http://www.bkjia.com/PHPjc/764126.html www.bkjia.com true http://www.bkjia.com/PHPjc/764126.html techarticle What is memcached? Memcached is a set of distributed memory object caching systems developed by danga.com (the technical team of operations LiveJournal) to reduce database load in dynamic Systems .

  • 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.