开发者

Generate thumbnail images at run-time when requested, or pre-generate thumbnail in harddisk?

I was wondering, which way of managing th开发者_开发问答umbnail images make less impact to web server performance.

This is the scenario:

1) each order can have maximum of 10 images. 2) images does not need to store after order has completed (max period is 2 weeks). 3) potentially, there may have a few thousands of active orders at anytime. 4) orders with images will frequently visit by customers.

IMO, pre-generate thumbnail in hard disk is a better solution as hard disk are cheaper even with RAID.

But what about disk I/O speed, and resource it need to load images? will it take more resource than generate thumbnails at real-time?

It would be most appreciate if you could share your opinion.


I suggest a combination of both - dynamic generation with disk caching. This prevents wasted space from unused images, yet adds absolutely no overhead for repeatedly requested images. SQL and mem caching are not good choices, both require too much RAM. IIS can serve large images from disk while only using 100k of RAM.

While creating http://imageresizing.net, I discovered 29 image resizing pitfalls, and few of them are obvious. I strongly suggest reading the list, even if it's a bit boring. You'll need an HttpModule to be able to pass cached requests off to IIS.

Although - why re-invent the wheel? The ImageResizer library is widely used and well tested.


If the orders are visited frequently by customers, it is better to create the thumbnails ones and store on disk. this way the webserver doesn't need to process the page that long. It will speed up the loading time of your webpages.


It depends on your load. If the resource is being requested multiple times then it makes sense to cache it.

Will there always have to be an image? If not, you can create it on the first request and then cache it either in memory, or more likely a database, for subsequent requests.

However, if you always need the n images to exists per order, and/or you have multiple orders being created regularly, you will be better off passing the thumbnail creation off to a worker thread or some kind of asynchronous page. That way, multiple request's can be stacked up, reducing load on the server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜