Design Cross-Device Wallpaper Synchronization
AppleSoftware Engineer · OnsiteLast updated
This question tests the ability to design a distributed synchronization system that balances low-latency local updates with eventually consistent cross-device state, focusing on conflict resolution, bandwidth optimization, and offline-first availability.
System Design: Cross-Device Wallpaper Synchronization
Design a service that ensures a user's wallpaper remains synchronized across all their registered devices (e.g., iPhone, iPad, Mac). The system must provide a seamless experience where local changes are applied instantly, while remote changes are propagated in the background.
Functional Requirements
- Users can set a local image as their wallpaper, which should sync to all other devices.
- Devices may be offline for extended periods; synchronization must resume once connectivity is restored.
- A device might undergo multiple wallpaper changes while offline; the system must ensure the "latest" state (by timestamp or sequence number) eventually propagates.
Non-Functional Requirements
- Efficiency: Minimize battery and data usage. Do not re-upload large files if the user reverts to a previously synced wallpaper.
- Responsiveness: The local UI must update immediately upon user interaction.
- Reliability: Handle concurrent edits from different devices gracefully.
Design Constraints
- Assume assets (images) are immutable and identified by a content-based hash (e.g., SHA-256).
- Devices have varying storage capabilities; define a strategy for local cache management.
Your answer should cover:
- API Design: Define the endpoints or communication patterns for state updates.
- Data Model: How do you track the "current" wallpaper state across devices?
- Conflict Resolution: What is the strategy for handling simultaneous updates (e.g., Device A sets Wall1, Device B sets Wall2 at the same time)?
- Sync Architecture: Explain how you handle delta-syncs, batching updates, and background synchronization to preserve battery life.
Hints
Hint 1
Consider maintaining a versioned state object on a central server that contains the image hash and a wall-clock timestamp.
Hint 2
Use a "Last-Write-Wins" policy based on synchronized server time, but clarify how you handle potential clock drift between devices.
Hint 3
Implement a content-addressable storage (CAS) approach where images are uploaded to a blob store once, and the metadata service merely tracks the hash of the current wallpaper.
Follow-up questions
- How would you handle the synchronization of large files (e.g., 4K ProRAW images) on cellular data compared to Wi-Fi?
- If a user has 10 devices, how would you design the push notification system to avoid 'thundering herd' issues when a device comes back online?
- How would you incorporate a 'rollback' feature to revert to a previous wallpaper without re-uploading the image data?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.