長連線是幹嘛的: 它是做連線復用的;
在openresty中的lua-resty-mysql 裡
connect方法去連線mysql時會去ngx_lua cosocket連線池中尋找是否有可用連線
如果有就直接復用;
如果沒有就與mysql建立新連線,連線成功後立即將這個連線放入ngx_lua cosocket連線池中。
本人用ngx-lua + mysql 做的乙個測試
開啟長連線:
關閉長連線:
[root@www ~]# webbench -c 100 -t 60 ""
webbench - ****** web benchmark 1.5
benchmarking: get
100 clients, running 60 sec.
speed=32749 pages/min, 273873 bytes/sec.
requests: 32191 susceed, 558 failed.
[root@www ~]# webbench -c 1000 -t 60 ""
webbench - ****** web benchmark 1.5
benchmarking: get
1000 clients, running 60 sec.
speed=46504 pages/min, 280990 bytes/sec.
requests: 34301 susceed, 12203 failed.
mysql 聊天室 聊天室php mysql 六
聊天室php mysql 六 相應的 資料庫 phpmyadmin mysql dump 主機 localhost 3306 資料庫 study28 資料表的結構 chat user create table chat user userid varchar 20 not null,passwd v...
聊天室程式
伺服器 include include include include include include include include define servport 8081 伺服器端口號 define bufsize 200 最大傳輸量 int main int args,char argv s...
簡單聊天室
include include include include include include include include include include pthread t thread 2 void send msg void ip msg if connect sockfd,struct ...