User Controls

Should I store images in a database?

  1. #1
    GasTheKikesRaceWarNow Houston [this unquestioningly unfrequented clast]
    Just blob them?
  2. #2
    infinityshock Black Hole
    only if you dont want to retain ownership of them
  3. #3
    aldra JIDF Controlled Opposition
    I don't like to do it because it puts extra load on the database and increases the chances of corruption

    depends on the application though I guess - if it's just light duty and small images it shouldn't be an issue
  4. #4
    Lanny Bird of Courage
    What's the application? If you're talking about a webserver you expect to be under any kind of load the answer is that you don't. Databases are generally not well optimized for blobs, even when they do support them, if they don't then you fuck your DB's caching and seek tradeoffs hard by storing images. Conversely your filesystem is very good at handling image sized files and apache/nginx/lighttpd takes advantages of this.

    Typically you'll want to store files on a disk on the same machine as your web server and store paths or something you can resolve to a path in the DB, at least up to CDN levels of load. After that it changes a bit but storing images in DBs, even sharded ones, isn't what you want. The extra backup effort is well worth it.
  5. #5
    Lanny Bird of Courage
    or be a bum like me and say fuck it. fun fact: everyone's avatar will be lost in a single disk failure.
  6. #6
    Originally posted by Lanny or be a bum like me and say fuck it. fun fact: everyone's avatar will be lost in a single disk failure.

    Thank god I have multiple backups of my avatar.

    What else would be lost though? In the event of a disk failure I mean
  7. #7
    Dfg Tuskegee Airman [compulsively riposte the emigrant]
    1) Use database for storing link/url
    2) Store them on the harddisk or CDN

    And backup shit regularly.
  8. #8
    Lanny Bird of Courage
    Originally posted by Fox Paws Thank god I have multiple backups of my avatar.

    What else would be lost though? In the event of a disk failure I mean

    logs and some stray config files, nothing critical or that couldn't be recovered. The DB is regularly backed up.
  9. #9
    GasTheKikesRaceWarNow Houston [this unquestioningly unfrequented clast]
    Originally posted by Lanny What's the application? If you're talking about a webserver you expect to be under any kind of load the answer is that you don't. Databases are generally not well optimized for blobs, even when they do support them, if they don't then you fuck your DB's caching and seek tradeoffs hard by storing images. Conversely your filesystem is very good at handling image sized files and apache/nginx/lighttpd takes advantages of this.

    Typically you'll want to store files on a disk on the same machine as your web server and store paths or something you can resolve to a path in the DB, at least up to CDN levels of load. After that it changes a bit but storing images in DBs, even sharded ones, isn't what you want. The extra backup effort is well worth it.

    It's a tarot card intepretation application. I'm probably going to stick it on AWS, so none of that stuff about optimisation matters, just what the jedi Bezos charges me.
  10. #10
    aldra JIDF Controlled Opposition
    Originally posted by GasTheKikesRaceWarNow It's a tarot card intepretation application. I'm probably going to stick it on AWS, so none of that stuff about optimisation matters, just what the jedi Bezos charges me.

    ideal setup would be to use RDS for the database and S3 for the images with Cloudfront in front of that
  11. #11
    GasTheKikesRaceWarNow Houston [this unquestioningly unfrequented clast]
    Originally posted by aldra ideal setup would be to use RDS for the database and S3 for the images with Cloudfront in front of that

    That sounds like the way to go, but why bother with Cloudfront?
  12. #12
    aldra JIDF Controlled Opposition
    it depends on how much load you anticipate I guess.

    S3 is used for storage, Cloudfront is used as a CDN to cache files - having your users access data from the Cloudfront cache is cheaper than having them access S3 directly, but if you're not planning on a lot of traffic it may be more troublesome setting up Cloudfront in the first place.
  13. #13
    Yes. Also be sure to run the server on your PC in your mom's basement, using her connection and no CDN
Jump to Top