Serving resized S3 images on the fly
#9 Protecting from Concurrent Access
If you didn’t notice — this is part of a series
Today we are to tackle the problem of concurrent access and how it could lead to the app being overwhelmed with requests.
Imagine a freshly generated link for an image that has never been downloaded from AWS and never had a thumbnail generated.
The address to generate such a thumbnail goes to the home page of a popular website. This website happens to serve constantly about 1000 people.
As soon as the link is published, everybody starts requesting the thumbnail of the image.
Effectively, this means 1000 image requests to the AWS for the source. In the case of a 7Mb large image, we are talking about almost seven gigabytes of wasted transfer!
Then the server would launch the Imagick converter. Can you guess how many times? Such traffic would generate a CPU spike that would cause a self-DDoS attack and effectively block the server.