TLDR;
Dropbox was using the same C++ code library to upload photos from smartphones. This wasn’t sustainable because Android and IOS started to have different constraints and requirements (ex. when background processes can run).
This led Dropbox to use native platform technologies like Swift (IOS) and Kotlin (Android) to scale uploading photos.
What’s the Problem?
Using the exact same reusable library for photo uploads for both Android and IOS devices is not scalable for Dropbox.
Android recently included AppStandby limits to allocate resources to apps being frequently used. Having a shared C++ library to be aware about differences like these leads to an unmaintainable codebase.
For Dropbox’s use case, silently uploading photos in the background has become more of a problem for Android users like forgetting to upload images when network activity is available.
Give me the Requirements!
Focusing on Android architecture, here’s what we care about
Take advantage of as much background activity as possible.
Photo uploads need to be speedy quick and limit memory usage
Validate and don’t break anything that already works
(IOS architecture isn’t in scope, lets focus on one thing at a time)
What are we doing, boss?
First, we’re uploading photos on Kotlin instead of C++.
For everything else, we’re doing this:
Background Activity:
If a new photo is added or being changed, a background worker called the “Scanner” picks them up and queues them up.
Another worker called the “Uploader” looks at the queue and batch uploads them to Dropbox when there’s network activity available.
Speed and Latency
Upload multiple photos at the same times by fixing endpoints to support this.
Scan the entire library every there’s a change. Process anything that has already been checked, even if scanning is still on-going.
Validation
Run things against the old C++ library and Kotlin implementation at the same time. Compare and if anything’s different, something went wrong.
Simplify the Design!
Let’s start at “Photo added to user’s library”. If there’s edited or added photos, the scanner is going to take a look if it needs to be added to Dropbox.
If yes, add them to a queue. If no, ignore and have a nice day.
If there’s something in the queue, wait until there’s network access. When there is, batch upload everything with the uploader.
Sources and Official Article!
(Link to sources and the full design article is available to paid subscribers! They help support this newsletter and maintain service costs.)
Keep reading with a 7-day free trial
Subscribe to Byte-Sized Design to keep reading this post and get 7 days of free access to the full post archives.