简体   繁体   中英

ASP.NET WebAPI Self Hosting on Azure: feature loss by avoiding IIS?

ASP.NET WebAPI's can either hosted within IIS (as a web role) or be self hosted (as a worker role)

var server = new HttpSelfHostServer(config);
server.OpenAsync().Wait();

The above reminded me of Node.JS. Anyway, I'm trying to list out all the technical tradeoffs between these two approaches. I'm not looking for an opinion on what tradeoffs you prefer - just what those tradeoffs are from a technical perspective. Right now I'm seeing about 8% faster response times per API call in self-hosted mode on our real-world API calls (=Azure SQL + heavy duty number crunching behind the API call). However, I'm concerned that jettisoning IIS will come back to bite us later in the future.

So, what are some major tradeoffs or features lost when avoiding IIS when going the WebAPI self-hosting route?

  • You lose all of the features of IIS (logging, application pool scaling, throttling/config of your site)....you have to build every single feature that you want yourself
  • HttpContext? You lose that since ASP.NET provides that for you. So, I could see that making things like authentication much harder
  • WebDeploy? You would lose that
  • IIS has some nice specific features in IIS 8 about handling requests and warming up the service

It depends on your application really. You would have to re-write each of those features you need. Node.js provides modules that do that stuff (Express) that the Nginx sever does not have...other than the (event loop async architecture) that is why it is faster.

I know this is not part of your question, but you mentioned a 8% perf gain...that gain is because you don't have the IIS pipeline involved. As you write your own code to mimic IIS functionality you lose, you will ultimitely lose out on that performance

Have you tried Windows 2008 R2/IIS 8? That includes a "free" performance gain over IIS 7.x: http://blog.bitdiff.com/2012/06/performance-comparison-iis-75-and-iis-8.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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