Is memory more efficient for storing images in mysql as a BLOB or as simple files?

I have a LAMP server with 256 MB of RAM (a bad human server in the cloud). I have an application written to run on this machine. Currently, people upload images and they go directly to mysql like a blob.

There are concerns that this could be very random access memory, and we are moving it to simple, simple files. Can someone tell me if these fears are valid? (Is it worth trying to change a lot of the odes that have already been written, given that we will have enough RAM in the next 6 months?)

As a rule, when should we store images in the database and when as files?

+3
source share
5 answers

For reading BLOBin MySQLyou need three times more than what is required (it is copied to several buffers).

So yes, reading BLOBin MySQLconsumes more memory than reading a file.

+15
source

You must save them to the file system for several reasons:

  • Images are easily accessible through other applications (shell, FTP, www, etc.),
  • It is less resource intensive ( including memory ) to read them from the file system than from the database
  • If the database is corrupted, the images are safe.
  • ( ), ( ).

, , - , .

+8

:

:

  • ( )

:

  • .
  • HTTP

:

  • ( )
  • -

:

  • .

, . , , . , .

, . . , , .

. , . , , , .

- BLOB -. Flickr BLOBs . , , , .

+6

WebPage, DataBase. Apache .

, , , , , , , , , - ( DB : + ).

+1

, . , , SQL- - .

, ( ) . , , . , (, ,...), "" , 1-1000 /1, 1001-2000 ares, /2 .. , .

0
source

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


All Articles