C#Web服务速度慢 [英] C# Web Services Slow

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

问题描述

我有一个在本地网络上运行的Web服务,但是仅通过传递不执行任何操作且不返回任何内容的整数来调用Web方法需要217毫秒.如果我在本地计算机上运行Web服务,则只需19毫秒.任何人都可以提出任何有关加快此速度的建议吗?

I have a web service running on a local network but to call a webmethod only passing an integer which does nothing and returns nothing takes 217milliseconds. If I run the web service on my local machine it only takes 19 milliseconds. Can anyone give any advice on speeding this up?

推荐答案

在远程托管的Web服务上调用Web方法总是很慢.... it"必须往返服务器

如果您确定自己的网络设置都是正确的,则没有真正的方法可以加快此速度
Calling a web method on a remote hosted web service will always be slower of course....it''s got to make the round trip to the server

If you are confident your network settings are all correct, there''s no real way to speed this up


否.这些数字是非常合理的.您会发现,当开始使用Web服务做一些有用的事情时,时间差异变小了. (您现在将大部分时间都花在建立上下文,在线包装等方面),并且服务时间为零.当您真正开始使用Web服务时,请注意不要使它们的粒度过细. Web服务应该往返进行合理数量的工作(例如读取许多记录并处理许多记录).
如果您为每个小事情调用Web服务,则最好是直接连接到数据库(如果这是您的目的)(除了这将创建2层架构,这也是邪恶的).
NO. these figures are very reasonable. You''ll find that when you start doing something usefull with your web service, the time disparity decreases. (you spend most of your time now on establishing context, packaging stuff on the wire, etc...) and zero time in your service. When you really start using webservices, take care so that you do''t make them too fine-grained. A Web service should do a reasonable amount of work (like reading many records and processing many records) on a round-trip.
If you call your web-service for every single little thing, you''re better of connecting to the database directly, if that''s your purpose (except that this will create a 2-tier architecture, which is also evil).


您可以在计算机和服务器之间使用很长的五类电缆.
You could run a long piece of Cat5 cable between your machine and the server.


这篇关于C#Web服务速度慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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