Damian
Damian

Reputation: 5561

Database or Filesystem?

I know there are several questions similar, but I can't find one that answers my specific problem:

I need to save some data in a server for a game I'm developing.
Each user will save one binary file and some time after ask for it.
The file can be something between just a bunch of bytes to around 50kb.

A lot of questions (mostly about images) say to use the filesystem, because that file can then be served as static content. In this case that's not possible, since I will have to check somehow that I'm sending that file to the right user, and also I need some logic return the file only if it's not the same the user already has.

Should I save that file in the database or in the filesystem?

Note: The server will be hosted on Linux, and the DB will probably by MySQL.

Thanks!

Upvotes: 0

Views: 1010

Answers (3)

Oded
Oded

Reputation: 499262

I suggest reading this whitepaper (To BLOB or Not To BLOB: Large Object Storage in a Database or a Filesystem) by Microsoft research (it deals with SQL Server 2005).

The conclusions are - if the files are under 250kb, use the DB to store them

In essence, filesystems seem to have better fragmentation handling than databases and this drives the break-even point down from about 1MB to about 256KB.

Of course, you should test for your own DB and OS.

Upvotes: 1

Stephane
Stephane

Reputation: 3402

I'm afraid you're far from providing enough information to answer your question correctly. If I read your question "naively", all you're trying to do is write a save game system.

In such a case, the file system is really all you need. DB are good for storing structured data that you're going to search, sum, combine and index, not for storing arbitrary bunch of small blobs.

Now, if there is other requirement, for instance, you're writing a web-based game that store the data for all players in a central location, the answer MIGHT be different (again, you need to provide much more details about what you're doing, though)

Upvotes: 3

Jayyrus
Jayyrus

Reputation: 13061

I think you could user a sort of database. Filesystem is slow, cause it go on hard disk, move head to find file. With db, the access is faster. If your server is hosted on windows, you can use a microsoft db, access, that is little and fast.

Upvotes: 0

Related Questions