Nginx+php+memcached

Source: Internet
Author: User

A memcached:1 memcached Introduction:

Memcached is an open-source, high-performance, highly concurrent distributed memory cache system. Written in C, a total of more than 2000 lines of code mem (memory) cache (cache) d (daemon)
The Memcached service is divided into two parts, server and client, where the name of the server is Memcached
Client's name Memcache
The Memcached software was born in 2003 and was originally developed by LiveJournal's Brad Fitzpatrick. Simple and easy to deploy
The role of memcached
In traditional scenes, most Web applications save data to a relational database, the Web server reads the data from it and displays it in the browser, but as the amount of data increases, the burden of the relational database becomes heavier, slows down, and causes delays in the Web site, affecting the user experience.
The main purpose of using memcached is to reduce the number of times the database itself is accessed through the query results of cached relational databases in its own memory, to improve the speed of dynamic Web applications, and to improve the concurrency and scalability of the Web site architecture.
Web Read data
1 read memcached data, if present, displays the result
2 if memcached has no data, the program will read the database data directly, the database returns the results, the program will return the results into the memcached cache

2 Characteristics of Memcached

1 Protocol simple: The protocol using the text line, can directly manipulate the memcached service to store data through the command of TELENT/NC, etc.
2 supports the epoll/kqueue asynchronous I/O model, using libevent as the time-processing notification mechanism,
The Libevent will be conceal things encapsulated into an interface for memcached use
Nginx also supports this model
3 Key/value Key Value data type (hash table)
4 full memory cache, high efficiency
When the in-memory data capacity that reaches the server startup memory value set, it will automatically use the LRU algorithm to delete outdated cached data, can also be stored in the data to set the expiration time, so that the data will be automatically purged after expiration, the memcached service itself will not monitor data expiration, Instead, the timestamp at the time of access to the key determines whether it expires
5 can support distributed cluster
Memcached not to MySQL as the master-slave synchronization, distributed memcached cluster between the different servers are non-communication, each node is independent access to data, and the data content should be not the same, Through the design of the Web application side or through the support of hash algorithm load Balancer software, memcached can be used to support large-scale mass distributed storage cluster applications.

Two nginx+memcached+php (here memcached is PHP's cache)

Package:
Links: Https://pan.baidu.com/s/1KgJv-ptqWDatcI1pGSIStQ
Password: ia59

PHP configuration See: http://blog.51cto.com/11233559/2110593

1 Modify environment variables so that they can support phpize



Refresh

2 Installing Memcache

1 decompression

2 Using Phpzie

3 for Configure

4 Compiling and installing

5 loading the corresponding memcache module into PHP




6 access in PHP without booting memcache

7 copying Memcache-related packets


8 modifying managed users and linked hosts


9 Restart PHP to load the memcache dynamic module

10 access to see if the above configuration is correct

11 Currently there is no access in the case of the proportion

3 Installing Memecached server 1 Installation

2 Start and view Port 11211 for its monitoring

4 Stress testing on the client


Server-side View cache status

Two nginx+memcached+php (here memcached is nginx cache)

An nginx two-time development kit with support for Memcache modules is required at this time
Download this development kit

1 Turn off the original Nginx

2 download Openresty and nginx-sticky-module-ng.tar.gz pack

Extract


Specify its path and the added module

Compiling and installing

3 Basic optimization


4 Configuring the Memcahe support module



Restart Service

Perform stress tests

Nginx+php+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.