A memcached:
1 memcached introduction:
Memcached is an open source, high-performance, high-concurrency distributed memory caching system. Written in C language, a total of more than 2000 lines of code mem (memory) Cache (cache) d (daemon process)
Memcached service is divided into two parts: server and client, where the name of the server is the name of the memcached
client memcache
Memcached software was born in 2003 In 2009, it was originally developed by Brad Fitzpatrick of LiveJournal. The protocol is simple and the deployment is convenient
. The role of memcached in
traditional scenarios, most web applications save data in relational databases, the web server reads the data from it and displays it in the browser, but with the data If the volume increases, the access is concentrated, the burden on the relational database will increase, the response will be slow, and the website opening delay will be caused, which will affect the user experience. The main purpose of using memcached is to reduce the number of times the database itself is accessed by caching the query results of the relational database in its own memory, to improve the speed of dynamic web
applications, and to improve the concurrency and scalability of the website architecture. 1 Read the data of memcached, if it exists, display the result 2 If there is no data in memcached, the program will directly read the data of the database, the database returns the result, and the program stores the returned result in the memcached cache
2 Features of Memcached
1. The protocol is simple: using the text line protocol, you can directly operate the memcached service to store data through commands such as telent/nc.
2. Support the epoll/kqueue asynchronous I/O model, and use libevent as the time processing notification mechanism.
Libevent will encapsulate things into interfaces, Provided to memcached using
NGINX also supports this model
3 key/value key value data type (hash table)
4 Full memory cache, high efficiency
When the data capacity in memory reaches the memory value set when the server starts, it will be used automatically The LRU algorithm deletes expired cached data, and it is also possible to set an expiration time for the stored data when storing the data, so that the data will be automatically cleared after expiration. The memcached service itself will not monitor the expiration of the data, but the time when the key is accessed.
Stamp
to determine whether it has expired It should be different. Memcached can support large-scale and massive distributed storage cluster applications through programming on the web application side or through load balancing software that supports hash algorithms.
Two nginx+memcached+PHP (here memcached is PHP's cache)
Package:
Link: https://pan.baidu.com/s/1KgJv-ptqWDatcI1pGSIStQ
Password: ia59
See PHP configuration: http://blog.51cto.com/11233559/2110593
1 Modify the environment variable so that it can support phpize
refresh
2 Install memcache
1 Unzip
2 using phpzie
3 to configure
4 Compile and install
5 Load the corresponding memcache module into php
6 Access without memcache in php
7 Copy memcache related packets
8 Modify administrative users and linked hosts
9 Restart php to load the memcache dynamic module
10 Access to see if the above configuration is correct
11 Percentage of currently no visits
3 Install memecached server
1 Installation
2 Start and view the port 11211 it monitors
4 Stress testing on the client
Check the cache on the server
Two nginx+memcached+PHP (here memcached is the cache of nginx)
At this time, you need to have the nginx secondary development package that supports the memcache module to
download this development package
1 Turn off the original nginx
2 Download openresty and nginx-sticky-module-ng.tar.gz packages
Unzip
the specified path and add modules to
compile and install
3 Basic optimization
4 Configure the memcahe support module
Restart the service
for stress testing