Efficiently Stream and Synchronize Multiple Data Types
Project: Slooh Space Camera
Challenge
Deliver and synchronize images, text and several audio streams from multiple servers to thousands of users in near-real time
Comments
The online astronomy app, Slooh, served users with a data-rich experience that had to take place simultaneously among thousands of users, and had to include a tight synchronization of events across multiple kinds of data: numeric data from remote observatories, images, whiteboarding, chat and up to three simultaneous audio streams.
The solution was a strategic combination of communication protocols and business rules, all tied together with timestamps and application logic that was executed partly in the server, partly in the client.
Actions
- Used Flash Media Server (FMS) running on fast Linux machines as the hub for outgoing and incoming data
- Made full use of AMF binary transfer formats, plus RTTP streaming as default protocol, with HTTP tunneling as fallback
- Handled image loading via http from a web server, eliminating load on FMS
- Designed concise data objects and enforced strict data logic at all points to minimize transfer sizes
- Strategic caching of data in both server and client
- Implemented load balancing at FMS by strategic use of multiple app instances and chatroom model for distribution of processing
- Used highly optimized data parsing in the client, including lookup tables to avoid math conversions
- Strategic use of callbacks, queuing of commands and low-priority async responses in both server and client to defer less urgent tasks to moments of reduced load
- Optimization and scheduling of heavy computations, such as bitmap operations, to avoid blocking of high priority tasks
- Business logic divided between FMS and Flash client to intelligently prioritize and queue transfers
- All Flash clients synchronized to server time and data presented according to cues from server and decision formulas hard-coded into the client