mysql長串連

來源:互聯網
上載者:User

標籤:socket   gpl   auth   nbsp   failed   run   pen   分享   client   

長串連是幹嘛的:  它是做串連複用的;

    在openresty中的lua-resty-mysql 裡

    connect方法去串連mysql時會去ngx_lua cosocket串連池中尋找是否有可用串連

    如果有就直接複用;

    如果沒有就與mysql建立新串連,串連成功後立即將這個串連放入ngx_lua cosocket串連池中。

 

本人用ngx-lua + mysql 做的一個測試

  

開啟長串連:

[[email protected] ~]#  webbench -c 100 -t 60 "http://www.new.cn/auth/test"
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://www.new.cn/auth/test
100 clients, running 60 sec.

Speed=47102 pages/min, 392419 bytes/sec.
Requests: 45901 susceed, 1201 failed.
[[email protected] ~]#  webbench -c 1000 -t 60 "http://www.new.cn/auth/test"
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://www.new.cn/auth/test
1000 clients, running 60 sec.

Speed=228165 pages/min, 1930685 bytes/sec.
Requests: 225810 susceed, 2355 failed.

 

 

 

 

 

關閉長串連:

 

[[email protected] ~]#  webbench -c 100 -t 60 "http://www.new.cn/auth/test"  
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://www.new.cn/auth/test
100 clients, running 60 sec.

Speed=32749 pages/min, 273873 bytes/sec.
Requests: 32191 susceed, 558 failed.


[[email protected] ~]#  webbench -c 1000 -t 60 "http://www.new.cn/auth/test"
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://www.new.cn/auth/test
1000 clients, running 60 sec.

Speed=46504 pages/min, 280990 bytes/sec.
Requests: 34301 susceed, 12203 failed.

 

mysql長串連

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.