I write an industry-grade Java API that provides you a few 100s JPEG images. The total size will be 15 MB which is not much. I believe that hosting the Java app due to this size is not an issue.
I think should I put the images inside the Java app or put in the cloud and read from there. What will be a better decision?
Ideal solution would be to have some sort of storage space like Amazon S3 cloud storage.
Benefits: 1. Central storage space : if wish to scale your application, each deployment would not have it's own copy of these files, that ultimately would avoid synch up problem across various deployment nodes.
So, you need to assess if you would need these benefits compared to the cost of having a storage space, and how likely is it that you would be scaling this app.
I may add or remove a few of them after months. But, generally, they don't change.
In fact I would distinguish two cases :
1) your application renders/displays a list of images hosted in a directory and the most recent version is the better for clients.
2) your application uses/relies on specific images in its code to render/manipulate it.
For the first case, I agree with the Ankur answer : use an external storage to decouple the application component and its images. It is the right solution.
For the second case, using an external storage or storing the images in the application are acceptable solutions. Each one has its advantages and its drawbacks.
External storage
Advantages :
Drawbacks :
For example, in the dev branch/env you could use the image set v.2 while you would use the image set v.1 for all other branches/envs that reflects the actual production component.
You don't want to spread the the image set v.2 everywhere as this will break the applications deployed in other envs. As a consequence, you need :
Images stored in the source code
Advantages :
Drawbacks :
According to my experience, if you use tools to automate your app configuration/redeployment (such as Ansible) and that you perform regularly deployments, the images stored in the source code approach is interesting because that is simple and the second drawback is not : "require to perform redeployments for any image set version." because you already redeploy often and that the whole deployment chain is effective.
If you feel brittle, uncomfortable about redeployments, using an external storage is probably safer while new images will always force you to redeploy the application to have a code that uses that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.