views:

60

answers:

1

I've got some Django content that I plan to host on a vps, web facing. It dynamically generates images that are cached to disk (regeneration is not often needed except (1)user changes content within image or (2) the layout is updated globally so all images need regeneration) right now when a user requests a view, it checks to see if whats stored on disk is the latest (ie. the global layout has not changed and the user has not changed any content) and either fetches the item from disk or generates a new image, stores it and serves it.

I've timed the process of generating and storing to disk and it takes around 200ms on a recent MBP running the Django dev server. While I dont expect a huge number of hits, I'm still interested in peoples opinion regarding handling generating content like this, so I have a few questions:

1) What criteria should be used to decide if a process/task in general worth handing off to a queue system (rabbitmq etc.), obviously your not going to move every task off the app server so if its time taken, how many ms is it before its worth moving it off?

2) I havent decided on what to host it with. If I plan to have a number of other dynamic content that may time some to execute involving images and the like, would I be better advised to host it with say nginx over lighttpd or apache using fastcgi, mod_wsgi etc? Keep in mind I plan to host on a VPS with say 512-1GB ram, and that it would be nice if the service degraded gracefully and if there was some way to prevent the process from locking up the server if there are many of requests for new images.

I do plan to run more tests as I'm not well versed in this area but I'd like to know from people with this experience what direction is it best to look in, no point trying things that are known not to work.

A: 

1) If you have enough threads to process requests then you don't need to worry about processing it asynchronously at another server. That being said, if the image processing is going to take a lot of CPU time then you will want to delegate that to another server.

2) Separating the serving of static content and dynamic content would be a good idea. That way, if the dynamic content generation part starts to have performance problem it would not affect the serving of static content.

phsiao