网络API的性能? [英] Web api performance?

查看:159
本文介绍了网络API的性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在想,

的WebAPI 以及路由机制工作在这样的方式,它读 HTTP动词(GET POST等...),然后搜索匹配的方法名称/参数:

The WebApi along with routing mechanism works in such way that it reads the http verb ( GET POST etc...) and then searches for matched method names / parameters :

例如:

  • 如果是 GET 和URI是 API /客户/ 5

  • 方法应该从获取

如果有 ID 所以搜索,它接受int值作为参数的方法。

if it has ID so search a method which accepts int as parameter.

等。 (有更多的规则)。

etc. (there are more rules).

我大多认为他们这样做是使用反射。

I mostly believe they did it using reflection.

问:

这难道不是一种性能影响,对于每一个URI请求 - 搜索所有这些数据只是附加的方法?

Isn't it a performance hit , for every URI request - to search all this data just to attach a method ?

在那里我可以轻松地发送从客户端,这将意味着在服务器端的方法很短的字符串?

Where I could easily send a very short string from a client which will imply on the method on the server side ?

为什么不这样做的简单的方法?好事业,我们要使用HTTP动词的含义。好。但如此多的操作,就像执行方法

例如#1

获得API /客户/ 5

可以

a.ashx M = GC和放大器;?ID = 5(方法= GetCustomer和ID = 5)

例如#2

把API /客户/ 5?V = 123

可以

a.ashx M = UC&放大器;?ID = 5 V = 123'?(方法= UpdateCustomer和ID = 5和值= 123)

我的是更短。

不要误会我的意思。我相信这个API是由非常聪明的人谁知道他们谈论的是什么做的。

Dont get me wrong. I believe this api was done by very smart people who knew what they talk about.

只是想Ø知道我缺少什么。

Just want o know what am I missing.

推荐答案

网络API有很多,你不使用HTTP处理程序,如果您没有code它选项 名单如下:<一href="http://www.asp.net/whitepapers/mvc4-release-notes#_Toc317096197">http://www.asp.net/whitepapers/mvc4-release-notes#_Toc317096197

Web api has a lot of options that you don't have with HTTP Handler if you don't code it Full list: http://www.asp.net/whitepapers/mvc4-release-notes#_Toc317096197

  • 的OData支持(通过可查询属性)
  • 内容协商
  • 过滤器
  • 模型绑定和验证
  • 能够自我主机IIS以外
  • 链接生成到相关资源的整合路由规则
  • 的路线完全支持/路由
  • 能够创建使用IApiExplorer定制的帮助和测试页面

性能比较的HttpHandler VS的WebAPI:<一href="http://www.west-wind.com/weblog/posts/2012/Sep/04/ASPNET-Frameworks-and-Raw-Throughput-Performance">http://www.west-wind.com/weblog/posts/2012/Sep/04/ASPNET-Frameworks-and-Raw-Throughput-Performance

Performance comparison HttpHandler vs WebAPI: http://www.west-wind.com/weblog/posts/2012/Sep/04/ASPNET-Frameworks-and-Raw-Throughput-Performance

与往常一样,你需要选择一个最适合你,如果你想要去的性能与HTTP处理程序的技术。如果您想要的灵活性和休息去的Web API。您可能要休息,如果你公开Web服务等将消耗

As always, you need to choose the the technology that suits you best, if you want performance go with Http Handler. If you want flexibility and rest go with Web API. You might want rest if you expose web services that other will consume

这篇关于网络API的性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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