On Wed, Aug 6, 2008 at 3:04 PM, Marcelo de Moraes Serpa <celoserpa@xxxxxxxxx > wrote: > Hello, > > My next project will be a kind of online photo viewer. All of these photos > will need to have watermark applied to them. The problem is that, depending > on the picture, different watermarks need to be applied. The easiest > solution would be to process these picture at runtime using GD, apply the > watermark(s) and serve them. The other approach, would be to pre-process > them (maybe using GD) and create different copies on the disk, the obvious > advantage being that it could be served directly via the webserver > (apache), > but, it would be much harder to manage (need to fix a watermark error? > Re-process and re-create the images on the disk...) and would take much > more > disk space. I would rather process them at runtime, per request, however, > this site will probably have lots of traffic. So, I've reached a deadend. > Could someone share his/her experiences and thoughts and help me decide? :) > > FYI, The application would be custom built from the ground up using PHP 5 > (Not sure if we will use a framework, if we happen to use, it will be > probably CakePHP). At first, there would be no clusters, proxies or > balancers, just a plain dedicated server with a good CPU, about 4GB RAM and > lots of disk space. > > PS: I've put DoS in the subject tagline meaning Denial of Service as I > think > that maybe dynamic processing of images X lots of request could result in > DoS. for the code that will invoke the watermarking, put it behind another layer, so that you can easily alter it in the future as the site grows. for example, you might use strategy pattern, and your initial strategy will use the current webserver directly. however, as the site begins to grow, you can add additional webservers, dedicated to running gd on top of php. you can then write a strategy which will pass the requests off to those boxe(s), and it will be transparent to your existing code that knows only of the strategy interface. also, as you grow, distributed filesystems are key. for example, your front-end webserver can handle requests from users on the site, dispatch a request (restful for instance) to another box, dedicated to gd. since both boxes share a common filesystem via nfs (or other) the gd box can create the watermark, which will then be immediately available to the front-end box, which it could signal w/ another request to say 'hey, the watermark is ready'. -nathan