WCF 服务的最大参数大小 [英] Max parameter size for WCF service

查看:30
本文介绍了WCF 服务的最大参数大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

拥有一个 WCF 服务(托管在 IIS 6.0 中),该服务从 SAP 获取 XML 提要,其中可能有数万(或更多)记录要处理.

Have a WCF service (hosted in IIS 6.0) that takes an XML feed from SAP with potentially tens of thousands (or more) of records to process.

[OperationContract]
[FaultContractAttribute(typeof (ArgumentException))]
void ProcessSapRoles(XElement SapData);

我担心参数大小的限制.从其他 SO 文章中,我读到在 web.config 中的 httpRuntime 设置上增加 maxRequestLength 将对此有所帮助(我确定我必须增加发送超时,以及).我也读过使用 NetTcpBinding 会有所帮助,但我不知道使用它的限制或如何配置它.

I'm concerned about limitations on parameter sizes. From other SO articles, I'm reading that upping the maxRequestLength on the httpRuntime setting in the web.config will help this (I'm sure I'll have to increase the send timeout, as well). I've also read that using a NetTcpBinding will help, though I wouldn't know limitations for using this or how to configure it.

我想我可以让调用者拨打 100,000 个电话,每条记录一个,但我认为性能影响会很大.此外,在另一方面,我必须查询现有记录以查看我是否正在更新或添加记录,然后将更新发送回数据库.为每条记录的 100,000 个单独查询创建 100,000 个数据集似乎也很糟糕.

I suppose I could have the caller make 100,000 calls, one per record, but I'd think the performance impact would be significant. Also, on the other side, I have to query existing records to see if I'm updating or adding records, and then send the updates back to the database. Creating 100,000 datasets for 100,000 separate queries of one record each seems crippling, as well.

WCF 之前,我们在远程处理链上使用了压缩接收器,这显着提高了性能(发送我们最大的数据集会在 20 分钟后超时;添加压缩接收器后,数据集在大约 20 秒内穿过电线)(并且客户负责制作如此大的数据集,我们无法控制它们:P).

Pre-WCF, we used compression sinks on a remoting chain, which significantly increased performance (sending our largest datasets were timing out the web page after 20 minutes; after adding the compression sink, the datasets were crossing the wire in about 20 seconds) (and the customer was responsible for making datasets that large, we had no control over them : P ).

如何最好地处理可能传递 100,000 条记录,WCF 是否有任何等效的压缩接收器概念?

How best to handle passing potentially 100,000 records, and is there any equivalent concept of a compression sink for WCF?

TIA!
詹姆斯

TIA!
James

推荐答案

WCF 服务的参数大小限制为 64KB - 默认情况下.这是一个很好的理由——服务必须有一个这样大小的缓冲区(或者可能有几个缓冲区,对于同时调用者),如果这个大小太大,一个人很容易用虚假的巨大请求淹没服务器,让它跪下.无论您拥有多少 RAM - 在某些时候,它都会耗尽.

WCF services are limited to 64KB in parameter size - by default. This is for a good reason - the service will have to have a buffer (or potentially several buffers, for simultaneous callers) of that size, and if that size would be too big, one could pretty easily flood a server with bogus huge requests and bring it to its knees. No matter how much RAM you have - at some point, it'll run out.

但是:好消息是:几乎所有东西,你都可以很容易地配置它.如果您在企业 LAN 环境(防火墙后)中将大消息与高度优化的 NetTcpBinding 结合使用,您应该是安全的,并且您应该能够在您的客户端之间传输几乎任何大小的文档和一项服务.

BUT: the good thing is: as pretty much everything, you can configure this pretty easily. If you combine a large message size with the highly optimized NetTcpBinding in a corporate LAN environment (behind firewalls), you should be both safe, and you should be able to transmit just about any size document between your client and a service.

这篇关于WCF 服务的最大参数大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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