对一个 Django 站点做 ab 压力测试

栏目: Python · 发布时间: 8年前

内容简介:对一个 Django 站点做 ab 压力测试

今天想起来测测一个小 Django 站点的性能和压力,寻找一下看有没有内存泄漏,先介绍下服务器的信息,站点部署在 Google Cloud Platform,实例尺寸是微型(1 共享 vcpu, 0.6GB 内存),价格大致是($4.28/月 估算值),地区是 asia-east1-c,速度还是挺快,由于之前送的 300 刀还没用完,所以不用担心钱钱问题。

部署方式主要参照的这篇文章 《How To Set Up Django with Postgres, Nginx, and Gunicorn on CentOS 7》 ,大致内容如下:

  • CentOS 7
  • Python 3.6.1
  • Nginx 1.10.2
  • Gunicorn 19.7.1
  • Virtualenv 15.1.0
  • Django 1.11.1

测试命令:

ab -c 5 -n 1000 http://www.cocoaz.com/

结果:

This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.cocoaz.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.10.2
Server Hostname:        www.cocoaz.com
Server Port:            80

Document Path:          /
Document Length:        15823 bytes

Concurrency Level:      5
Time taken for tests:   277.324 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      16049000 bytes
HTML transferred:       15823000 bytes
Requests per second:    3.61 [#/sec] (mean)
Time per request:       1386.619 [ms] (mean)
Time per request:       277.324 [ms] (mean, across all concurrent requests)
Transfer rate:          56.51 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       21  208 425.4     24    3162
Processing:   100 1170 1442.9    801   20850
Waiting:       76  702 661.3    488    4786
Total:        124 1378 1561.5   1034   20883

Percentage of the requests served within a certain time (ms)
  50%   1034
  66%   1501
  75%   1807
  80%   2000
  90%   3014
  95%   3816
  98%   5270
  99%   6200
 100%  20883 (longest request)

StackDriver 监控状态:

对一个 Django 站点做 ab 压力测试

通过监控能看到 CPU 使用率最高飙到了 90%,内存一直稳定在 50% 左右倒是没怎么变化,所有请求都成功返回。


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

科技想要什么

科技想要什么

[美] 凯文·凯利 / 熊祥 / 中信出版社 / 2011-11 / 58.00元

在《科技想要什么》一书中,凯文•凯利向我们介绍了一种全新的科技观。他认为,作为整体,科技不是由线路和金属构成的一团乱麻,而是有生命力的自然形成的系统,它的起源完全可以回溯到生命的初始时期。正如生物进化呈现出无意识的趋势,科技也是如此。通过追踪这些长期趋势,我们可以对“科技想要什么”有所理解。 凯文•凯利预测了未来数十年科技的12种趋势,包括创造大脑这一得寸进尺之举。不过,为了让人类创造的世界......一起来看看 《科技想要什么》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

随机密码生成器
随机密码生成器

多种字符组合密码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具