Twisted.web的性能测试

34 篇文章 0 订阅
21 篇文章 0 订阅

想了解一下twisted单独作为web服务器的性能。

 

所以用webpy写一个简单的页面,挂上twisted的wsgi跑一下。

测试代码:

 

 

以 twistd -noy test.tac的方式运行。

 

测试环境:

 

Hardware Overview:

 

  Model Name: MacBook

  Model Identifier: MacBook2,1

  Processor Name: Intel Core 2 Duo

  Processor Speed: 2 GHz

  Number Of Processors: 1

  Total Number Of Cores: 2

  L2 Cache: 4 MB

  Memory: 2 GB

  Bus Speed: 667 MHz

 

 

 

测试软件 siege

 

 

1. 20并发,各10次

 

Transactions:         200 hits

Availability:      100.00 %

Elapsed time:        9.65 secs

Data transferred:        0.00 MB

Response time:        0.11 secs

Transaction rate:       20.73 trans/sec

Throughput:        0.00 MB/sec

Concurrency:        2.18

Successful transactions:         200

Failed transactions:           0

Longest transaction:        0.45

Shortest transaction:        0.01

 

 

2. 100并发,各10次
Transactions:        1000 hits
Availability:      100.00 %
Elapsed time:       25.87 secs
Data transferred:        0.01 MB
Response time:        1.78 secs
Transaction rate:       38.65 trans/sec
Throughput:        0.00 MB/sec
Concurrency:       68.93
Successful transactions:        1000
Failed transactions:           0
Longest transaction:        3.00
Shortest transaction:        0.02
3. 20个并发,各100次
Transactions:        2000 hits
Availability:      100.00 %
Elapsed time:       61.64 secs
Data transferred:        0.02 MB
Response time:        0.10 secs
Transaction rate:       32.45 trans/sec
Throughput:        0.00 MB/sec
Concurrency:        3.23
Successful transactions:        2000
Failed transactions:           0
Longest transaction:        0.40
Shortest transaction:        0.01
再跑一次
Transactions:        2000 hits
Availability:      100.00 %
Elapsed time:       64.13 secs
Data transferred:        0.02 MB
Response time:        0.08 secs
Transaction rate:       31.19 trans/sec
Throughput:        0.00 MB/sec
Concurrency:        2.65
Successful transactions:        2000
Failed transactions:           0
Longest transaction:        0.50
Shortest transaction:        0.01

 

 

 

 

结论:

还不能下结论。

 

 

再试试twisted.web自身的。

 

代码:

 

 

 

注意,这个代码没有用twistd启动,而是直接运行了。应该区别不大。

 

 

 

1. 20并发,10请求

Transactions:         200 hits

Availability:      100.00 %

Elapsed time:        6.06 secs

Data transferred:        0.00 MB

Response time:        0.01 secs

Transaction rate:       33.00 trans/sec

Throughput:        0.00 MB/sec

Concurrency:        0.18

Successful transactions:         200

Failed transactions:           0

Longest transaction:        0.02

Shortest transaction:        0.00

 

2. 100并发,10次
Transactions:        1000 hits
Availability:      100.00 %
Elapsed time:        7.23 secs
Data transferred:        0.01 MB
Response time:        0.02 secs
Transaction rate:      138.31 trans/sec
Throughput:        0.00 MB/sec
Concurrency:        2.78
Successful transactions:        1000
Failed transactions:           0
Longest transaction:        0.09
Shortest transaction:        0.00
3. 20并发,各100次

Transactions:        2000 hits

Availability:      100.00 %

Elapsed time:       56.31 secs

Data transferred:        0.02 MB

Response time:        0.00 secs

Transaction rate:       35.52 trans/sec

Throughput:        0.00 MB/sec

Concurrency:        0.11

Successful transactions:        2000

Failed transactions:           0

Longest transaction:        0.03

Shortest transaction:        0.00

 

 

 

结论:

1.不用wsgi要快不少,尤其是在高并发的时候。

2. 不用wsgi的时候,CPU占用相当低,10%-20%之间。 用的时候,在100%以上。

 

仅供参考。

可能测试的不太准。原因:

1. 用了不同的运行方式。

2. 用户web,web2

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值