mwjackson
mwjackson

Reputation: 5451

Architecture ideas for static resource (images) web server?

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:

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.

Upvotes: 0

Views: 726

Answers (3)

ConcernedOfTunbridgeWells
ConcernedOfTunbridgeWells

Reputation: 66682

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.

Upvotes: 2

Mike Chaliy
Mike Chaliy

Reputation: 26698

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.

Upvotes: 2

Mike Chaliy
Mike Chaliy

Reputation: 26698

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.

Upvotes: 1

Related Questions