PHP and memcache installation instructions. After the website traffic has recently increased, the number of database connections has been high. after analysis, all requests are normal, but the website features are fine. there are too many database queries on a single page, many of the data is that the number of database connections has been high since the recent website traffic was up. after analysis, the requests are normal, but the website features are fine, and there are too many database queries on a single page, A lot of data does not need to be queried in real time, so it can be cached! Memcache must be used for caching to reduce the pressure on mysql!
Project name: Weather forecast 15 days Query website http://15tianqi.cn
Cause: too many mysql connection requests and high database pressure
Solution: Install and enable memcache cache
What is Memcache? Memcache is a free and open source code, high-performance, and allocated memory object cache system. It is used to accelerate dynamic web applications and reduce database load.
It can cope with any number of connections and use non-blocking network I/O. Because its working mechanism is to open up a space in the memory, and then create a HashTable, Memcached self-manages these HashTable. Memcached is simple and powerful. Its simple design promotes rapid deployment and is easy to develop. it solves many large data caches. Its APIs are available in the most popular languages.
In any case, to use the memcache memory cache, you must install memcache in php and then install memecached in linux. In this way, PHP can use memecache to access data in the memory.
1. download memcached.
cd /usr/local/srcwget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
2. install memcached.
tar zxvf memcached-1.4.15.tar.gzcd memcached-1.4.15./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libeventmakemake install
3. start memcached and check for installation
/usr/local/memcached/bin/memcached -d -m 128 -p 11211 -u rootps aux | grep memcached
Memcache is a very useful caching technology. Memcache's well-known users include LiveJournal, Wikipedia, Flickr, Bebo, Twitter, Typepad, Yellowbot, and Youtube.
...