Php Memcached distributed cache (1/3)

Source: Internet
Author: User
Tags php memcached

1. What is memcached?

Memcached is a high-performance distributed memory object Cache System for dynamic web applications to reduce the database tutorial load. It caches data and objects in the memory to reduce the number of times the database is read, so as to provide dynamic, database-driven website speed.

I believe many people have used the cache. net also has a built-in cache mechanism, and many third-party tools such as apache and nginx can cache static resources. At the same time, we can also develop our own cache mechanism, cache the data queried by the database to reduce frequent operations on the database. However, we often feel that these caches are not satisfactory. memcached can solve many of your troubles. At least I solved a lot of problems in my studies, so I decided to record them and share them.

Memcached is based on a hashmap that stores key/value pairs. Its daemon is written in c, but the client can be written in any language (this article uses c # as an example) and communicates with the daemon through the memcached protocol. However, these things are too advanced. We will not study them for the moment.

 

Ii. distributed cache

In fact, memcached serves as a distributed cache data service, but each service does not communicate with each other at all. Here, it may be a little different from what I understand in distributed architecture. It may be that I am not familiar with it, it may also be that everyone thinks differently. The memcached client saves data to different memcached servers through a distributed algorithm and caches the data. Distributed cache, but we know that memcached can cache large amounts of data. This can make up for what we have encountered before to cache data on the application server, and only a small amount of data can be cached, otherwise it will have a huge impact on the application server.
Memcached application mechanism diagram:

 

This figure is a bit simple, but the problem can still be clearly described. The basic principle of the cache mechanism is to first query data and save it to memcached, the address directly retrieves data from the memcached cache for this request, which reduces the load on server requests.

 

 

1 2 3

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.