When To Put Images Into MySQL?

So, most of the “I want images in MySQL” conversations are terminated with “Don’t.” Some articles say “MySQL’s overhead isn’t worth it” and others that say “If you put the images in MySQL you don’t have to deal with the filesystem overhead.”

My company’s site has over 2 million images to store/retrieve, and our current setup is at its limit and does not scale well — 2 NFS servers. We’d rather avoid adding another NFS server, because it involves changing where images are located whenever we scale. The problem is that with so many images, there are so many inodes that the filesystem cannot keep up. As well, if a server is rebooted or offline for more than an hour (ie, during maintenance) it is extremely slow until the cache catches up (about half an hour).

We believe the best retrieval method is to use MySQL. We will be doing our own speed testing, so I’m not relying on what folks say here. But I’m curious — what do other folks think? Flickr uses MySQL for image storage…..

16 responses to “When To Put Images Into MySQL?

  1. Sheeri’s blog does not support trackback autodetection.

    So here is my manual trackback:

    Serving Images From A Database, The Inside Story

  2. Started typing here and decided to write my own post about my experience with this: http://mike.kruckenberg.com/archives/2006/03/storing_binary.html

  3. […] Dezbaterea privind păstrarea fişierelor (audio/video/imagini) in baza de date contra sistem de fişiere continuă cu noi argumente. […]

  4. Hrm…..I actually meant 36 million images, not 2 million! my bad.

  5. Hi Sheeri,

    Any news on the speed test? I am currently developing my own site and this would be a very useful info.


  6. Very interesting topic!
    What do you guys think about so -called “chunk approach” – when you cut your BLOB in some little chunks, say 64 kb big and store your blob in those smaller chunks in the database instead of one big BLOB. What do you think, theoretically, will it do some good? Can it optimize search or retrieval effectivity?
    Thank you all for your thoughts.

  7. Do any of you have any more insight into this problem? How did storing large numbers of files in the DB work out for you?