gpt4 book ai didi

c# - 在 WCF 中设置最大下载速度

转载 作者:IT王子 更新时间:2023-10-29 04:24:33 25 4
gpt4 key购买 nike

我正在使用 WCF 从数据库下载音频数据。我需要设置最大下载速度。

如何在 WCF 中完成?

谢谢!

最佳答案

WCF 通过 ServiceThrottlingBehavior 处理节流类(class)。

How to throttle a Wcf service

WCF provides a throttling behavior to manage server load and resource consumption (with the following properties):

  • MaxConcurrentCalls. Limits the number of concurrent requests that can be processed by all service instances. The default value is 16.

  • MaxConcurrentInstances. Limits the number of service instances that can be allocated at a given time. For PerCall services, this setting matches the number of concurrent calls. For PerSession services, this setting matches the number of active session instances. This setting doesn t matter for Single instancing mode, because only one instance is ever created. The default value for this setting is 2,147,483,647.

  • MaxConcurrentSessions. Limits the number of active sessions allowed for the service. This includes application sessions, transport sessions (for TCP and named pipes, for example), reliable sessions, and secure sessions. The default value is 10.

我不认为有控制带宽的内置机制。您需要实现自定义流。您使用线程来编写流。然后,您可以控制每秒写入多少数据。例如,您可以写入 250Kb,然后执行线程休眠一秒钟。

另请参阅:Concurrency and Throttling Configurations for WCF Services

关于c# - 在 WCF 中设置最大下载速度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6134111/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com