nginx+php+memcached

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

nginx+php+memcached
nginx+php+memcached
refresh
nginx+php+memcached

2 Install memcache

nginx+php+memcached

1 Unzip

nginx+php+memcached

2 using phpzie

nginx+php+memcached

3 to configure

nginx+php+memcached

4 Compile and install

nginx+php+memcached

5 Load the corresponding memcache module into php

nginx+php+memcached
nginx+php+memcached
nginx+php+memcached
nginx+php+memcached

6 Access without memcache in php

nginx+php+memcached

7 Copy memcache related packets

nginx+php+memcached
nginx+php+memcached

8 Modify administrative users and linked hosts

nginx+php+memcached
nginx+php+memcached

9 Restart php to load the memcache dynamic module

nginx+php+memcached

10 Access to see if the above configuration is correct

nginx+php+memcached

11 Percentage of currently no visits

nginx+php+memcached

3 Install memecached server

1 Installation

nginx+php+memcached

2 Start and view the port 11211 it monitors

nginx+php+memcached

4 Stress testing on the client

nginx+php+memcached
Check the cache on the server
nginx+php+memcached

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

nginx+php+memcached

2 Download openresty and nginx-sticky-module-ng.tar.gz packages

Unzip
nginx+php+memcached
nginx+php+memcached
the specified path and add modules to
nginx+php+memcached
compile and install
nginx+php+memcached
nginx+php+memcached

3 Basic optimization

nginx+php+memcached
nginx+php+memcached

4 Configure the memcahe support module

nginx+php+memcached

nginx+php+memcached
nginx+php+memcached
Restart the service
nginx+php+memcached
for stress testing
nginx+php+memcached

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325152976&siteId=291194637