Design an Async Resource Loader for a Desktop Client with Local and CDN Sources

Quick Overview

A system design question about the resource loader of a desktop client: resolve resource IDs through a manifest to installed files or CDN downloads, decrypt and decompress, and deliver results through an async callback. It tests exactly-once completion, retries, request coalescing with per-caller cancellation, and memory reclamation.

Design an Async Resource Loader for a Desktop Client with Local and CDN Sources

Company: Roblox

Role: Software Engineer

Category: System Design

Difficulty: hard

Interview Round: Technical Screen

Design the resource loading module of a desktop client application. The application uses resources such as textures, audio and 3D models. Some resources ship with the installer and sit on local disk; others are downloaded from a CDN at runtime. Some resources must be decompressed or decrypted after they are retrieved, and only after that processing are they placed in memory for other modules of the application to use. The discussion is in pseudocode. Be concrete about each interface's inputs and return values and about how the parts connect. Decompression and decryption already exist as functions; say at which step of the flow you call them. ### Constraints and Clarifications - Callers pass only a resource ID. The loader looks the ID up in a resource index (the manifest), which yields a local path, a CDN address, or both. - When both exist, prefer a valid local version. When the local file is missing or its version does not match and a CDN address exists, download instead. - Loading is asynchronous, for example `loadAsync(id, onComplete)`, which registers a completion callback. When the resource is ready, the callback hands the usable resource to the caller. Failure and cancellation are reported through the same callback, and each request gets exactly one callback. - Network timeouts and interrupted downloads may be retried at intervals; once the retries are used up, return an error. A resource confirmed not to exist, or a caller who cancels, ends the request immediately. - A downloaded file becomes a usable cache entry only after the download is complete. - Concurrent requests for the same resource ID and version may share one underlying load. Each caller keeps its own callback and its own way to cancel. ### Clarifying Questions - Is the manifest shipped with the installer, downloaded, or both, and can it change while the application runs? - Beyond a version match, does a "valid" local copy need a size or checksum check? - On which thread should callbacks run: the thread that called `loadAsync`, or any worker? - Is there a memory budget for loaded resources, and are some resources expected to stay loaded for the whole session? ### Part 1: Resource sources and the basic load path Define the public interface and the manifest lookup. Walk one ordinary local load end to end: read from disk, decrypt or decompress if needed, place the result in memory, and hand it to the caller. Then add the CDN path and the rule for choosing between a local copy and a download. ```hint Start with one local load Get a single local load correct from lookup to callback first, then decide where the network branch joins that flow. ``` #### What This Part Should Cover - The interface: inputs, what `loadAsync` returns, and what the callback receives - Manifest lookup and the local-versus-CDN decision, including the version check - Where decryption and decompression run in the flow, and on which threads ### Part 2: Asynchronous completion and notification Specify how completion is reported. Success, failure and cancellation all arrive through the same callback, and each request receives exactly one callback. Describe the states a request moves through and how you guarantee exactly one callback. ```hint List the races Write down the events that can happen at nearly the same time for one request, such as a cancel arriving just as the load finishes. ``` #### What This Part Should Cover - Request states and their terminal outcomes - The exactly-once guarantee under racing completion, failure and cancellation - Callback threading and the form in which the resource is delivered ### Part 3: Failures and retries Separate failures worth retrying (network timeout, interrupted download) from failures that end the request (resource confirmed missing, caller cancellation). Define the retry interval and limit, and make sure a partial download never becomes a usable cache file. ```hint Ask whether retrying can help For each failure, ask whether trying again could produce a different result. ``` #### What This Part Should Cover - Classification of failures and a retry policy with spacing and a limit - How a completed download is promoted into the disk cache, and what happens to partial files - Handling of errors during decryption or decompression ### Part 4: Duplicate requests and cancellation When several callers request the same resource ID and version at the same time, share one underlying load while each caller keeps its own callback and cancel entry point. One caller cancelling ends only that caller's wait; the others keep waiting. When the last waiter also cancels, remove the task if it is still queued, or try to abort a load that has already started and clean up after it. ```hint Separate the load from the request Model the shared underlying load and each caller's request as different objects, and track which requests are still waiting on a load. ``` #### What This Part Should Cover - Coalescing by resource ID and version, with per-caller callbacks and cancel handles - Cancel behavior for one waiter versus the last waiter, for queued versus running loads - Cleanup of temporary files and buffers after an abort ### Part 5: Caching and memory How are frequently used resources reused? When memory is tight and resources must be reclaimed, how do you tell whether a resource is still in use somewhere in the application? ```hint Follow the resource after delivery Consider what a caller holds once its callback has fired, and how the loader learns that the caller no longer needs it. ``` #### What This Part Should Cover - An in-memory cache keyed by resource ID and version, and how it relates to downloaded files on disk - Tracking whether a resource is in use, and evicting only unused entries - A request that arrives while its resource is being evicted ### What a Strong Answer Covers - A design that grows from the plain local load to the network, failure and sharing cases without being rewritten for each one - Concurrency correctness: shared loader state protected consistently, and no callbacks run while internal locks are held - Bounded resource use: limits on concurrent downloads, worker threads for processing, and a memory budget - Observability: per-request timings, cache hit rates, and retry and failure counts ### Follow-up Questions - How would you add priorities so that a resource needed on screen now loads before background prefetches? - How would the design change if one resource depends on others, such as a 3D model that references its textures? - What happens when a manifest update changes the version of a resource that is currently in use?

Overview: A system design question about the resource loader of a desktop client: resolve resource IDs through a manifest to installed files or CDN downloads, decrypt and decompress, and deliver results through an async callback. It tests exactly-once completion, retries, request coalescing with per-caller cancellation, and memory reclamation.

Read the full Roblox Software Engineer interview experience this question came from

Roblox logo
Roblox
Nov 20, 2026
hardSoftware EngineerTechnical ScreenSystem Design
0
0

Design the resource loading module of a desktop client application. The application uses resources such as textures, audio and 3D models. Some resources ship with the installer and sit on local disk; others are downloaded from a CDN at runtime. Some resources must be decompressed or decrypted after they are retrieved, and only after that processing are they placed in memory for other modules of the application to use.

The discussion is in pseudocode. Be concrete about each interface's inputs and return values and about how the parts connect. Decompression and decryption already exist as functions; say at which step of the flow you call them.

Constraints and Clarifications

  • Callers pass only a resource ID. The loader looks the ID up in a resource index (the manifest), which yields a local path, a CDN address, or both.
  • When both exist, prefer a valid local version. When the local file is missing or its version does not match and a CDN address exists, download instead.
  • Loading is asynchronous, for example loadAsync(id, onComplete) , which registers a completion callback. When the resource is ready, the callback hands the usable resource to the caller. Failure and cancellation are reported through the same callback, and each request gets exactly one callback.
  • Network timeouts and interrupted downloads may be retried at intervals; once the retries are used up, return an error. A resource confirmed not to exist, or a caller who cancels, ends the request immediately.
  • A downloaded file becomes a usable cache entry only after the download is complete.
  • Concurrent requests for the same resource ID and version may share one underlying load. Each caller keeps its own callback and its own way to cancel.

Clarifying Questions Guidance

  • Is the manifest shipped with the installer, downloaded, or both, and can it change while the application runs?
  • Beyond a version match, does a "valid" local copy need a size or checksum check?
  • On which thread should callbacks run: the thread that called loadAsync , or any worker?
  • Is there a memory budget for loaded resources, and are some resources expected to stay loaded for the whole session?

Part 1: Resource sources and the basic load path

Define the public interface and the manifest lookup. Walk one ordinary local load end to end: read from disk, decrypt or decompress if needed, place the result in memory, and hand it to the caller. Then add the CDN path and the rule for choosing between a local copy and a download.

What This Part Should Cover Guidance

  • The interface: inputs, what loadAsync returns, and what the callback receives
  • Manifest lookup and the local-versus-CDN decision, including the version check
  • Where decryption and decompression run in the flow, and on which threads

Part 2: Asynchronous completion and notification

Specify how completion is reported. Success, failure and cancellation all arrive through the same callback, and each request receives exactly one callback. Describe the states a request moves through and how you guarantee exactly one callback.

What This Part Should Cover Guidance

  • Request states and their terminal outcomes
  • The exactly-once guarantee under racing completion, failure and cancellation
  • Callback threading and the form in which the resource is delivered

Part 3: Failures and retries

Separate failures worth retrying (network timeout, interrupted download) from failures that end the request (resource confirmed missing, caller cancellation). Define the retry interval and limit, and make sure a partial download never becomes a usable cache file.

What This Part Should Cover Guidance

  • Classification of failures and a retry policy with spacing and a limit
  • How a completed download is promoted into the disk cache, and what happens to partial files
  • Handling of errors during decryption or decompression

Part 4: Duplicate requests and cancellation

When several callers request the same resource ID and version at the same time, share one underlying load while each caller keeps its own callback and cancel entry point. One caller cancelling ends only that caller's wait; the others keep waiting. When the last waiter also cancels, remove the task if it is still queued, or try to abort a load that has already started and clean up after it.

What This Part Should Cover Guidance

  • Coalescing by resource ID and version, with per-caller callbacks and cancel handles
  • Cancel behavior for one waiter versus the last waiter, for queued versus running loads
  • Cleanup of temporary files and buffers after an abort

Part 5: Caching and memory

How are frequently used resources reused? When memory is tight and resources must be reclaimed, how do you tell whether a resource is still in use somewhere in the application?

What This Part Should Cover Guidance

  • An in-memory cache keyed by resource ID and version, and how it relates to downloaded files on disk
  • Tracking whether a resource is in use, and evicting only unused entries
  • A request that arrives while its resource is being evicted

What a Strong Answer Covers Guidance

  • A design that grows from the plain local load to the network, failure and sharing cases without being rewritten for each one
  • Concurrency correctness: shared loader state protected consistently, and no callbacks run while internal locks are held
  • Bounded resource use: limits on concurrent downloads, worker threads for processing, and a memory budget
  • Observability: per-request timings, cache hit rates, and retry and failure counts

Follow-up Questions Guidance

  • How would you add priorities so that a resource needed on screen now loads before background prefetches?
  • How would the design change if one resource depends on others, such as a 3D model that references its textures?
  • What happens when a manifest update changes the version of a resource that is currently in use?