Skip to content
This repository was archived by the owner on Jun 3, 2026. It is now read-only.

pion/webrtc-zero-downtime-restart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webrtc-zero-downtime-restart

Warning

The APIs this example uses were never merged into Pion. If you are interested in these APIs please reach out!

This API has a few downsides

  • Complexity of implementing it Saving+Resumption of state requires additional code. You have to update all your business state as well, this made it hard to deploy.

  • Privacy+Security Saving crypto state meant that previous packets could be replayed+decrypted. Keeping this only in memory is safer for users.

  • Handling across versions Having to support resumption across multiple Pion versions might be error prone.


webrtc-zero-downtime-restart is a simple Pion WebRTC broadcast server that can be restarted without disconnecting users. All the WebRTC state is suspended to disk. The next time the process is started that information is read into memory. All the remote PeerConnections will be unaware that they are even connected to a new process. This gives us the following benefits.

Painless Deploys

No more migrating users to a new process when you want to deploy code. At anytime you can replace the binary you are running and no users will be impacted. You don't need to implement extra signaling/error handling for your deploy process.

Easier Scaling

Move clients to an entirely different host without them knowing. You can do this with zero interruption in service or additional signaling.

Greater Resiliency

Since server state is constantly being written to disk you don't need to worry about crashes anymore. If you server goes down (and then restarts) it will automatically resume the last known good state.

Running

Execute go run github.com/pion/webrtc-zero-downtime-restart@latest.

This will start the server. On startup the server will print.

Open http://localhost:8080 to access this demo

You can then access it at http://localhost:8080. The first user to connect will broadcast their webcam. Every user after can watch the broadcasted video.

At anytime you can start+stop the process in your terminal. Users will not be disconnected and will be able to continue talking when the process is started again.

What is next

This demo uses reflection to access internal Pion WebRTC APIs. We will be working on designing the final APIs for the next major release of Pion WebRTC. We would love your feedback ideas either on the repo or Slack

About

A playground to make WebRTC easier to deploy, safer and more robust

Topics

Resources

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Contributors

Languages