• mysql长连接


    长连接是干嘛的:  它是做连接复用的;

        在openresty中的lua-resty-mysql 里

        connect方法去连接mysql时会去ngx_lua cosocket连接池中寻找是否有可用连接

        如果有就直接复用;

        如果没有就与mysql建立新连接,连接成功后立即将这个连接放入ngx_lua cosocket连接池中。

    本人用ngx-lua + mysql 做的一个测试

      

    开启长连接:

    [root@www ~]#  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.
    [root@www ~]#  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.

    关闭长连接:

    [root@www ~]#  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.


    [root@www ~]#  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.

  • 相关阅读:
    [转]如何选购塑料水杯(塑料口杯、茶杯)
    【转】在sqlserver下增加MYSQL的链接服务器,实现分布式数据库开发第一步
    MySql: 查看当前登录用户,当前数据库
    python import, from xx import yy
    python class metaclass instance
    git: fatal: Not a git repository (or any of the parent directories): .git
    Python flask 基于 Flask 提供 RESTful Web 服务
    Python flask @app.route
    MySql: log 位置
    MySql: 忘记root密码
  • 原文地址:https://www.cnblogs.com/sixiong/p/6268883.html
Copyright © 2020-2023  润新知