What is the difference between APC and Memcache? which one is better and more efficient?

Source: Internet
Author: User
Php Chinese network (www.php.cn) provides the most comprehensive basic tutorial on programming technology, introducing HTML, CSS, Javascript, Python, Java, Ruby, C, PHP, basic knowledge of MySQL and other programming languages. At the same time, this site also provides a large number of online instances, through which you can better learn programming... Reply: APC is used as Opcode Cache and MemCache is used as CotentCache.
I add that when APC is used as the Content Cache, it is a single-host Cache, while MemCache can achieve multi-host sharing. Therefore, for Session sharing issues, you can only use a Cache similar to MemCache.
In addition, if you use APC to cache variable content due to design problems, the cached content may not be synchronized. (I don't know if it has been fixed in the future. I haven't paid much attention to the Upgrade of APC for more than a year.) due to the features of PHP, after each execution of the page, all running objects are released, so APC and Memcached can be used to share and cache data between scripts and processes.

APC is an extension of PHP and will be loaded into PHP processes. apart from interpreting PHP code as OPCode and saving it in memory, it can also use shared memory (the data structure of the system kernel) between PHP processes to save data, and it is completely transparent.

Memcached is an external service that shares/caches data through tcp or udp network protocols.

Memcached allows you to share and cache data between multiple machines, or share data with other non-php applications. However, due to the use of network protocols for interaction, in addition, php objects need to be serialized and deserialized during the interaction process. The latency is much higher than that of APC directly integrated in the PHP process.

Facebook uses both APC and Memcache as two-layer caches. APC is based on shared memory, which is theoretically faster. However, it is difficult to share data with non-PHP processes and external machines. Based on open protocols, Memecache allows N machines in N languages and N processes to access data. The disadvantage is that Memecache is a little slower than APC. Apc is used to interpret php code as opcode and then stored in the memory.
Mc for data caching
Usually used together

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.