Choosing storage place for Images
In this article I have jotted down various pros and cons for choosing the best storage place for images used in our web based applications.
There are two basic approaches for storing the images that are used in our web application
- File System
- Database
Below are some comparisons between the two:
Ease: One can easily configure the path of an image from a directory on the web server containing images while from database one needs to create custom logic for reading Image data (eg .ashx handler for image)
Flexibility: It is always easy to store a new image file on the web server while in case of database new column needs to be created.
Maintenance: Using simple file operations for storing the image on web server is very trivial task while in case of database one might need to create a complex query or business logic.
Caching: IIS can be easily configured to cache images stored in file system while images in database needs some further complex IIS configuration
Size: As the web directory in which our application is hosted can be easily scaled in terms of size for storing more images as a when needed while in database the size of database goes on increasing affecting the overall database performance.
Compatibility: Images are stored on file system with basic file operations while in case of database during migration process to some other database vendor their may be some Data Type compatibility problem
Performance: File operations are less costly in resource utilization while database operations are more costly in terms of resources.