I recently interviewed for a Principal Engineer role on the Roblox Studio team. First there was a Hiring Manager round, which I passed, and then a separate System Design round that ran about an hour.
The question was to design a resource loading module for a desktop client. Resources like textures, audio and 3D models are either shipped locally with the install package or downloaded from a CDN at runtime. Some of them also have to be decompressed or decrypted after they are fetched, and once processed they go into memory for the other modules in the app to use.
This round was done in pseudocode. You can be fairly specific about the interface inputs, the return values and how the parts connect. Decompression and decryption can be treated as existing functions, you just say at which step of the flow they get called.
Resource source.
The caller only passes a resource ID. The loader looks it up in the resource index (manifest) and gets a local path, a CDN URL, or both. If both exist, you can prefer a valid local version. If the local file is missing or the version does not match, and there is a CDN URL, switch to downloading.
Async loading and notification.
For example, use loadAsync(id, onComplete) to register a completion callback. When the resource is ready, the callback hands the usable resource to the caller. Failure or cancellation also comes back through the same callback with its own result, and each request calls back only once.
Failure and retry.
A network timeout or an interrupted download can be retried at intervals, and when the attempts run out you return an error. If the resource is confirmed not to exist, or the caller cancels, you just end it. Only make the file available as a cache after the download is complete.
Duplicate requests and cancellation.
When the same resource ID and version are requested at the same time, you can share one underlying load. Each caller has its own callback and its own cancel handle. One person cancelling only ends their own wait, and the others keep waiting. When the last waiter cancels too, you can remove the task if it is still queued, or try to abort a load that has already started and clean up.
Caching and memory.
How do you reuse resources that are used repeatedly? When memory is tight and you need to reclaim, how do you tell whether a resource is still being used somewhere?
If you are preparing for this question, first take one ordinary local load and walk through the whole chain of reading, processing and handing off to the caller, then add network loading and the other cases.
Discussion
Loading comments…