成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

nginc+memcache

memcache 分為服務(wù)端和客戶端。服務(wù)端用來存放緩存,客戶端用來操作緩存。
因此,可以使用 Nginx 直接訪問 Memcache,并用$uri 和$args 等 Nginx 內(nèi)置變量設(shè)定緩存 key規(guī)則,這樣,當(dāng)緩存命中時(shí),Nginx 可以跳過通過 fastcgi 和 PHP 通信的過程,直接從 memcache中獲取數(shù)據(jù)并返回。
OpenResty是一個(gè)基于 Nginx 與 Lua 的高性能 Web 平臺(tái),其內(nèi)部集成了大量精良的 Lua 庫、第三方模塊以及大多數(shù)的依賴項(xiàng)。用于方便地搭建能夠處理超高并發(fā)、擴(kuò)展性極高的動(dòng)態(tài) Web 應(yīng)用、Web 服務(wù)和動(dòng)態(tài)網(wǎng)關(guān)。



1.下載openresty的壓縮包,opwnresty中含有自身的nginx,因此不需要額外安裝nginx
[root@server2 ~]# tar zxf openresty-1.11.2.3.tar.gz
[root@server2 ~]# cd openresty-1.11.2.3
[root@server2 openresty-1.11.2.3]# yum install gcc-c++ -y
[root@server2 openresty-1.11.2.3]# yum install pcre-devel -y
[root@server2 openresty-1.11.2.3]# yum install openssl-devel -y
[root@server2 openresty-1.11.2.3]# ./configure
[root@server2 openresty-1.11.2.3]# gmake
[root@server2 openresty-1.11.2.3]# gmake install
[root@server2 openresty-1.11.2.3]# cd /usr//local/openresty/nginx/conf/



2.更改配置文件
[root@server2 conf]# vim nginx.conf
###########################################
 18 http {
 19     upstream memcache {        ##nginx 模塊中,uosteam 主要用于完成數(shù)據(jù)的接收,處理,轉(zhuǎn)發(fā)
 20     server 127.0.0.1:11211;        ##設(shè)置默認(rèn)端口號(hào)
 21     }
 52         location /memc {
 53                 internal;        ##只接受內(nèi)部訪問,不接收外部 http 請求
 54                 memc_connect_timeout 100ms;
 55                 memc_send_timeout 100ms;
 56                 memc_read_timeout 100ms;
 57                 set $memc_key $query_string;    ##使用 Nginx 內(nèi)置的$query_string 來作為 key
 58                 set $memc_exptime 300;        ##緩存失效時(shí)間
 59                 memc_pass memcache;    
 60                 }    ##將請求的 URL 和后端服務(wù)返回的有效結(jié)果組成 key-value 存入 memcache服務(wù)
 72         location ~ \.php$ {
 73                 set $key $uri$args;
 74                 srcache_fetch GET /memc $key;
            ##注冊一個(gè)輸入攔截器到 location,這個(gè)配置將在location 進(jìn)入時(shí)被執(zhí)行
 75                 srcache_store PUT /memc $key;
            ##注冊一個(gè)輸出攔截器到 location,當(dāng) location執(zhí)行完成并輸出時(shí)會(huì)被執(zhí)行
 76                 root            html;
 77                 fastcgi_pass    172.0.0.60:9000;
 78                 fastcgi_index   index.php;
 79                 include         fastcgi.conf;
 80         }##為“~ \.php$”配置緩存,表示所有以“.php”結(jié)尾的請求都會(huì)結(jié)果被緩存
    }
##當(dāng)所請求的 uri 以“.php”結(jié)尾時(shí),首先到 memcache 中查詢有沒有以$uri$args 為 key 的數(shù)據(jù),如果有則直接返回;否則,執(zhí)行 location 的邏輯,如果返回的 http 狀態(tài)碼為 200,則在輸出前以$uri$args 為 key,將輸入結(jié)果存入 memcache

###########################################
[root@server2 conf]# /usr/local/openresty/nginx/sbin/nginx -t
[root@server2 conf]# /usr/local/openresty/nginx/sbin/nginx -s reload


[root@server2 conf]# /etc/init.d/httpd start    
##注意:http與nginx的端口號(hào)都為80,因此需要修改http的端口號(hào)
[root@server2 html]# /etc/init.d/iptables stop
[root@server2 html]# yum install memcached -y


測試:
1.開啟memcached,在物理機(jī)中進(jìn)行壓力測試
[root@server2 conf]# /etc/init.d/memcached start
[root@foundation60 Desktop]# ab -c 10 -n 50000 http://172.25.60.3/index.php
nginc+memcache

創(chuàng)新互聯(lián)主要從事網(wǎng)頁設(shè)計(jì)、PC網(wǎng)站建設(shè)(電腦版網(wǎng)站建設(shè))、wap網(wǎng)站建設(shè)(手機(jī)版網(wǎng)站建設(shè))、成都響應(yīng)式網(wǎng)站建設(shè)公司、程序開發(fā)、網(wǎng)站優(yōu)化、微網(wǎng)站、成都小程序開發(fā)等,憑借多年來在互聯(lián)網(wǎng)的打拼,我們在互聯(lián)網(wǎng)網(wǎng)站建設(shè)行業(yè)積累了豐富的做網(wǎng)站、成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、網(wǎng)絡(luò)營銷經(jīng)驗(yàn),集策劃、開發(fā)、設(shè)計(jì)、營銷、管理等多方位專業(yè)化運(yùn)作于一體。

2.關(guān)閉memcached,在物理機(jī)中進(jìn)行壓力測試
[root@server2 conf]# /etc/init.d/memcached stop
[root@foundation60 Desktop]# ab -c 10 -n 50000 http://172.25.60.3/index.php
nginc+memcache

本文名稱:nginc+memcache
本文來源:http://jinyejixie.com/article6/psheog.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄網(wǎng)站內(nèi)鏈、響應(yīng)式網(wǎng)站、微信小程序、云服務(wù)器商城網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)
威宁| 呼图壁县| 海晏县| 师宗县| 宁晋县| 承德市| 方正县| 武义县| 友谊县| 古田县| 通渭县| 修文县| 永济市| 白朗县| 丹江口市| 泰顺县| 长宁县| 高邑县| 东方市| 巴马| 县级市| 通榆县| 新干县| 延长县| 锡林郭勒盟| 深水埗区| 开远市| 拜城县| 叶城县| 墨玉县| 大姚县| 剑河县| 惠水县| 枣庄市| 登封市| 新巴尔虎左旗| 申扎县| 贵阳市| 泗洪县| 金平| 金川县|