Gravatar - A Globally Recognized Avatar

A Globally Recognized Avatar

Gravatar is an image that follows you from site to site appearing beside your name when you do things like comment or post on a blog. Avatars help identify your posts on blogs and web forums, so why not on any site?

How it works

Url: http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802?s=80

The URL always begins with http://www.gravatar.com/avatar/ and the next part is the hexadecimal MD5 hash of the requested user's lowercased email address with all whitespace trimmed. Hashing is done to prevent spambots from harvesting e-mail addresses.

Parameters:

  • Parameter "s" will fetch image of size 80x80 (example: s=80)
  • Parameter "g" will fetch image if it is rated G (example: r=g, r=pg)
  • Parameter "d" will fetch a default image if there is no gravatar associated with an email address (Example: d=wavatar, d=404)

Technology Details:

- Initially developed in Ruby on Rails now in PHP.
-
Uses nginx (fourth most popular) as Webserver
-
Photos are served from Amazon S3 Cloud

"The way that images were stored originally was: a complete image was made for all sizes between 1×1 and 80×80 pixels, a directory made for each rating, and a symlink placed from the rating to the appropriate image (either the users image or the default image in case the rating was too high.) So that's 80 images, 5 directories, and 240 symbolic links. The reason for this, I believe, was to attempt to serve the avatar content without any database interaction whatever. The files were then archived, uploaded to Amazon S3, and an entry added to Amazon SQS. Finally the SQS entry was retrieved by the serving server, the file downloaded, extracted, and placed on the filesystem. So this is why it took several minutes once you uploaded and cropped your image for you to be able to browse the rest of the site again. You can imagine how many files Gravatar was comprised of by the time we got a hold of it! We knew that this would simply NOT work for our new 512×512px avatar sizes. Lastly there were a couple of directories which had several hundred thousand entries (either files or other directories) which were nearly impossible to even get a listing inside of. So we had a list of things NOT to do. We just needed to figure out what TO do

So we decided that we would render all our avatars dynamically from the highest quality copy of the image we can manage… down. We would only store one version of the image, though we would store it in multiple places (a local file server for speed, and S3 for redundancy.) We would still rely heavily on caching. And we would asynchronize as much of the workload as was possible, so that you don't have to wait for things to happen after you finish cropping (to do this we employed various techniques and hacks best left for another day and another story.)

Gravatar now lives on about 20 servers: 2 Database servers, 1 File server, 2 Load balancers, 5 Caching servers, 9 Web servers, and 1 Development server. That combination of servers is handling an average of 7,214 of your requests every second of every day. That's a whopping 623,293,056 requests daily! 96% of all of those requests are served directly from cache. These days we get around 5,000 uploaded images every day."

Unique Avatar Icon Generators based on Email address

identicon wavatar monsterid


Gravatar Rocks.

No comments: