Discover more from System Design Newsletter
How Giphy Delivers 10 Billion GIFs a Day to 1 Billion Users
#14: And CDN Explained Like You’re Five (3 minutes)
Get the powerful template to approach system design for FREE on newsletter sign-up:
Once upon a time, there lived a tiny server.
She had a single purpose in life: to give people dancing cat GIFs and make the internet a fun place.
People who asked for the dancing cat GIFs lived closer to her.
So she was able to give it to them fast.
And she was living a Happy life.
But one day.
An Evil GIF maker, Bob entered the picture.
And ruined it all.
He puts a famous cat GIF on the tiny server.
So people from many countries started asking her for it.
But most of them lived far away.
So it took her lots of time to give it to them.
And she was Sad.
So she dials Giphy engineers for help.
“What’s the big deal?”, said Giphy engineers, “Let’s get you some friends for help”.
And called her new friends Edge servers.
Their only job was to keep a GIF copy and give it to people nearby.
Also they had a superpower: they were fast because they stored GIFs in memory.
Edge servers lived in different countries closer to people.
So people who lived far away got the GIF fast from them.
And life was Good again.
Until one day when Bob returned.
He showed no Mercy.
And puts a new viral cat GIF on the tiny server.
Phone calls for the tiny server skyrocketed.
Because no edge servers had a copy of the viral GIF.
Yet people all over the world asked them for it.
But the tiny server could attend only a few phone calls simultaneously.
So she was under pressure. And Heartbroken.
She picks up the phone and calls Giphy engineers for help.
This time Giphy engineers thought hard. And came up with a simple idea.
“Did you make any best friends?”, asked Giphy engineers.
“Oh, I bonded with a few of the edge servers”, replied the tiny server.
Then they did something Magical.
“You talk only to your best friends from now on”, said Giphy engineers.
And called her best friends the Shield servers.
Their only job was to protect her.
From that day on, the tiny server had more time for herself. Because only shield servers called her for the viral GIF.
While edge servers rang the shield servers for the viral GIF.
And everyone lived Happily ever after.
Using edge servers to deliver GIFs faster is called the Content Delivery Network (CDN).
Giphy uses Fastly CDN.
It helped them to handle 100 thousand requests per second. And deliver 10 billion GIFs a day to more than 1 billion people.
Besides CDN reduced their latency and server costs.
Also AWS S3 stores GIFs. And DynamoDB stores GIF metadata.
Consider subscribing to get simplified case studies delivered straight to your inbox:
Thank you for supporting this newsletter. Consider sharing this post with your friends and get rewards. Y’all are the best.
Did you enjoy this post? Then don’t forget to hit the Like button ❤️
Reference: https://engineering.giphy.com/how-giphy-uses-fastly-to-achieve-global-scale/
Amazing work
Would be great if you could give a more detailed explantation of CDN
In the latest part of this article (after the ELI5 part), I would suggest to mention that CDN + NoSql db for metadata is a very common pattern used by tons of companies in their architecture not just by Giphy.
Also that this pattern is not even specific to GIFs but it can be used for any static assets (images, audio, video).
Finally, mentioning technologies like DynamoDB without explaining what it is, it is very counter productive for teaching about system design. So often I've seen system design interviews fails because candidates mention AWS technologies by name before they correctly understand why to use each of them or what those can be replaced with in another cloud provider.
I would suggest to add "Metadata are not stored in CDN but separately in a NoSQL db like DynamoDB"