简体   繁体   English

.NET WebService IPC-是否应该这样做以最大程度地减少一些昂贵的操作?

[英].NET WebService IPC - Should it be done to minimise some expensive operations?

I'm looking at a few different approaches to a problem: Client requests work, some stuff gets done, and a result (ok/error) is returned. 我正在寻找解决问题的几种不同方法:客户端请求工作,完成一些工作,并返回结果(确定/错误)。

A .NET web service definitely seems like the way to go, my only issue is that the "stuff" will involve building up and tearing down a session for each request. .NET Web服务绝对看起来像是要走的路,我唯一的问题是“资料”将涉及为每个请求建立和拆除会话。 Does abstracting the "stuff" out to an app (which would keep a single session active, and process the request from the web service) seem like the right way to go? 将“内容”抽象到应用程序(可以保持单个会话处于活动状态并处理来自Web服务的请求)是否似乎是正确的做法? (and if so, what communication method) (如果是,则采用哪种通信方式)

The work time is negligible, my concern is the hammering the transaction servers in question will probably get if I create/drop a session for each job. 工作时间可以忽略不计,我担心的是,如果我为每个作业创建/删除会话,则可能会对相关事务服务器产生冲击。

Is some form of IPC or socket based communication a feasible solution here? 某种形式的IPC或基于套接字的通信在这里可行吗?

Thoughts/comments/experiences much appreciated. 的想法/评论/经验,不胜感激。

Edit: After a bit more research, it seems like hosting a WCF service in a Windows Service is probably a better way to go... 编辑:经过更多研究,似乎在Windows Service中托管WCF服务可能是一种更好的方法。

well, here we go: 好吧,我们开始:

  • Do not setup a new communication channel for every request. 不要为每个请求都设置新的通信通道。 CLient side / Server side use WCF implementations and make sure the client does not get a new procxy for every call ;) Especially with HTTPS channel setup is expensive. 客户端/服务器端使用WCF实现,并确保客户端不会为每个调用获得新的procxy;)特别是使用HTTPS通道设置时,这样做的代价很高。

  • Do not call the service ;) SImple as that - make as few calls as POSSIBLE. 不要拨打该服务;)那样简单-尽可能少拨打电话。 Have a coarse interface optimized into not making many calls. 将粗略接口优化为不打很多电话。 Allow batching of results. 允许分批结果。 For example "GetInvoice" could be "GetDocuments" - returning not only an invoice, and taking multiple ID's, returning multiple documents. 例如,“ GetInvoice”可以是“ GetDocuments”-不仅返回发票,并获取多个ID,还返回多个文档。 A list of 30 invoices turns from 30 calls into 1. Otherwise a messaging bus approach may work - I use one like that and transport up to 1024 messages per call. 30张发票清单将30个电话变成1个电话。否则,可以使用消息传递总线方法-我使用类似的方法,每个呼叫最多可以传送1024条消息。

  • Try not to use a web service if you have a ton of load. 如果您有大量负载,请尝试不使用Web服务。 Use WCF and NetTcp binding (which is binary and not using HTTP, so it is not a web service). 使用WCF和NetTcp绑定(这是二进制的而不是使用HTTP,因此它不是Web服务)。 THe HTTP overhead is tremendous - look up google, someone made a test and we talk net tcp sometimes being about 900 TIMES faster. HTTP的开销是巨大的-查找Google,有人进行了测试,我们说的net tcp有时快900倍左右。 Especially if you do little work and have lost of users this may increase scalability. 特别是如果您工作量少并且失去了用户,则可能会增加可伸缩性。 Negative - you are only WCF compliant on the client side, no "Web Service" anymore. 负数-您仅在客户端上符合WCF,现在不再有“ Web Service”。

This is pretty much all you can do. 这几乎是您所能做的。 With different losses, but this is how to get performance up ;) If you talk of purely IPC consider using named pipes, not even net.tcp - named pipes are very efficient (using shared memory between the processes), but limited to the same machine in the .NET implementation. 损失不尽相同,但这是提高性能的方法;)如果纯粹是IPC,请考虑使用命名管道,甚至不使用net.tcp-命名管道非常有效(在进程之间使用共享内存),但限于相同.NET实现中的计算机。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM