I was thinking ,
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 :
For example :
If it's GET
and the URI is api/Customers/5
:
method should start with Get
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.
Question :
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 ?
Why not doing it the simple way ? Ok cause we want to use http verbs as meaning. OK. but so much operations just to execute a method
example #1
get api/Customers/5
could be
a.ashx?m=gc&id=5 (method=GetCustomer & id=5)
example #2
put api/Customers/5?v=123
could be
a.ashx?m=uc&id=5?v=123' (method=UpdateCustomer & id=5 & value=123)
mine is even shorter.
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.
Caching is one of the best ways to improve API performance. If you have requests that frequently produce the same response, a cached version of the response avoids excessive database queries. The easiest way to cache responses is to periodically expire it, or force it to expire when certain data updates happen.
API performance testing is any type of test that evaluates how well APIs perform under a given set of conditions. For example, an API performance test could assess: Whether an API returns the expected output in response to given input. This is known as functional API testing.
For web applications, API performance has a compounding impact on the user experience. When using a web app, a client may make dozens of requests over the span of minutes. If an API is slow to respond, this makes the client application lag behind, causing unhappy customers and unhappy developers.
WEB API can use any text format including XML and is faster than WCF. WEB API can be used to create full-blown REST Services. WEB API doesn't require any data contracts and doesn't require configurations to the level of WCF.
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
Performance comparison HttpHandler vs WebAPI: http://www.west-wind.com/weblog/posts/2012/Sep/04/ASPNET-Frameworks-and-Raw-Throughput-Performance
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With