Storing images in a database

Discussion in 'MySQL' started by tbarr60, Feb 1, 2006.

  1. #1
    I work at a company that has made code and content deployment more formal. Content often can't wait for the normal twice monthly cycle so we do "hot fixes". We have some portions content managed so we can bypass the "process".

    There is one simple content feature that I'd like to content manage. It includes a few test items and an image. The image currently is deployed to multiple servers throught the code deployment process.

    I haven't stored images in a database but to eliminate hot fixes it might be the way to go. I am sure Marketing would love to respond better to executive management requests to change things in real time. Is there any concern about performance by doing this?

    A little background:
    Database: SQL Server 2000 (potentially moving to latest Oracle)
    Web Application Server: Coldfusion MX 6.1 (potentially mixxing with Java)
    Traffic: 20,000 visitors per day
    Servers: 8 behind a load balancer
    Caching: Net Cache for images and files (not sure if it would handle images from database)
     
    tbarr60, Feb 1, 2006 IP
  2. AWD1

    AWD1 Peon

    Messages:
    191
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Stupid question, but do you need to save the image as such? What I usually do is save the filename of the image, width, height, and occasionally alt tag in four fields in the database and then retrieve and display the information accordingly.

    This does work with SQL Server 2K and ASP, and will handle pretty well any level of traffic you throw at it. I'm not really familiar with ColdFusion myself.
     
    AWD1, Feb 1, 2006 IP
  3. tbarr60

    tbarr60 Notable Member

    Messages:
    3,455
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    210
    #3
    I don't need to store the image in the database. I can access the production database with delay. Getting an image file to a production web server normally takes days since management has chosen to use twice monthly uploads. So if I can store and retrieve images from a database responsiveness to Marketings needs will be much better.

    You can think of ColdFusion as being similar ASP or ASP.NET, it generates web pages on the server side.
     
    tbarr60, Feb 1, 2006 IP
  4. stuw

    stuw Peon

    Messages:
    702
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #4
    wouldn't it be easier to store the images on their own server, and reference them from a database as awd1 suggests?

    If you are storing a lot of images I belive it's faster to store them in small groups.
    eg if you have a file called: 123456789.jpg
    save it as /12/34/56/78/9.jpg
     
    stuw, Feb 1, 2006 IP
  5. dfsweb

    dfsweb Active Member

    Messages:
    1,587
    Likes Received:
    55
    Best Answers:
    0
    Trophy Points:
    88
    #5
    Yes, I think that's the best way to do it imo too. I follow this method (Storing file names in the db and referencing and displaying them) for two of my sites at work. Plus, I do something similar with my Photography site as well and have never had any performance issues.
     
    dfsweb, Feb 1, 2006 IP
  6. tbarr60

    tbarr60 Notable Member

    Messages:
    3,455
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    210
    #6
    Thanks for the feedback but you are missing the point. Our company (1000's of employees) adopted IBM's software development process which means beauracracy: what would be a one minute job for me to FTP an image to a web server is now a 5 day process starting with checking the file into a version control system on Friday and it gets passed around to various testing servers and then gets put on a production web server the following Thursday or Saturday night. This doesn't work when the CEO says "change pricing before tomorrow".

    The question is there any concerns about calling images from a database not a question about how to store a file name in a database.
     
    tbarr60, Feb 1, 2006 IP
  7. stuw

    stuw Peon

    Messages:
    702
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #7
    It makes your database slow down, unless you can cache the image somewhere else. I guess there would be more server overhead depending on what your doing with the images - like constantly re-sizing them on the fly
     
    stuw, Feb 1, 2006 IP
  8. AWD1

    AWD1 Peon

    Messages:
    191
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #8
    What stuw said.

    I've also heard of cases where the image itself can cause corruption issues with the database.

    These are the reasons I asked the question and made the suggestion I did. Your response times will be much quicker and your DB will be smaller and more stable.

    But...it sounds to me like you're up the excrement creek without a paddle.
     
    AWD1, Feb 1, 2006 IP
  9. stuw

    stuw Peon

    Messages:
    702
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Maybe the CEO needs to be fully briefed on the issues
     
    stuw, Feb 1, 2006 IP
  10. tbarr60

    tbarr60 Notable Member

    Messages:
    3,455
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    210
    #10
    We are a big company (employees measured in thousands, business meausered in billions per month) and have more than enough web server and database server capacity and we use NetCache so the image can be cached outside the database.
     
    tbarr60, Feb 2, 2006 IP
  11. wwm

    wwm Peon

    Messages:
    308
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #11
    ok if it is a big company, and theres no worry bout server loads cause its an intranet

    yes storing images as BLOBs is good idea

    now im not 100% on SQL server but im sure its almost same process for uploading
    images to database as mysql
     
    wwm, Feb 3, 2006 IP
  12. Sham

    Sham Peon

    Messages:
    136
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #12
    You don't work for Shell Oil do you?
     
    Sham, Feb 3, 2006 IP
  13. tbarr60

    tbarr60 Notable Member

    Messages:
    3,455
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    210
    #13
    No, not Shell. It's a financial company.
     
    tbarr60, Feb 3, 2006 IP
  14. eiso

    eiso Peon

    Messages:
    583
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #14
    I think the best thing you can do is take the image binary using php and store that in the database then use a few functions from the PHP GD library to build up the image from binary again.
     
    eiso, Feb 4, 2006 IP
  15. tbarr60

    tbarr60 Notable Member

    Messages:
    3,455
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    210
    #15
    We may do something similar with ColdFusion/Java/SQL Server.
     
    tbarr60, Feb 9, 2006 IP