On Mon, Feb 15, 2010 at 10:53 AM, Martijn Tonies <m.tonies@stripped>wrote:
> databases are made for storing data - it saves you on both database and PHP
>> requests, as (from a web point of view) you can't return the image data
>> inside your HTML - it requires a second HTTP call. Filesystem image
> Doesn't an image always required additional http calls from the <IMG> tag?
Yes, that's what I'm saying. However, there's a significant difference
between an HTTP call that only needs to pump a file on to the network, and
an HTTP call that needs to start a PHP process that then in turn needs to
connect to the DB, which then needs to parse and execute a query.
Offloading static files (images, css, whatnot) to a separate server that
runs a lightweight, threaded httpd without PHP and whatnot compiled in, also
means that you'll need less hardware to serve the same amount of requests -
our PHP machines typically run 400 apache processes, but a static server on
the same hardware could easily serve a few thousand threads - suddenly it's
not memory/cpu but disk/network bandwidth that becomes your bottleneck.
> If you do go for BLOBs, though, for god's sake keep them in a separate
>> table, lest you fragment your datafiles. Split records are a disaster for
> I agree -for MySQL-, but this is a MySQL limitation!! Not a DBMS one.
True. I think (but am too lazy to verify) that even in MySQL this is mainly
an issue with MyISAM, not InnoDB. Given how MyISAM is the default engine,
though, I thought it worthwile to mention.
Separate LOB storage still leaves the overhead of query parsing and other
generic DBMS stuff which isn't there on a filesystem, though, not to mention
that each image requests takes up a database connection for as long as it
takes to transfer the (potentially huge) data. Don't forget that in a
well-tuned database, network transfer is often a significant part of your
total connection lifetime for select statements.
Bier met grenadyn
Is als mosterd by den wyn
Sy die't drinkt, is eene kwezel
Hy die't drinkt, is ras een ezel