Search code examples
c#.netnginxhttplistener

Thoughts on using Nginx to proxy webrequests to a .Net HttpListener based Json service


I am making a webservice that only needs to serve json and it needs to be scalable.

I have gotten the impression that Nginx is a more scalable webserver than IIS 7.5 and that it is extremely simple to manage compared to IIS. Also, Nginx can very easily be used to load balance among several json services, using the upstream module.

As I only need to serve json I feel that ASP.NET and IIS i way overkill. I just need some very simple routing and a simple authcookie mechanism I easily can write myself.

Right now I am using MVC3 but feels it is to bloated when I only servce Json, and I am very annoyed by the facts that I am having to write custom Auth attributes to make a default deny policy, having to make a HttpModule to hack around WindowsForms authentication's default redirection of unauthorized requests and in general needs to read and learn a lot to stay in control of the framework. I have also considered WCF but my prev. experience with this was that there was to much bloat and configuration for my needs and to much stuff to know about to stay in control.

I prefer simplicity and want to avoid "framework overhead" when I just need to handle some Http for a simple, fast and scalable async json service. So I am considering a setup like this:

  • An Nginx webserver on a linux box that load balances among and proxies webrequests to async json services.
  • The json services are written as Windows Services using HttpListener to do Async handling of web reqests.

What are your thoughts about this architecture?

EDIT: Actually I think it would be more performant using fastcgi from nginx to the windows services instead of proxying http prequests? What are your thoughts?


Solution

  • Just implement an ASHX - basically a IHttpHandler for IIS which scales really well and most of the issues you describe just "go away"... it gives you full control over the whole request/response processing... for a nice tutorial see http://www.dotnetperls.com/ashx