[Catalyst] Serving "static" content from DB

John Romkey romkey at apocalypse.org
Sat Jun 6 12:51:58 GMT 2009


On Jun 6, 2009, at 7:41 AM, Ian Docherty wrote:
> Mihai Bazon wrote:
>> Hi folks,
>>
>> I'm working on a simple CMS (actually started it for learning  
>> Catalyst,
>> but the goal is to be able to maintain a few websites with it).  Each
>> page is stored in DB and it can have file attachments, also stored  
>> in DB
>> (content is BLOB).
>>
> I may get shot down in flames for this, but I would not personally  
> put page data or attachments into the DB in the first place. I would  
> put the page into the filesystem and use the DB to reference the  
> file contents. This would also satisfy your cache problems since you  
> can retrieve the static data directly from the filesystem.

I agree whole-heartedly.

There are very few drawbacks to serving directly from the filesystem  
(only one I can think of, which has to do with access control to the  
content), while there are several when serving from the DB, mostly  
performance-related. Apache is very good at serving a static file  
quickly - when you have to pull a large object out of the database,  
you're dramatically increasing the instruction path and you're also  
increasing the number of copies of the data that it's necessary to do.  
Add in the overhead of then passing it through Catalyst and you've  
probably increased your overhead by orders of magnitude.

If it's okay to pull it from the database and cache it in the  
filesystem, why not just leave it in the filesystem in the first place  
and not bother with the database?

The only reason I would consider storing a file in a database would be  
if I couldn't satisfy my security model any other way.
	- john romkey
	http://www.romkey.com/




More information about the Catalyst mailing list