Home > Database > Mysql Tutorial > body text

Boolean Education Yan 18 Memcached video data sharing

巴扎黑
Release: 2017-08-25 15:47:15
Original
1402 people have browsed it

Memcached is a high-performance distributed memory object caching system used in dynamic web applications to reduce database load. It improves the speed of dynamic, database-driven websites by caching data and objects in memory to reduce the number of database reads. 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 and communicates with the daemon through the memcached protocol.

Memcached is a high-performance distributed memory object caching system for dynamic web applications to reduce database load. It improves the speed of dynamic, database-driven websites by caching data and objects in memory to reduce the number of database reads. We have collected the "Boolean Education Yan 18 Memcached Video Tutorial", hoping to help everyone better learn Memcached distributed clusters.

Boolean Education Yan 18 Memcached video data sharing

Video playback address: http://www.php.cn/course/314.html

1. memcached Basic settings
1) Start the server side of Memcache
# /usr/local/bin/memcached -d -m 10 -u root -l 192.168.0.200 -p 12000 -c 256 -P /tmp/memcached. The pid

-d option is to start a daemon process,
-m is the amount of memory allocated to Memcache, in MB, here it is 10MB,
-u is the user running Memcache, I am root here,
-l is the IP address of the listening server, if there are multiple addresses, I have specified the IP address of the server 192.168.0.200,
-p is the port where Memcache is set to listen, here I am 12000 is set, preferably a port above 1024. The
-c option is the maximum number of concurrent connections. The default is 1024. I set 256 here. Set it according to the load of your server.
- P is the pid file that is set to save Memcache. I save it in /tmp/memcached.pid.

2) If you want to end the Memcache process, execute:

# kill `cat /tmp/ memcached.pid`

The hash algorithm maps a binary value of any length into a smaller binary value of a fixed length. This small binary value is called a hash value. A hash value is a unique and extremely compact numerical representation of a piece of data. If you hash a piece of plaintext and change even one letter of the

paragraph, subsequent hashes will produce different values. It is computationally impossible to find two different inputs that hash to the same value.

2. The purpose of the consistent Hash algorithm is twofold: first, after the node changes, other nodes are affected as little as possible; second, after the node changes, the data redistribution is as balanced as possible.

3. Why run memcached?

If the website has high traffic and most visits will cause a high load on the database, using memcached can reduce the pressure on the database.

4. What business scenarios are memcached suitable for?

1) If the website contains dynamic web pages with high traffic, the load on the database will be very high. Since most database requests are read operations, memcached can significantly reduce database load.

2) If the load of the database server is relatively low but the CPU usage is high, the calculated results (computed objects) and rendered web page templates (rendered templates) can be cached.

3) Memcached can be used to cache session data and temporary data to reduce database write operations for them.

4) Cache some small but frequently accessed files.

5) Caching the results of Web 'services' (not Web Services promoted by IBM, translator's note) or RSS feeds.

5. Business scenarios where memcached is not applicable?

1) The size of the cache object is greater than 1MB

Memcached itself is not designed to handle large multimedia (large media) and huge binary blocks (streaming huge blobs).

2) The key length is greater than 250 characters

3) The virtual host does not allow memcached service to be run

If the application itself is hosted on a low-end virtual private server, like vmware , virtualization technologies such as xen are not suitable for running memcached. Memcached needs to take over and control large blocks of memory. If the memory managed by memcached is swapped out by the OS or hypervisor, the performance of memcached will be greatly reduced.

4) The application runs in an unsafe environment

Memcached can provide no security policy, and you can access memcached only through telnet. If the application is running on a shared system, security issues need to be considered.

5) The business itself needs persistent data or a database

6. Can all items in memcached be traversed?

No, this operation is relatively slow and blocks other operations (the slowness here is compared to other memcached commands). All non-debug commands of memcached, such as add, set, get, fulsh, etc., no matter how much data is stored in

memcached, their execution only consumes constant time. The time taken to execute any command that traverses all items will increase as the amount of data in memcached increases. When other commands are waiting (traversing all

The command with item has been executed) but cannot be executed, so blocking will occur.

The above is the detailed content of Boolean Education Yan 18 Memcached video data sharing. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template