views:

335

answers:

3

We're looking at removing all of the static resources (mainly images) in our ASP.NET 2.0 web app, and moving them to their own separate server. The main design requirements are for speed (so caching will be important) and a minimal level of security (so that people can't just directly download or rip off the images). Using a plain .net 2.0 web service immediately sprints to mind, but I'm worried about possible performance issues, and caching? Is this a valid concern?

So what kind of architectural setups would fit this bill?

Some other points to consider:

  • WCF is not really an option yet as we're not moving to .net3.5 for a few months yet
  • Development time is limited to 2 weeks

Edit - To further clarify our position:

I don't really need a mission-critical, super high load, asynchronous RPC server dishing out vast amounts of data. All I need is some sort of facade to dish out requests (and take advantage of IIS caching) from our main site for images on a separate web server, and be able to simply authenticate the request to prevent basic cases of theft.

+2  A: 

The king of the hill for high-speed static web serving is asynchronous I/O, at least the last time it looked. At one point there was a web server called 'Zeus' that used this type of architecture. It was specifically designed for serving high-volume static content - guess which industry.

Threading and synchronisation is more expensive than you think. Asynchronous architecture is used quite widely in servers and can be made very resource efficient. Often a single thread is so fast that it can outrun multi-threaded servers by a considerable margin.

Using asynccore (a Python async server framework) I could make a single threaded XML-RPC server that could connect to a database, issue a simple query, cose the connection and reply to the request faster than a multi-threaded server with a thread pool. On a single CPU machine it was about 2.5x faster.

Rolling your own async server isn't that hard. I've seen them assigned as second-year computer science assignments. You can probably find Async web server libraries for most languages - Python comes with one in the standard library.

Finally, I don't have much time for people saying 'do it but it must be done in two weeks.' If your business case can only justify two weeks development time, consider not bothering - the business case is too marginal unless it really is low-hanging fruit. I mechanically translate a marginal business case to no business case at all. If it's important give me time to do it for real. If it's not important don't do it at all.

There we go - just saved you two weeks and all the ongoing maintenance costs.

ConcernedOfTunbridgeWells
+1 for *guess which industry*
Mehrdad Afshari
Sorry guys, I should probably have made it more clear that we're looking to roll-our-own instead of shelling out for 3rd party solutions.
jacko
See the edit above for clarification.
ConcernedOfTunbridgeWells
See my edit on the main question
jacko
+2  A: 

Just use static folder configured as virtual folder in IIS. This will give everything you need. Caching, speed and so on.

Minimal pseudo-security could be achievend with random folder/file names. Or injected pipline handlers. Of course, you should disable folder listings and so on.

Mike Chaliy
If you use IIS 7, then you can get _real_ security, same as in the ASP.NET pages.
John Saunders
John please expand on that, or point some link, would you? Thanks
John says that IIS7 work pipleine support regualr HttpHandlers. You can leverage on them even for static files. For example read this - http://aspnet.4guysfromrolla.com/articles/122408-1.aspx.
Mike Chaliy
Sorry, more correct to say HttpModules rather then HttpHandlers, but still both are valid.
Mike Chaliy
That's right. The pipelines are the same.
John Saunders
+1  A: 

You can develop simple HttpHandler (+ MVC Routing for user friendly urls). But this requires manual handling of compressions, cache headers, content parts and so on.

But with this solution you are free to implement anything, like tracking abnormal downloads, proper user authentincation, image resizes, image optimizations and many others.

Mike Chaliy