您的位置:首页 > 其它

NHibernate+WCF项目实战(四)使用WAS对Webservices接口进行压力测试

2009-11-13 21:19 711 查看
NHibernate+WCF项目实战

第一篇、项目介绍与搭建

第二篇、使用NHibernate实现数据访问并进行单元测试

第三篇、使用WCF对外提供Webservices接口并进行单元测试

第四篇、使用WAS对Webservices接口进行压力测试

源码下载: WCFDemo

开发环境

我的开发环境是VS2008 SP1+SQLServer 2005

NHibernate版本是2.1.0.4000

  NUnit版本是2.5.2

  Microsoft Web Application Stress Tool 版本是1.1

本节概要

本篇使用Microsoft Web Application Stress Tool对接口提供的方法进行压力测试

测试方法

上篇为IUserInfo中的方法添加了Attribute [WebGet],就是为了能通过get方式访问这些方法,同时也可以用压力测试工具Microsoft Web Application Stress Tool对它们进行压力测试。

get访问方式我们在Hosting项目的web.config中配置了如下的EndPoint:
<endpoint address="webhttp" behaviorConfiguration="webHttp" binding="webHttpBinding" contract="Lee.Contract.IUserInfo">

<identity>

<dns value="localhost" />

</identity>

</endpoint>

get访问地址是这样的:webservices访问地址/ endpoint 的address/方法名?参数1=value&参数2=value

所以三个方法的get访问地址分别是:

AddUserInfo
http://localhost:1600/UserInfo.svc/webhttp/AddUserInfo?name=testname7&description=testdesc&state=teststate
ExistUserInfo http://localhost:1600/UserInfo.svc/webhttp/ExistUserInfo?name=testname7
UpdateUserInfo
http://localhost:1600/UserInfo.svc/webhttp/UpdateUserInfo?name=testname7&description=updatetestdesc&state=updateteststate
Microsoft Web Application Stress Tool

WAS是微软提供的压力测试工具,使用较为简单,下载请自行Google,我把程序部署在本机测试,在实际开发中应在与生产服务器配置相当的测试服务器上做压力测试。

1)在本地新建一个网站,地址为 http://localhost:8080/UserInfo.svc;
2)打开WAS,配置你要测试的服务器、地址和访问方式。



3)设置线程数和Socket连接数,设置测试运行时间。



以下是我测试ExistUserInfo的数据,在View/Report下可以看到测试结果:

200个并发[10*20]

================================================================================

Report name: 2009-11-12 12:46:12

Run on: 2009-11-12 12:46:12

Run length: 00:02:01

Web Application Stress Tool Version:1.1.293.1

Number of test clients: 1

Number of hits: 47602

Requests per Second: 396.66

Socket Statistics

--------------------------------------------------------------------------------

Socket Connects: 47802

Total Bytes Sent (in KB): 11857.14

Bytes Sent Rate (in KB/s): 98.80

Total Bytes Recv (in KB): 143224.38

Bytes Recv Rate (in KB/s): 1193.47

Socket Errors

--------------------------------------------------------------------------------

Connect: 0

Send: 0

Recv: 0

Timeouts: 0

RDS Results

--------------------------------------------------------------------------------

Successful Queries: 0

Script Settings

================================================================================

Server: localhost

Number of threads: 200

Test length: 00:02:00

Warmup: 00:00:00

Cooldown: 00:00:00

Use Random Delay: No

Follow Redirects: Yes

Max Redirect Depth: 15

Clients used in test

================================================================================

localhost

Clients not used in test

================================================================================

Result Codes

Code Description Count

================================================================================

404 Not Found 47602

Page Summary

Page Hits TTFB Avg TTLB Avg Auth Query

================================================================================

GET http://localhost:8080/User 47602 500.44 500.52 No No

100个并发[10*10]

================================================================================

Report name: 2009-11-12 12:49:03

Run on: 2009-11-12 12:49:03

Run length: 00:02:00

Web Application Stress Tool Version:1.1.293.1

Number of test clients: 1

Number of hits: 47699

Requests per Second: 397.36

Socket Statistics

--------------------------------------------------------------------------------

Socket Connects: 47797

Total Bytes Sent (in KB): 11855.90

Bytes Sent Rate (in KB/s): 98.77

Total Bytes Recv (in KB): 143516.23

Bytes Recv Rate (in KB/s): 1195.56

Socket Errors

--------------------------------------------------------------------------------

Connect: 0

Send: 0

Recv: 0

Timeouts: 0

RDS Results

--------------------------------------------------------------------------------

Successful Queries: 0

Script Settings

================================================================================

Server: localhost

Number of threads: 100

Test length: 00:02:00

Warmup: 00:00:00

Cooldown: 00:00:00

Use Random Delay: No

Follow Redirects: Yes

Max Redirect Depth: 15

Clients used in test

================================================================================

localhost

Clients not used in test

================================================================================

Result Codes

Code Description Count

================================================================================

404 Not Found 47699

Page Summary

Page Hits TTFB Avg TTLB Avg Auth Query

================================================================================

GET http://localhost:8080/User 47699 249.06 249.15 No No
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐