[Catalyst] Serving "static" content from DB

Bill Moseley moseley at hank.org
Sun Jun 7 15:21:02 GMT 2009


On Sun, Jun 07, 2009 at 03:01:58PM +0300, Mihai Bazon wrote:
> I do want to keep files in the DB, BUT serve them as static files.  The
> backend<->db traffic is unimportant, as it will happen only when the
> file is updated.

Of all parts to a web app the database is probably the hardest to
scale.  Keeping traffic off the database when possible is good.

Of course, when it's time to worry about that, and if it's the
"static" content in the db that's a problem, you can move the static
content off the db at that point.  For low traffic single-server sites
I've found the db very handy for uploaded content.

You probably want a central store for the uploaded static content
anyway.  But, if you have or plan to have multiple non-sticky app
servers then you don't want to be stuck with your files on the app
server's file system.


> I wrote some tests, since you ask me about numbers.  You can download it
> here to run it yourself:
> 
>  ab -c 2 -n 100 http://localhost:54321/mp2/image.jpg

Don't you want "-n 1" there?  If it's static content don't you only
serve it once from the app server?  Serve it with expire headers way
into the future and then let the front-end proxy cache (or better use
a content delivery network).

As mentioned, if you need auth for these files then look into the
sendfile and reproxy features of Lighty and Perlbal.  Use a dedicated
static server for all static content.  Then you just need to get
uploads redirected there.

-- 
Bill Moseley.
moseley at hank.org
Sent from my iMutt



More information about the Catalyst mailing list