WCF Service 调用外部 Web 服务导致重负载环境超时 [英] WCF Service calling an external web service results in timeouts in heavy load environment

查看:22
本文介绍了WCF Service 调用外部 Web 服务导致重负载环境超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下场景:

我们的 .NET 客户端调用我们的 WCF 服务 - 该服务又调用外部第三方服务来检索一些数据.检索到数据后,我们的 WCF 服务会设置一些值,然后将控制权返回给客户端.调用外部服务的过程必须是同步的.

Our .NET client calls our WCF service - which in turn calls an external third party service to retrieve some data. Once the data is retrieved, our WCF service sets some values and then returns the control back to the client. The process of calling the external service has to be synchronous.

我的问题是这一切都适用于低负载环境,但是当负载变高时,我们开始对多个请求进行排队,WCF 服务开始超时.我们已将绑定的sendTimeout"属性设置为 5 秒,然后超时.

My problem is that this all works in a low load environment but when load gets high then we start queueing multiple requests, the WCF service starts timing out. We have set the "sendTimeout" property for the binding to 5 seconds and it times out after that.

我尝试用模拟的本地版本替换外部服务,并且可以正常处理负载,但另一方面,对外部服务的调用非常快 - 大约 0.5 秒.我只能假设超时的发生是因为排队的请求太多,而 WCF 服务无法在分配的 5 秒内响应.

I've tried replacing the external service with a mocked out local version and that handles the load OK but on the same hand the call to external service on it own is very quick - around 0.5 second. I can only presume that the timeouts are happening because too many requests were queued and WCF service couldn't respond within those allocated 5 seconds.

我尝试了以下方法:

  • 设置 maxConcurrentCalls、maxConcurrentSessions & 的值maxConcurrentInstances 到非常高的数字
  • 将 system.net - connectionManagement - maxconnection 的值设置为非常高的值

有人对我们在这个场景中可以做什么有任何想法吗?

Does any one have any ideas about what we can do in this scneario?

推荐答案

在这些高负载时间内您的 CPU 是否达到峰值?如果没有,那么您可能会用完线程.使你的接收原始调用的 wcf 服务异步,然后异步调用外部服务.

does your cpu peak during these high load times ? if not then you might be running out of threads. Make your wcf service that receives the original call asynchronous, and then call the external service asynchronously.

您必须在整个调用链中使用 asnyc 模式以确保没有任何东西阻塞线程.

you will have to use asnyc pattern throughout your call chain to make sure nothing is blocking the thread.

http://msdn.microsoft.com/en-us/library/ms731177.aspx

这篇关于WCF Service 调用外部 Web 服务导致重负载环境超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆