简体   繁体   English

webapi C#使用异步等待令人费解的负载测试结果

[英]webapi c# puzzling load test results with async await

We are doing a load test on one of our web api end point and we can't believe the results that we are seeing. 我们正在对一个Web api端点进行负载测试,我们无法相信我们看到的结果。

In scenario 1 our tps (throughput per second) is ~1/sec while in scenario 2 our tps is ~3/sec. 在方案1中,我们的tps(每秒吞吐量)约为1 /秒,而在方案2中,我们的tps约为3 /秒。 We expected a higher tps in scenario 1 than in 2. 我们预计方案1的tps高于方案2的tps。

Scenario 1 is our current system where we call service 1. Scenario 2 is the new system where we are introducing a bridge service in the middle to combine results from service 1 and service 2. Hence, scenario 2 should have lower throughput than scenario 1, because in scenario 1 we are directly calling our service 1. 方案1是我们称为服务1的当前系统。方案2是新系统,其中我们在中间引入了网桥服务以结合服务1和服务2的结果。因此,方案2的吞吐量应低于方案1的吞吐量。因为在方案1中,我们直接调用我们的服务1。

All the services are in web api asp.net 4.5. 所有服务都在web api asp.net 4.5中。 Service 1 and 2 does not have async await operations. 服务1和2没有异步等待操作。 Bridge Service has async await operations and makes call to service 1 and 2 at the same time and waits for both the calls to finish. 桥服务具有异步等待操作,并同时对服务1和2进行调用,并等待两个调用完成。 Call to service 1 always take longer than call to service 2. Hence, service 1 decides the total call time. 服务1的呼叫总是比服务2的呼叫花费更长的时间。因此,服务1决定总的呼叫时间。 The server is windows server 2012 R2 and IIS 8. Bridge service and Service 1 are deployed on the same server and are in the same application pool. 该服务器是Windows Server 2012 R2和IIS8。网桥服务和服务1部署在同一服务器上,并且在同一应用程序池中。 Service 2 is deployed on another server. 服务2部署在另一台服务器上。

Also, we verified that we are making the exact same call to Service 1 in both the scenarios. 另外,我们验证了在两种情况下我们都对服务1进行了完全相同的调用。

We are seeing the same results in JMeter and soap ui. 我们在JMeter和soap ui中看到了相同的结果。

在此处输入图片说明

Following is the code from bridge service: 以下是网桥服务的代码: 在此处输入图片说明

Apparently our call to service 1 wasn't same in both the scenarios. 显然,在两种情况下,我们对服务1的调用都不相同。 When we call service 1 directly we pass the ASP.NetSessionId in the cookie, but when the bridge called the service 1 it didn't pass the session id in the cookie. 当我们直接调用服务1时,我们在cookie中传递了ASP.NetSessionId,但是当网桥调用服务1时,它没有在cookie中传递会话ID。

Verdict: In our original load test we used one ASP.NetSessionId and asp.net has some session level locks, hence it reduced the performance. 结论:在我们最初的负载测试中,我们使用了一个ASP.NetSessionId,而asp.net具有一些会话级别的锁定,因此降低了性能。

Hence, to test the session level lock theory, we did a load test by simulating 50 users instead of 1 user, and this time the performance is on par with bridge. 因此,为了测试会话级别锁定理论,我们通过模拟50个用户(而不是1个用户)进行了负载测试,这次的性能与网桥相当。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM