Skip to content
Advertisement

Best way to store user’s avatars

I have a website where users each have their own profile page. Here they can upload a single image that acts as their avatar. This is the only image users can upload to the server across the whole site. There is no archive so it can be overwritten if a user wishes to update their avatar.

I have never had to do anything like this before so I would like to open it up and ask for a suitable, scalable option for this website.

My initial thought is to give each user’s image a random name, a string 6-12 characters long. This way you couldn’t build a script that just pulls every user’s profile pic from a directory (eg 001.png, 002.png etc). My second thought is that there should be only be a certain amount of images per directory to make sure they can be retrieved quickly by the server.

There may well be other things I’m missing here, I’m not sure on exact details hence why I’m asking.

Advertisement

Answer

I would recommend storing the images on something like Amazon S3. Depending on how many pictures you’re storing, serving images can really take a tow on your web server. S3 is scalable and with multi-zone deployments through CloudFront (Amazon’s version of a CDN), you can really speed up this part of your service.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement