Instagram decreases video compute time by 94% without updating hardware
Engineers at Instagram, in an effort to delay running out of room for new videos, developed a method for reducing file size and improving quality, without needing to update any hardware.
Instagram has approximately two billion users, and they all want to upload videos, to the vast number of servers they use. In the early part of 2021 projections of the system showed engineers that within 12 months there would no longer be the capacity to accommodate new videos for everyone.
The engineers in the quest to reverse this eventuality developed a system, where multiple encoded versions of uploaded videos, each with different characteristics, could be repurposed. By repurposing one type of video encoding to help generate another type, the compute resources were reduced on the less-watched videos by 94%, and a drastically decreased amount of resources were realized.
Because there are more resources available, it allowed the engineers a chance to produce more advanced encodings, allowing more people to view smoother playback of clearer video content.
Spending video compute
Essentially there are two types of video encoding on Instagram:
- Minimum functionality encodings, which are compatible with all users on Instagram. They are lower-efficiency compression is more readily decoded by older devices and able to be played by just about anyone.
- Advanced encodings use newer compression technologies for higher-quality playback. This provides great clarity and sharper detail with fewer bits.
The problem with this method of encoding was Instagram was spending 80% of its resources on processing minimum functionality encodings. That course would have monopolized the system with minimum functionality encodings within a year. The advanced encodings took up only 15% of the total watch time. It was found that if the spend was focused on minimum functionality encoding then this would soon prevent them from offering advanced video encoding watch time at all.
There are two minimum functionality encodings:
- Basic adaptive bit rate (ABR) encodings - the most watched encoding of both the minimum functionality encodings. There are versions and playback can be adjusted between versions for connection speed for the steadiest playback. This prevents stalling that is caused by bandwidth changes. This is commonly called adaptive bit rate streaming.
- Progressive encoding - this rarely used encoding package is used for older versions of the Instagram app that don't support ABR playback.
Traditionally an ABR and a progressive encoding profile are created when the client uploads the original video file. This generally hogs compute resources, taking 86.17 seconds to load a 23-second video. The engineers noticed that the settings were similar for both sets of encoding. Very similar codecs were being accessed and developed. What the team discovered in an A-Ha moment, as - they could replace basic ABR encodings with progressive encoding's video frames by repackaging them into an ABR-capable file structure.
This would virtually eliminate the need for generating the basic ABR encodings. This returned a functionality of 0.36 seconds for a video of the same size as the 23-second video. A reduction in computes the time of 94%.
The net result of this efficiency and reduction in net time it takes to render a video, no matter the length is better quality for older devices and newer devices. The use of an ABR that has mostly advanced coding, in a progressive base, would then allow older devices to use the same resources as the newer devices.
This is a real boon to the many users of Instagram, and already the net savings are being put to good use, with higher overall watch times across the server fleet.
Professor John Gunnar Carlsson reroutes the world using the power of math. Carlsson, who is known for solving distribution problems using geometry tells us about his strategy.