I'm developing web app that user can save his/her work to server. The data will be saved is in variable-length binary form, it's size mostly under 20KB (sometimes little bigger < 100KB). The data wi开发者_C百科ll often be changed / updated.
I have 2 options saving the data in server: as BLOB (mysql) or as filesystem with reference to its filepath stored in db server. I heard that each option have pro and cons.
Which is best for my app ?
Thanks
I'd probably go for the DB approach. The speed difference isn't likely to be that much, and I'm a big fan of having all data stored in one place. It's much easier to get a consistent back up of a database then it is to backup a database, filesystem, and associated data (and preserve consistency)
It also provides a uniform access method, consistent permissions, and allows you to access things remotely without setting up a separate service.
That said, it may be worth your while to keep your options open and not tie it to the db too tightly in case you want to move later.
I recommend placing it in the DB. It makes little sense building a special format for storage and access of this data, just to avoid going through the DB. What about simultaneous accesses from multiple instances of your application (a likely scenario in a web app)? With a DB you can leave these worries to the DB engine if you just use it correctly. With your home-cooked file format you'll be in trouble.
精彩评论