Serving billion GIFs every single day

Serving billion GIFs every single day

GIPHY serves 10 billion GIFs every day, here's how it beautifully uses different features of CDN.

What is CDN

Think of CDN as a geographically distributed cache; and just like any regular cache, it sits between the user and the origin.

For any request, if it has the data, it serves the response. If not, it hits the origin to grab the data, cache it, and then responds.

Geographical Nearness

A key highlight of using a CDN is geographical nearness. Because the CDN servers are distributed worldwide, the request from a user is served from the nearest edge server giving an excellent UX.

CDN for media content

This is a no-brainer application of CDN. Giphy serves all the media content like images and videos through CDN that sits transparently between the user and the origin (eg: S3).

CDN for API responses

Apart from the media content, Giphy uses CDN to cache API responses of Search and Discover APIs like

  • /v1/gifs/trending
  • /v1/search?q=funny

It serves these APIs from CDN because the responses of these APIs do not change often; hence using CDN for this reduces the load on API servers.

Route-specific TTL

Not all APIs or media objects need to be cached on CDN for the same amount of time. Hence Giphy configures different expirations for different types of APIs.

Media object endpoints are cached longer while trending API is cached for a shorter duration.

Response-driven TTL

Sometimes, it is the backend server that should dictate for how long the response should be cached.

Hence, Giphy, in the HTTP response from the origin server provides max-age headers that tell CDN the TTL for the specific response. This gives finer control over key expiration.

Cache invalidation by grouping

Giphy uses Surrogate Keys (tags) while caching endpoints on CDN. It helps in smarter cache invalidation, eg:

  • invalidate API responses that contain a specific GIF
  • invalidate API responses from an API key
  • invalidate API responses where the query contains a particular query


Here's the video of my explaining this in-depth 👇 do check it out

Thank you so much for reading 🖖 If you found this helpful, do spread the word about it on social media; it would mean the world to me.

If you liked this short essay, you might also like my courses and playlists on


No alt text provided for this image

I teach an interactive course on System Design where you'll learn how to intuitively design scalable systems. The course will help you

  • become a better engineer
  • ace your technical discussions
  • get you acquainted with a spectrum of topics ranging from Storage Engines, High-throughput systems, to super-clever algorithms behind them.

I have compressed my ~10 years of work experience into this course, and aim to accelerate your engineering growth 100x. To date, the course is trusted by 800+ engineers from 11 different countries and here you can find what they say about the course.

Together, we will dissect and build some amazing systems and understand the intricate details. You can find the week-by-week curriculum and topics, testimonials, and other information at https://arpitbhayani.me/masterclass.

Shubham Kaushik

Systems Engineer at Tata Consultancy Services

2y

hi Arpit Bhayani ! Is there any vacancy in your company fie the post of database administrator, please share

Like
Reply

You are from COEP right pune. I am also from Pune.

Like
Reply
Like
Reply

Arpit Bhayani Thanks for sharing with design insights.I always wonder and curious to understand the internals of top companies innovations and found that #AsliEngineering is the right destination. 😎

POOJA JAIN

Storyteller | Linkedin Top Voice 2024 | Senior Data Engineer@ Globant | Linkedin Learning Instructor | 2xGCP & AWS Certified | LICAP'2022

2y

Amazing!! Thanks for sharing across! Arpit Bhayani

To view or add a comment, sign in

More articles by Arpit Bhayani

  • The best resource does not exist.

    The best resource does not exist.

    This edition of the newsletter contains two quick write-ups about The best resource is mythical Convergent Encryption I…

    4 Comments
  • It's not about what you know, but about how you think

    It's not about what you know, but about how you think

    This edition of the newsletter contains two quick write-ups about It's not about what you know, but about how you think…

    1 Comment
  • Roadmaps are just satisfying your urge to follow a syllabus

    Roadmaps are just satisfying your urge to follow a syllabus

    This edition of the newsletter contains one quick write-up about Roadmaps are just satisfying your urge to follow a…

    3 Comments
  • Always negotiate the offer you get

    Always negotiate the offer you get

    This edition of the newsletter contains two quick write-ups about Always negotiate the offer you get Why PostgreSQL…

    3 Comments
  • Proving your Culture Fit

    Proving your Culture Fit

    This edition of the newsletter contains two quick write-ups about Proving your Culture Fit What not to say during…

    1 Comment
  • Premature Abstractions

    Premature Abstractions

    This edition of the newsletter contains two quick write-ups about Quantify and show impact, whenever and wherever…

    1 Comment
  • Tip the scale in your favor in interviews

    Tip the scale in your favor in interviews

    This edition of the newsletter contains two quick write-ups about How to tip the scale in your favor during interviews…

    2 Comments
  • 7 questions that you should ask your interviewer

    7 questions that you should ask your interviewer

    This edition of the newsletter contains two quick write-ups about Questions that you should ask your interviewers The 4…

    5 Comments
  • Traits of a 10x engineer

    Traits of a 10x engineer

    Build your own Interpreter CodeCrafters launched a super interesting challenge on building your own interpreter. Give…

    3 Comments
  • How PostgreSQL stores data in files, called forks

    How PostgreSQL stores data in files, called forks

    Thank you so much for reading this edition of the newsletter 🔮 If you found it interesting, you will also love my…

    1 Comment

Insights from the community

Others also viewed

Explore topics