Thanks to my cousins, Recently I've been very active on Snapchat. Well, my SnapScore isn't braggable but enough to tickle my curiosity on what happens when I send a snap. After exploring and researching here's what I think:
So, Snapchat, like other giant companies is hosted on AWS ( Amazon Web Services ) and has the same generic distributed architecture as other giant companies. To give you an idea SC has around 332 million daily active users, that's super sweet, compared to my favorite social platform Reddit which has only approximately 15-20 million DAU, Although I low-key don't want Reddit to become mainstream. But what I do want is to see our industry come up with something other than this Micro-Tech to scale, anyway. Moving on...
Obvious things first,
-> Snap uses S3 buckets to save their assets.
-> CloudFront ( CDN ) to deliver them.
-> EKS ( Elastic Kubernetes Service ) to manage their cluster.
So, the way our snap travels is that it hits the Snap Gateway first, Snap Gateway is built using something called Envoy. Envoy is a proxy for Cloud Native apps built by folks at Lyft. It's going into my "Cool stuff should try this weekend" stack, which is pretty full at the moment. Although Envoy supports HTTP/3 they don't seem to have migrated to it yet. The pretty sweet thing about Envoy is that it provides something called xDS which can be used to configure your endpoints dynamically.
Microservices in Snap's architecture follow the sidecar pattern, which makes it more modular and maintainable. Service-to-service communication happens over a service mesh, in order to monitor it they built a custom app which they call "Switchboard".
They do have microservices for different set of use cases, like "Friends" microservice, "Users" microservice etc.
Another interesting thing that I found is that they built a wrapper around the Dynamo DB and they now call it "Snap DB", the reason being tons of ephemeral data that snap has to deal with and tons of cost that AWS charges with upscaling of Dynamo DB. Honestly, I can sympathize with them for this, also AWS is rich AF anyway.
Friend Graph
Any asset accessing user request would first hit Snap's friend graph microservice which would then return the requested permissions assigned to this particular user, to do this, Snap's messaging service would obtain the client's persisted connection ID from their elastic cache, which makes your request super fast. which means, that if your request to Friend Graph returns true then you'll be able to view the Snap.
So, That's just a high-level overview with some intricate details on how Snap works, to know more
like follow subscribe just go to their engineering blog
Until next time,
Jai Mahismati!