摘要:调大uwsgi配置中 listen=1024的数目是提高并发能力最有效的办法。第二种方法是调大processes数目

发现总是超时报警

1  使用ab确定网络具体征况

[bre@dmp-1 ~]$ ab -n 1000 -c 100 http://.com/Mapping.do?





Concurrency Level:      100

Time taken for tests:   1.040 seconds

Complete requests:      1000

Failed requests:        0

Write errors:           0

Non-2xx responses:      1000

Total transferred:      486000 bytes

HTML transferred:       0 bytes

Requests per second:    961.42 [#/sec] (mean)

Time per request:       104.013 [ms] (mean)

Time per request:       1.040 [ms] (mean, across all concurrent requests)

Transfer rate:          456.30 [Kbytes/sec] received





Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    0   0.4      0       2

Processing:     3   28  61.9     25    1005

Waiting:        3   28  61.9     25    1005

Total:          5   28  61.9     25    1006





Percentage of the requests served within a certain time (ms)

  50%     25

  66%     26

  75%     26

  80%     26

  90%     27

  95%     27

  98%     29

  99%     31

100%   1006 (longest request)

[bre@dmp-1 ~]$ ab -n 1000 -c 200 http://.com/Mapping.do?



Concurrency Level:      200

Time taken for tests:   3.022 seconds

Complete requests:      1000

Failed requests:        0

Write errors:           0

Non-2xx responses:      909

Total transferred:      463432 bytes

HTML transferred:       0 bytes

Requests per second:    330.91 [#/sec] (mean)

Time per request:       604.403 [ms] (mean)

Time per request:       3.022 [ms] (mean, across all concurrent requests)

Transfer rate:          149.76 [Kbytes/sec] received





Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    1   1.2      0       4

Processing:     6  274 791.9     28    3015

Waiting:        6  274 791.9     28    3015

Total:         10  275 792.5     29    3018





Percentage of the requests served within a certain time (ms)

  50%     29

  66%     29

  75%     30

  80%     30

  90%     43

  95%   3015

  98%   3015

  99%   3016

 100%   3018 (longest request)

[bre@dmp-1 ~]$ ab -n 1000 -c 300 http://.com/Mapping.do?





Concurrency Level:      300

Time taken for tests:   3.036 seconds

Complete requests:      1000

Failed requests:        0

Write errors:           0

Non-2xx responses:      811

Total transferred:      439128 bytes

HTML transferred:       0 bytes

Requests per second:    329.35 [#/sec] (mean)

Time per request:       910.892 [ms] (mean)

Time per request:       3.036 [ms] (mean, across all concurrent requests)

Transfer rate:          141.24 [Kbytes/sec] received





Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    2   2.4      0       6

Processing:     5  521 1043.3     29    3027

Waiting:        5  521 1043.3     29    3027

Total:         10  523 1044.8     29    3032





Percentage of the requests served within a certain time (ms)

  50%     29

  66%     31

  75%     35

  80%     53

  90%   3021

  95%   3027

  98%   3029

  99%   3030

 100%   3032 (longest request)

[bre@dmp-1 ~]$ 

[bre@dmp-1 ~]$ ab -n 1000 -c 400 http://.com/Mapping.do?

Concurrency Level:      400

Time taken for tests:   3.025 seconds

Complete requests:      1000

Failed requests:        0

Write errors:           0

Non-2xx responses:      711

Total transferred:      414328 bytes

HTML transferred:       0 bytes

Requests per second:    330.58 [#/sec] (mean)

Time per request:       1209.982 [ms] (mean)

Time per request:       3.025 [ms] (mean, across all concurrent requests)

Transfer rate:          133.76 [Kbytes/sec] received





Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    3   3.7      0       9

Processing:     6  738 1148.8     28    3013

Waiting:        6  738 1148.8     28    3013

Total:         13  741 1151.3     28    3022





Percentage of the requests served within a certain time (ms)

  50%     28

  66%     38

  75%   2011

  80%   2016

  90%   3013

  95%   3016

  98%   3019

  99%   3019

 100%   3022 (longest request)

[bre@dmp-1 ~]$ ab -n 1000 -c 500 http://cm.api.baifendian.com/Mapping.do?bfd_nid=behe

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/





Benchmarking cm.api.baifendian.com (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Completed 600 requests

Completed 700 requests

Completed 800 requests

Completed 900 requests

Completed 1000 requests

Finished 1000 requests









Server Software:        nginx/1.2.9

Server Hostname:        cm.api.baifendian.com

Server Port:            80





Document Path:          /Mapping.do?bfd_nid=behe

Document Length:        0 bytes





Concurrency Level:      500

Time taken for tests:   3.100 seconds

Complete requests:      1000

Failed requests:        0

Write errors:           0

Non-2xx responses:      610

Total transferred:      389280 bytes

HTML transferred:       0 bytes

Requests per second:    322.63 [#/sec] (mean)

Time per request:       1549.754 [ms] (mean)

Time per request:       3.100 [ms] (mean, across all concurrent requests)

Transfer rate:          122.65 [Kbytes/sec] received





Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    5   4.7      9      10

Processing:     9  930 1168.2     31    3014

Waiting:        9  930 1168.2     31    3014

Total:         18  935 1171.1     33    3023





Percentage of the requests served within a certain time (ms)

  50%     33

  66%   2012

  75%   2016

  80%   2018

  90%   3018

  95%   3020

  98%   3021

  99%   3021

 100%   3023 (longest request)

[bre@dmp-1 ~]$ ab -n 1000 -c 600 http://cm.api.baifendian.com/Mapping.do?bfd_nid=behe

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/





Benchmarking cm.api.baifendian.com (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Completed 600 requests

Completed 700 requests

Completed 800 requests

Completed 900 requests

Completed 1000 requests

Finished 1000 requests









Server Software:        nginx/1.2.9

Server Hostname:        cm.api.baifendian.com

Server Port:            80





Document Path:          /Mapping.do?bfd_nid=behe

Document Length:        0 bytes





Concurrency Level:      600

Time taken for tests:   3.039 seconds

Complete requests:      1000

Failed requests:        0

Write errors:           0

Non-2xx responses:      511

Total transferred:      364728 bytes

HTML transferred:       0 bytes

Requests per second:    329.08 [#/sec] (mean)

Time per request:       1823.243 [ms] (mean)

Time per request:       3.039 [ms] (mean, across all concurrent requests)

Transfer rate:          117.21 [Kbytes/sec] received





Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    7   5.2     10      12

Processing:     9 1126 1170.6     45    3022

Waiting:        9 1126 1170.6     45    3022

Total:         21 1133 1173.4     55    3033





Percentage of the requests served within a certain time (ms)

  50%     55

  66%   2014

  75%   2017

  80%   2019

  90%   3019

  95%   3025

  98%   3028

  99%   3031

 100%   3033 (longest request)

可以看到,每秒处理请求数目极限大约是300,随着并发数目的增大,性能开始下降。

现在的请求每天1000000条,那么高峰时段的请求次数为:1000000/(8*60*60)*10 =  347 (次每秒)

每天正常请求时段是8小时,高峰时段请求频次是平均的8~10倍。

所以只是勉强够用而已,还需要提高速度(优化整个程序流程或者增大并发进程)。

2   使用 uwsgitop 查看是前端(nginx)还是后端(uwsgi和后续处理流程)

观察结果

uwsgi-1.9.14 - Mon Feb 10 16:17:16 2014 - req: 188802 - lq: 0 - tx: 66.0M                             node: dmp-1 - cwd: /opt/bre/CookieMapping/dsWebService - uid: 508 - gid: 503 - masterpid: 25062

 WID    %       PID     REQ     EXC     SIG     STATUS  AVG     RSS     VSZ     TX      RunT    

 7      41.4    25073   78127   0       0       idle    1ms     0       0       25.0M   217637

 5      10.0    25071   18956   0       0       idle    1ms     0       0       6.0M    105123

 8      9.1     25076   17213   0       0       idle    1ms     0       0       6.0M    101432

 4      9.1     25070   17196   0       0       idle    1ms     0       0       6.0M    99265

 6      9.0     25072   17032   0       0       idle    1ms     0       0       6.0M    95653

 2      7.6     25068   14312   0       0       idle    1ms     0       0       5.0M    93229

 1      7.1     25067   13489   0       0       idle    17ms    0       0       5.0M    85652

 3      6.6     25069   12477   0       0       idle    2ms     0       0       4.0M    91285

发现当使用ab测试时,当并发比较大时候,时间会出现很大的情况

3  措施

(1)首先,uwsgi观察到上面的负载不均衡,第7个线程负责的请求数远大于其他的。

调整使之均衡

(2)再机器能力足够的情况下,增加线程数目

(3)建立uwsgi集群,在另外一台机器上也部署此服务,并让nginx转发部分到此

uwsgi性能调忧的更多相关文章

  1. centos 7上nginx+uwsgi 性能调优

    上一章将nginx +uwsgi搭建起来,将keystone挂载后面.但是发现一个问题,如果http请求达到一定量后,nginx直接返回502.这让需要部署大规模openstack集群的我很是头疼,比 ...

  2. web前端性能调优

    最近2个月一直在做手机端和电视端开发,开发的过程遇到过各种坑.弄到快元旦了,终于把上线了.2个月干下来满满的的辛苦,没有那么忙了自己准备把前端的性能调优总结以下,以方便以后自己再次使用到的时候得于得心 ...

  3. [网站性能2]Asp.net平台下网站性能调优的实战方案

    文章来源:http://www.cnblogs.com/dingjie08/archive/2009/11/10/1599929.html 前言    最近帮朋友运营的平台进行了性能调优,效果还不错, ...

  4. Asp.net平台下网站性能调优的实战方案(转)

    转载地址:http://www.cnblogs.com/chenkai/archive/2009/11/07/1597795.html 前言 最近帮朋友运营的平台进行了性能调优,效果还不错,所以写出来 ...

  5. 第0/24周 SQL Server 性能调优培训引言

    大家好,这是我在博客园写的第一篇博文,之所以要开这个博客,是我对MS SQL技术学习的一个兴趣记录. 作为计算机专业毕业的人,自己对技术的掌握总是觉得很肤浅,博而不专,到现在我才发现自己的兴趣所在,于 ...

  6. sqlserver性能调优第一步

    相信不少的朋友,无论是做开发.架构的,还是DBA等,都经常听说“调优”这个词.说起“调优”,可能会让很多技术人员心头激情澎湃,也可能会让很多人感觉苦恼,不知道如何入手.当然,也有很多人对此不屑一顾,因 ...

  7. JavaScript:内存泄露、性能调优

    1.在进行JS内存泄露检查之前,先要了解JS的内存管理: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Manageme ...

  8. hadoop 性能调优与运维

    hadoop 性能调优与运维 . 硬件选择 . 操作系统调优与jvm调优 . hadoop运维 硬件选择 1) hadoop运行环境 2)  原则一: 主节点可靠性要好于从节点 原则二:多路多核,高频 ...

  9. JVM性能调优监控工具jps、jstack、jmap、jhat、jstat、hprof使用详解

    摘要: JDK本身提供了很多方便的JVM性能调优监控工具,除了集成式的VisualVM和jConsole外,还有jps.jstack.jmap.jhat.jstat.hprof等小巧的工具,本博客希望 ...

随机推荐

  1. Inno Setup入门(十四)——替换安装程序和卸载程序的图标

    通常Inno生成的安装文件的图标是一个光盘和显示器,如下图.同时,程序安装好之后,在安装目录下的卸载程序的图标也是一样的,其实我们也可以自己修改. 首先生成的安装文件图标.这个比较简单,只需要在Set ...

  2. IOS 中常用站位符

      CGPoint.CGRect等可以转化为字符串打印出来 如:   NSLog(@"-------------%@",NSStringFromCGPoint(point));   ...

  3. css(非表格变成表格用)

    父元素:display:table: 子元素:display:table-cell:vertical-align:middle:

  4. java获取数据库的列名、类型等信息

    当你使用和学习JDK的时候,可以查看并学习它所提供给你的两个ResultSetMetaData 和DataBaseMetaData类的源码并很好的了解它们的实现原理和思路,JDBC中提供有两种源数据, ...

  5. HDU 1155 Bungee Jumping 物理

    题目大意:给出k:绳子的劲度系数,l:绳长,s:桥高,w:邦德的质量,g取9.81.绳子弹力=形变量*劲度系数.如果落地速度大于10 则摔死,小于0则飘着空中. 题目思路:根据能量守恒得知:落地的动能 ...

  6. linux视频学习5(top, 网络监控

    top命令的详解: 1. top :动态监控进程. 第一行:当前系统时间:  up  4days :服务器启动后的持续时间. 5 user 当前服务器上的用户数目 ; load average :负载 ...

  7. contentHorizontalAlignment 属性浅析

    转载自:http://blog.csdn.net/s0228g0228/article/details/46832285 最近在iOS 7以上总是碰到导航条上左右按钮距离边距太大的问题 为了解决这个这 ...

  8. sonar tomacat配置

    最近在学习Sonar,配置了好几天,才搭建起来环境,为自己的学习能力感到汗颜,赶紧在此记录一下,所谓好记性不如烂笔头. 1.Sonar介绍 Sonar是一个用于代码质量管理的开源平台,用于管理Java ...

  9. ElasticSearch — 集群搭建

    1.es需要java环境,故先检查java环境是否正常 2.下载elasticsearch安装包 http://www.elasticsearch.org/download/ 目前最新版本到1.4.0 ...

  10. AngularJS 从零开始学习(一)

    什么是AngularJS? AngularJS是一个把HTML(视图)绑定到JavaScript对象(模型)上的框架.当模型改变时,页面也能自动随之更新,反之亦然.当某个域的内容发生变化时,与之关联的 ...