Distributed Application of memcache

Source: Internet
Author: User
ArticleDirectory
    • Official site

I have heard that memcached is a good distributed memory cache system. I have done some homework and want to use this memcache in practice. A good cache system can greatly improve the performance of Web applications. after doing some homework, I made the following summary:

    • Memcache can be installed on the same server as Web server.
    • Memcache can enable N processes on N ports. If it is on the same machine as the Web server, the network overhead can be reduced.
    • Simple configuration: Start a process without the configuration file

I am more concerned about how to deploy memcache distributed applications. with this problem, I did some further work on various search engines. the initial solution was to start n memcache processes on different ports of different servers.

The Perl API can be used to easily link Multiple memcache files at a time. The storage and read mechanism is unknown. soon I found a memcachedclient class in PHP, which is basically the re-implementation of APIs in Perl. it uses fscokopen or socket series functions to directly read and retrieve memcache. This indicates that you do not even need to install the memcache extenstion in PHP as long as you know the network protocol of memcache. after reading the implementation of this class, we basically figured out that its distributed application basically stores different keys in different memcache daemon without retaining multiple copies, there is no problem of multi-memcache synchronization.

After a while, I found that the memcache: addserver () method was found in the latest PHP manual, which was generated for distributed applications. With this support, PHPCodeIt is simpler:

<? PHP
$ Memcache_obj = new memcache;
$ Memcache_obj-> addserver ('memcache _ host', 11211 );
$ Memcache_obj-> addserver ('failed _ host', 11211 );

$ Stats = $ memcache_obj-> getextendedstats ();
Print_r ($ stats );
?>

It seems that the PHP manual should keep pace with the times. It is best to use the English version directly, otherwise it will not take so many detours :)

Official site

Http://www.danga.com/memcached/

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.