怎样测量一台WEB(Django)服务器的负载能力.

发布于 2021-11-28 18:48:17 字数 5068 浏览 746 评论 5

最近在学着用Django开发一个服务器, 如何去测量它的性能,用谷哥搜一圈对这些概念还是一头雾水,比如:

  QPS(TPS):每秒钟request/事务 数量

        并发数: 系统同时处理的request/事务数

        响应时间:  一般取平均响应时间

对上面这些概念没有直观的理解.下面是我用AB工具比着测试了一下,下面这个URL的请求就是一个用户登录的请求,登录成功后会分别在postgresql 与redis 里插入一条记录.请行家给解释指教 一下,这个结果达到一个什标准 ,非常感谢:

# ab -n 1000000 -c 20000  "http://192.168.25.109:8090/app/auth/?uuid=623cc896cb764ccf9ed207848fd29eb5&key=123456"
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.25.109 (be patient)
Completed 100000 requests
Completed 200000 requests
Completed 300000 requests
Completed 400000 requests
Completed 500000 requests
Completed 600000 requests
Completed 700000 requests
Completed 800000 requests
Completed 900000 requests
Completed 1000000 requests
Finished 1000000 requests


Server Software:        nginx/1.9.15
Server Hostname:        192.168.25.109
Server Port:            8090

Document Path:          /app/auth/?uuid=623cc896cb764ccf9ed207848fd29eb5&key=123456
Document Length:        537 bytes

Concurrency Level:      20000
Time taken for tests:   45.129 seconds
Complete requests:      1000000
Failed requests:        16948
   (Connect: 0, Receive: 0, Length: 16948, Exceptions: 0)
Non-2xx responses:      983052
Total transferred:      704407228 bytes
HTML transferred:       530542812 bytes
Requests per second:    22158.68 [#/sec] (mean)
Time per request:       902.581 [ms] (mean)
Time per request:       0.045 [ms] (mean, across all concurrent requests)
Transfer rate:          15242.91 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       33  376  68.3    380    1341
Processing:    66  514 136.1    493    2082
Waiting:       55  387 139.2    358    1955
Total:        139  890 135.4    881    2287

Percentage of the requests served within a certain time (ms)
  50%    881
  66%    921
  75%    948
  80%    968
  90%   1014
  95%   1071
  98%   1229
  99%   1343
 100%   2287 (longest request)

我的NGINX配置 :

worker_processes auto;  
worker_rlimit_nofile 1048576;
events {
    use epoll;
    multi_accept on;
    worker_connections  65535;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  10;
    server {
        listen       8090;
        server_name  192.168.25.109;
        location / {
        include     uwsgi_params;
        uwsgi_pass  unix:///tmp/uwsgi.sock;
        }  
}


uWSGI的配置 :

[uwsgi]
project = mqtt_auth
base = /home/www

chdir = %(base)/%(project)

module = %(project).wsgi:application
uid = nginx
gid = nginx
disable-logging = true

virtualenv = /home/www/virtualenv
master = true

processes = 20
max-requests = 65536

socket = /tmp/uwsgi.sock
chmod-socket = 664
daemonize=/home/www/log/uwsgi.log

vcauum = true

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

好听的两个字的网名 2021-12-03 17:50:14

这是我后面再次调优的结果,请行帮忙评价一下.谢谢

心欲静而疯不止 2021-12-03 17:37:51
ab -n 1000000 -c 20000 "http://192.168.25.109:8090/app/auth/?uuid=623cc896cb764ccf9ed207848fd29eb5&key=123456"
This is ApacheBench, Version 2.3 <$Revision: 1706008 
gt;
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.25.109 (be patient)
Completed 100000 requests
Completed 200000 requests
Completed 300000 requests
Completed 400000 requests
Completed 500000 requests
Completed 600000 requests
Completed 700000 requests
Completed 800000 requests
Completed 900000 requests
Completed 1000000 requests
Finished 1000000 requests


Server Software:        nginx/1.9.15
Server Hostname:        192.168.25.109
Server Port:            8090

Document Path:          /app/auth/?uuid=623cc896cb764ccf9ed207848fd29eb5&key=123456
Document Length:        537 bytes

Concurrency Level:      20000
Time taken for tests:   49.030 seconds
Complete requests:      1000000
Failed requests:        4697
   (Connect: 0, Receive: 0, Length: 4697, Exceptions: 0)
Non-2xx responses:      995303
Total transferred:      709172867 bytes
HTML transferred:       535210443 bytes
Requests per second:    20395.81 [#/sec] (mean)
Time per request:       980.594 [ms] (mean)
Time per request:       0.049 [ms] (mean, across all concurrent requests)
Transfer rate:          14125.15 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0  406  89.4    407    1422
Processing:   107  521 236.4    487    7140
Waiting:       92  391 238.8    348    7046
Total:        216  927 241.8    902    7528

Percentage of the requests served within a certain time (ms)
  50%    902
  66%    935
  75%    965
  80%    988
  90%   1042
  95%   1075
  98%   1159
  99%   1359
 100%   7528 (longest request)

灵芸 2021-12-03 17:21:13

jmeter压力测试压一下就知道了

自此以后,行同陌路 2021-12-02 21:03:16

用测试负载的工具

岁吢 2021-12-01 16:19:26

根据服务器配置,先计算一下,会得出一个预估值

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文