This isn’t a direct answer to your question but storing images on S3 will not give you the performance improvement you’re expecting. In fact it will make it slower.
The reason is that all image URLs go via the database, they never link directly to files even when you store files on disk. In other words:
- You have a URL like example.com/?qa=image...
- That runs a PHP script same as any other page on Q2A.
- It checks the database for the referred image.
- The script echo’s the binary data stored, whether in the db or by reading the file from disk.
If you store the image on S3 then your server has to go and read the image and output it to the user. That’s obviously slower than the server reading straight from its own disk.
However, it is possible to use a CDN. I don’t think S3 is really intended as a CDN, CloudFront is the CDN part. That can be put in front of any website, you don’t need to put images elsewhere. It’s quite expensive though so you might want to try something like CloudFlare which is free for basic usage. There are others like MaxCDN, Akamai, CDN77.