I am working on spring web application, in which I have functionality where user can upload image. I have confusion about when to compress this image. I am thinking for below 3 choices.
1) User upload image, compress image in backend, save this image and send response back to user. (will it take more time to response to user if there are millions of users and many of them upload images frequently?)
2) User upload image , Send response back to user, notify to compression algorithm in some way (using JMS) which compress given image and replace original one.
3) Run scheduler which compress all the images uploaded between certain time period (later save this time period in database so can be used next time)
Can anyone help to figure out which approach I should use? is there any better approach than this?
Thanks in advance.