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

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

内容简介:对一个 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% 左右倒是没怎么变化,所有请求都成功返回。


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

查看所有标签

猜你喜欢:

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

鸟哥的Linux私房菜

鸟哥的Linux私房菜

鸟哥 / 人民邮电出版社 / 2010-6-28 / 88.00元

本书是最具知名度的Linux入门书《鸟哥的Linux私房菜基础学习篇》的最新版,全面而详细地介绍了Linux操作系统。全书分为5个部分:第一部分着重说明Linux的起源及功能,如何规划和安装Linux主机;第二部分介绍Linux的文件系统、文件、目录与磁盘的管理;第三部分介绍文字模式接口 shell和管理系统的好帮手shell脚本,另外还介绍了文字编辑器vi和vim的使用方法;第四部分介绍了对于系......一起来看看 《鸟哥的Linux私房菜》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

SHA 加密
SHA 加密

SHA 加密工具