Store original temporary uploaded image (to be deleted once filtered) using AWS

108 Views Asked by At

I have built an image upload feature using PHP. The implemented scenario was dealing only with local filesystem of the server machine, and now I need to re-implement the feature to fit with AWS. The problem is that AWS offers 3 types of file storage (EFS, EBS ans S3) and I don't know how to deal with steps 1 and 3 of used scenario:

  1. The original image is uploaded and stored in the system (after renaming and sanitizing).

  2. I create 3 copies from that image (small, medium, large) using the Imagine library filters. These 3 copies are intended to be copied to S3 using PHP AWS SDK. They are also optimized for better performance.

  3. The original image is deleted (because it is big, not used, and its deletion is psychologically good).

In other terms, where is it better to store the original temporary image? is it better to use EBS or EFS for this image or also store in S3 alongside the final images, then delete it after.

What is the "nearest" storage system to EC2 in terms of latency and execution speed? They all need an EC2 instance but certainly one of them will suit better this condition of temporary .

Your experience was always invaluable to us. Thank you very much

1

There are 1 best solutions below

2
On BEST ANSWER

I will suggest to keep the image on you EBS volume as any ways you are going to delete that image after processing. Your EBS volume is fastest way for that image to process as it is directly attached to the EC2 instance, and then move those 3 images to S3. EFS volume attached to your EC2 will also work in your case but again EFS is expensive and not good option for temporary storage.

If you move that large image to S3 and then process it then there will be increase in S3 data transfer cost also latency will be involved as it will take time for that image to upload to S3.

So best option for temporary image storage is EBS or upto certain level EFS on your EC2 instance.