WCF 请求限制

发布于 2025-01-07 03:21:48 字数 387 浏览 0 评论 0原文

我正在使用第三方 .NET 4 WCF 服务,该服务作为服务引用添加到我的解决方案中。有没有办法配置请求,使我的服务不会 Ddos:ing 第三方服务?

我知道 ServiceThrotdling 可以控制以下参数:

- MaxConcurrentCalls
- MaxConcurrentSessions
- MaxConcurrentInstances

我的应用程序是单线程的,因此上述参数不会产生影响。

我想限制每个时间段的请求数量。也许可以在每个请求之间暂停一下。显然,我可以为该服务编写一个适配器并自己处理这个问题,但第三方服务包含约 200 个方法,因此需要大量代码。

是否可以通过配置以这种方式限制请求?

I'm using a third party .NET 4 WCF service that is added to my solution as a Service Reference. Is there a way to configure requests so that my service isn't Ddos:ing the third party service?

I'm aware of ServiceThrottling where the following parameters can be controlled:

- MaxConcurrentCalls
- MaxConcurrentSessions
- MaxConcurrentInstances

My application is single threaded so the above parameters will have no impact.

I would like to limit number requests per time period. Maybe by making a pause between each request. I could obviously write an adapter for the service and handle this myself, but the third party service contains ~200 methods so it would require lots of code.

Is it possible to throttle the requests this way by configuration?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泪眸﹌ 2025-01-14 03:21:48

您的问题已经有几周了,所以我不知道您是否仍然需要它。至少值得一试......另外,如果我误解了你的场景,请纠正我。

据我了解,您希望限制自己的服务仅一个又一个请求地调用第三方服务。我不知道有什么可配置的解决方案。但是,正如您所说,您可以实施自己的解决方案,我建议采用不同的方法。

您可以将请求放入队列中,然后一次处理一个队列条目。
这可以通过多种方式实现,具体取决于您必须使用的环境。

我想到了两种解决方案。

一种简单的方法可能是在您自己的服务中使用内存队列,每个条目调用第三方一次,并使用某种 锁定。但这可能需要仔细考虑以避免丑陋的僵局。

更复杂但可能更好的可扩展解决方案:
您可以配置您的服务来编写进入 Microsoft 消息队列 (MSMQ) 基础结构并添加另一个服务 按顺序将这些消息处理到第三方服务。

your question is already a couply of weeks old, so I do not know if you still need it. At least it is worth a try... Also, please correct me if I misunderstood your scenario.

As far as I understood, you want to restrict your own service to only call the third-party service one-request-after-another. I am not aware of a configurable solution for this. But, as you stated that it is possible for you to implement your own solution, I would suggest a different approach.

You might put your requests into a queue and then process one queue entry at a time.
This could be implemented in a variaty of ways, depending on the environment you have to work with.

there are two solution that come to my mind.

A simple approach might be to use an in-memory queue within your own service that calls the third party once per entry and use some kind of locking. But this might need some careful thought to avoid ugly deadlocks.

The more complex, but possibly better scalable solution:
You can configure your service to write into a Microsoft Message Queue (MSMQ) infrastructure and add another service that processes those messages sequentially to the third party service.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文