WCF - 工厂和通道对象 - 如何创建以获得更好的性能
我只是想确保我遵循正确的方法。在我针对特定服务的应用程序中,我有一个静态 ChannelFactory (因为它是实例线程安全的),每次我需要与 WCF 服务通信时,我都会使用 CreateChannel 创建一个通道,使用该通道然后关闭它。然而,我遇到了一种观点,即将通道本身存储在静态成员中,并重用它也是正确的(该观点的作者还声称基于 PerCall 创建通道会显着降低性能)。最好的方法是什么?
谢谢,帕维尔
I just want to make sure I'm following the right approach. In my application for particular service I have one static ChannelFactory (as it's instance thread safe), and every time I need to comunicate with WCF Service I create a channel with CreateChannel , use that channel and then close it. However I bumped into one opinion that storing channel itself in static member, and reusing it is also right (author of that opinion also claims that creation of channels on PerCall basis will decrease performance significantly). What's the best approach?
Thanks,Pawel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我建议您进行自己的性能测试,但我认为您会发现,使用您的方法,根据您的硬件,每秒创建数千个通道不会有任何问题。在我看来,对于大多数用例来说,这根本不重要。
如果您有兴趣,Michele Bustamante(来自 IDesign.net)将进入 此处使用代码示例进行讨论。
Well I suggest you do your own performance testing, but I think you'll find that with your approach you won't have any problem creating many thousands of channels per second depending on your hardware. In my opinion for most use cases it won't matter much at all.
If you are interested, Michele Bustamante (from IDesign.net) goes into the discussion here with code samples.