Normal image saving or mySQL blob?

I am programming a php / mysql web application which is kind of like a blogging platform where people can upload photos and post them.

What is the best way to store these images, Saving them in a folder or in mySQL table via BLOB?

I ask about this because I need the easiest way that allows me to easily move to another host / server without spending days downloading all hosted images and uploading them to a new server.

An optional question: is a dedicated server enough for a new blogging platform?

thanks

+4
source share
7 answers

From the database. When it exits the database, your web server can do its job and force clients to cache images. Doing this with a dynamic database-driven image is more complex. In addition, you will find that you are likely to get much better performance by letting the web server handle this.

+5
source

If you provide hosting for static files, you may need to disconnect files from CDNs such as Amazon S3. Implementing is a lot of work, but you don’t have to worry about moving files if you change web hosts (unless you change the cdn provider). Plus, file access will be localized to the client and you don’t even need to hit your web server for most requests, thereby reducing bandwidth usage.

+3
source

The best way is to save the images in a directory and save only the image name in the database. Thus, the database will not be huge and will be more convenient for maintenance ...

+1
source

If these are images - a database. Performance can be as good as the file system, especially if you extract the file along with the file name and maintain data integrity, which is much more important than performance, at least for business applications and regular websites (i.e.Not youtube, gmail , microsoft.com, etc.)

here's more on the topic: http://sietch.net/ViewNewsItem.aspx?NewsItemID=124

One thing you should check and research yourself is how MySQL handles drops. If it were SQL Server or Oracle, I am sure that they do a good job with blobs and especially the special types of filestream and bfile. I have no experience with MySQL and I do not know if it can handle more than a few megabytes of blobs.

+1
source

In my web applications, I stored binaries from a database. The implementation is more complicated, but the database is space conservation.

0
source

Save them as files:

  • It's faster.

  • You can process files (copying to another server) without even accessing the database.

With the smart design of your application, you can even avoid accessing the database of these images. A cached template refers to images or with a smart file name.

0
source

Do not use the database - use the file system. I had the same problem, tried both approaches and, frankly, there were too many problems using db as a binary data store.

Instead, I have a folder containing all the downloaded files, with a database and an object that is associated with the downloaded files, but instead of just storing them β€œas is”, I save them instead when the file name is the appropriate Checksum MD5 (or SHA-1) of the aforementioned file, which pretty well eliminates duplicate downloads and reduces overhead - require (); more efficient than dumping data from db.

0
source

Source: https://habr.com/ru/post/1300564/


All Articles