peers / peerjs-server

Server for PeerJS
https://peerjs.com
MIT License
4.38k stars 1.09k forks source link

Peerjs-server should support Redis #113

Closed aldovincenti closed 5 years ago

aldovincenti commented 5 years ago

I love this project but I think peerjs-server should support Redis. I'm not a WebRTC expert, but if I'm not wrong this server isn't really scalable. Any plan to implement Redis support or switch to socket.io which already supports Redis?

kidandcat commented 5 years ago

You don't need to scale this server because you will only get 2 request at the time of setting up the connection. it's nearly the same as a STUN server.

Anyway, storing IDs in redis could give you more possibilities, sadly I don't have time to develop it. Any PR is welcome.

ChristopheBougere commented 5 years ago

In addition to scaling capability, using a distant Redis would decouple the storage layer from the compute layer, and allow to run the server on a FaaS solution (like AWS lambda). But I guess there would be other changes too. Also, even if the server does not have to scale, being able to start a new one without losing data in case the first one crashes would be nice.

kidandcat commented 5 years ago

I'm contrasting different approaches for this as I would also love to deploy PeerServer in a Serverless provider (Zeit Now). But in an environment like that persistent connections may not be the best approach. I'm comparing databases too. Redis is awesome, but have it replicated for having HA is hard, and I'm a linux sysadmin so, when I mean hard, I mean HARD.

ChristopheBougere commented 5 years ago

@kidandcat I finally decided to build my own signaling service, which is actually quite simple. I took advantage of the new API Gateway websockets support, and used DynamoDB to persist connected users/rooms (should be fast enough). Concerning Redis, I don't know about Zeit Now, but many cloud providers offer managed Redis.

kidandcat commented 5 years ago

Nice, I was thinking about how to surpass the websockets things when using serverless. Sadly I use Zeit Now (which I consider much cheaper, easier to use, and trustable) so I need to wait for them to support websockets or find another paradigm for PeerJS.

If you have any troubles with the signaling, you can ask here :)

ChristopheBougere commented 5 years ago

First time I'm hearing about Zeit but it looks interesting, I will have a look!

If you have any troubles with the signaling, you can ask here :)

Great thanks! It seems that the most complicated piece is on the frontend because you need to integrate many different things, while the server is a simple WS server with rooms management. Signaling & co was hard to understand until I found this tutorial where they do everything from scratch using just webrtc-adapter.

afrokick commented 5 years ago

Ok, leave it AS IS. Maybe in the future we'll be support Redis/Mongo/etc. as a persistence storage

tobowers commented 4 years ago

I finally decided to build my own signaling service, which is actually quite simple. I took advantage of the new API Gateway websockets support, and used DynamoDB to persist connected users/rooms (should be fast enough). Concerning Redis, I don't know about Zeit Now, but many cloud providers offer managed Redis.

@ChristopheBougere

Is that code available?

ChristopheBougere commented 4 years ago

@tobowers Yes, code is now available here: https://github.com/ChristopheBougere/avatarz/tree/master/signaling It's just a PoC, but it works pretty well