Should web application store images in Database or File system?

As a web developer storing images in the file system would be the easiest and it is the best way. If the images are stored in the database then below are its disadvantages

  1. On request, the specified file has to be retrieved from database and temp file should be created, which would be referenced in the generated html. This is a time consuming task and it will delay the page load.
  2. In database, the image data would be stored as BLOB or IMAGE. If a particular record doesnot have any image then also it will consume certain space. To avoid this images should be stored in separate table and it should be accessed via foreign key.
  3. In shared hosting environment, where the database, disk space, web servers and other tools would be provided by the service provider, the database space would be very much limited and it is good option to utilize the file system. In case virtual private hosting this may not be an issue.
There are also some advantages to store the images in Database.
  1. If multiple servers are required for load balancing then if the images are available in database then it would be easy to take backup or replicate the data.
  2. Databases are helpful to keep multiple versions of the images.
  3. It provides some security as against storing all the image files in the file system.
What is the best solution? You need to pick based on your requirement. If it is a single server then I would recommend to store images in file system. If you scale then store the images in database but cache it in file system. For first time the images will be loaded from database and after that the images are loaded from file system. This would be difficult as to ensure both database and cache are in sync.

See also:
http://www.findbestopensource.com/tagged/database
http://www.findbestopensource.com/tagged/cache

Please post your feedback.



Bookmark and Share          11464



comments powered by Disqus


Related Articles

10 Free services for your Website / Blog. Just plug it.

Each website / blog delivers useful content or service to its users. But website themselves requires some service to monitor and increase its presence. Here are few free services which could be used by Website / Blog. This will be very much helpful for small business owners.

Read more

10 sites to get the large data set or data corpus for free

You may require GBs of data to do performance or load testing. How your app behaves when there is loads of data. You need to know the capacity of your application. This is the frequently asked question from the sales team "The customer is having 100GB of data and he wants to know whether our product will handle this? If so how much RAM / Disk storage required?". This article has pointers to the large data corpus.

Read more

An introduction to MongoDB

MongoDB is the most exciting SQL-free database currently available in the market. The new kid on the block, called MongoDB is a scalable, high-performance, open source, schema free and document oriented database that focuses on the ideas of NoSQL Approach. Written in C++, it has taken rapid strides since its emergence into the public sphere as a popular way to build your database applications.

Read more

LucidWorks Vs SearchBlox - Enterprise Search Solution

Enterprise search software should be capable to search the data available in the entire organization or personnel desktop. The data could be in File system, Web or in Database. It should search contents of Emails, file formats like doc, xls, ppt, pdf and lot more. There are many commercial products available but LucidWorks and SearchBlox are best and free.

Read more

Is ZooKeeper mandatory for Cloud

Cloud is nothing but more than one system or application distributed across the network, across the globe. It may have couple of application servers, database server, shared data storage, backup server and lot more. The resources in the distributed environment must have information about each other so that they could co-ordinate and share without any issues. ZooKeeper helps to do that.

Read more

Best situation to use Column database

Column oriented database or datastore as the name sounds it stores the data by column rather than by row. It has some advantages and disadvantages over traditional RDBMS. Developer should know the typical situation to choose column oriented database.

Read more

Advantages and Disadvantages of using Hibernate like ORM libraries

Traditionally Programmers used ODBC, JDBC, ADO etc to access database. Developers need to write SQL queries, process the result set and convert the data in the form of objects (Data model). I think most programmers would typically write a function to convert the object to query and result set to object. To overcome these difficulties, ORM provides a mechanism to directly use objects and interact with the database.

Read more

Why require Searchengine? Why not use database for full text search in Enterprise application.

Most of the database has support of full text search, basically indexing and saarching. MySQL, Oracle and many more databases has in-built full text search. Then what is the need to go for external search engine like Lucene, Sphinx, Solr etc. Check out the advantage of using Searchengine.

Read more

Lucene / Solr as NoSQL database

Lucene and Solr are most popular and widely used search engine. It indexes the content and delivers the search result faster. It has all capabilities of NoSQL database. This article describes about its pros and cons.

Read more

Column database vs OLAP

OLAP (Online Analytical Processing), Reporting, Data mining related tasks are usually done by Business intelligence products. They do powerful Extraction, Transformation and Loading (ETL) the data and provides various reports. They use relational database as its back end. How could they generate better reports? Will column DB do a better job?

Read more

Follow feeds Follow bestopensource on Twitter Follow bestopensource on Facebook


Open source products are scattered around the web. Please provide information about the open source projects you own / you use. Add Projects.

Do you provide Consulting, Training, Support for any open source products. Register your business

Tag Cloud >>