Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App/Backend-Architecture: How do Snapchat stories load so fast? [closed]

Simple question - How do Snapchat stories load so fast, and even when I "skip" an item, the next one is always ready?

Snapchat stories is a mix of images and videos, whenever the screen is tapped, the next item starts instantly, no matter if it's an image, or a video. I have never seen any delay in the app, and I'm wondering

How do they do it? Do they cache all the content once the app is started (highly unlikely)? Do they continuously pre-load upcoming items while you are watching a story? Do they load everything when I tap the story? I do not understand the "magic" behind the flawless stream of content. Also: What does the backend provide? A list of resources?

Does anyone know how they do it? Other apps like Yeti or Fleek pretty much do the same thing, executed in the same flawless manner. I'm a somewhat decent iOS developer, yet I have no idea of the method that is used here.

like image 559
schnabler Avatar asked Nov 08 '22 20:11

schnabler


1 Answers

The use case allows for background-readying on the app side, and caching on the back end.

So how I'd do it is something like this:

  • When the app comes into focus, have a background thread find some links to the stories that come right after. Also if you get toward the end of the cached content, look ahead some more. Possibly have some sort of visual animation so people can't flick to the very end without giving the app a chance to load some data.
  • Since you know what comes after, the back end can move all the content to cache, where it will feel nice and snappy. The fact that SnapChat is not supposed to be persistent helps a lot, because once the recipients have seen the stuff you can remove it from cache. Also since recipients are not editing the information, you don't have a cache coherence issue (actually can you edit stuff? Haven't looked in a while).
like image 123
Carlos Avatar answered Dec 06 '22 06:12

Carlos