高性能wcf
如何最大限度地提高 WCF 服务的性能?是否可以采取 多核的优势?或者多线程?
谢谢!!
How do I maximize performance for my wcf service? Is it possible to take
advantage of multicore? or multi-threading?
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
以下行为属性默认为最简单的(单线程)解决方案,更改它们的默认值将为您提供多线程,包括自托管服务。
Single< /code> (单线程)
True
(在 UI 自托管场景中实际上是单线程)您可能还需要查看 InstanceContextMode 也 这篇 MSDN 文章提供了有关 WCF 并发性的起点。
The following Behavior properties default to the simplest (single threaded) solution, changing them from their default values will give you multiple threading, including self-hosted services.
Single
(single threaded)True
(effectively single threaded in UI self hosted scenario)You may want to also look at InstanceContextMode also this MSDN article gives a starting point on WCF Concurrency.
这是一篇相关文章,提供了一些有关性能的指标,以便您进行基准测试。
WCF 服务性能
Here is a related article, gives some metrics around performance so you can benchmark.
WCF Service Performance
这是一个非常广泛的问题,很难回答。这将取决于您的服务正在做什么以及如何实施。但作为一般经验法则,您应该避免长时间运行的操作,因为这可能会独占工作线程。
This is a very broad question that is difficult to answer. It will depend on what your service is doing and how it is implemented. But as a general rule of thumb you should avoid long running operations which could monopolize worker threads.
如果您在 IIS 中托管 WCF 服务,那么 IIS 会将每个调用放在它自己的线程上,从而为您的服务器提供多核优势。
如果您希望单个调用在多个线程上运行,那么您需要在代码中自行编程。仅当您的服务正在进行大量计算时,您才需要此功能。
If you host your WCF service in IIS, then IIS will place each call on it's own thread, giving you the advantage mulitcores on your server.
If you want a single call to run on many threads, then you need to program this yourself in your code. You would only need this if your service is doing a lot of calculations.