Skip to content
giongto35 edited this page Dec 1, 2019 · 5 revisions

CloudRetro has multiple servers for streaming game and a coordinator distributing traffic and pairing connection with servers. We call server

Worker

Worker is responsible for streaming game to frontend worker

  • After Coordinator matches the most appropriate server to the user, webRTC peer-to-peer handshake will be conducted. The coordinator will exchange the signature (WebRTC Session Remote Description) between two peers over Web Socket connection.
  • On worker, each user session will be attached to a game session. A game sesssion contains one RetroArch emulator with selected game and a media pipeline. Image stream and audio stream from emulator is captured and encoded to WebRTC streaming format. We applied H264/Vp8 for Video compression and Opus for audio compression to ensure the smoothest experience. After finish encoding, these stream is then piped out to user and observers joining that room.
  • On the other hand, input from users is sent to workers over WebRTC DataChannel. Game logic on the emulator will be updated based on the input stream.
  • Game state is stored in cloud storage, so all workers can collaborate and keep the same understanding with each other. It allows user can continue from the saved state in the next time.

Overlord

Overlord is the coordinator, which is in charge of picking the most suitable workers for a user. Every time a user connects to Overlord, it will pick the nearest worker that still has sufficient computing resource and assign it to the user. Overlord sets up a peer-to-peer connection between worker and user based on WebRTC protocol.

Architecture

  1. A user connected to Overlord .
  2. Overlord will find the most suitable worker to serve the user.
  3. Overlord collects all latencies from workers to users as well as CPU usage on each machine.
  4. Overlord setup peer-to-peer handshake between worker and user by exchanging Session Description Protocol.
  5. A game is hosted on worker and streamed to the user.