Code Monkey home page Code Monkey logo

Comments (5)

SebastianStehle avatar SebastianStehle commented on May 28, 2024

We have designed the project structure to also support other protocols. But SignalR does not really solve any problem. SignalR is great because of the backplane, but the general problem is that we don't have an architecture for clustering yet.

Yjs documents are potentially big states and you might receive hundred of updates within a short time. Therefore you cannot load the state from the storage for each update. You need to keep it in memory or at least I think that this would be the best option. If you have multiple servers you also don't want to have a copy on each server because you need to synchronize them.

So I think you have a several solutions:

  1. Sticky load balancer sessions using the document ID.
  2. Use something like Microsoft Orleans to have an actor per document (then you can use SignalR) again.
  3. Use a single server.

from ydotnet.

vdurante avatar vdurante commented on May 28, 2024

@SebastianStehle thanks for the response!

I ended up implementing a SignalR server to see how that would perform. It honestly performs well, but likely won't scale as good as WebSockets.

In my use case I don't see that much concurrent users, so it would work for quite some time before it really requires a refactor. But I definitely understand why it would be much better to use WebSockets in the future.

I will close this for now. Thanks!

from ydotnet.

SebastianStehle avatar SebastianStehle commented on May 28, 2024

I am not so concerned about the transport protocol. You can just embed the binary protocol in a message and go. if you want to contribute, you are more then welcome. But I don't see how SignalR helps with scaling.

We designed the library to support other protocols, so you contribution would be awesome :)

from ydotnet.

vdurante avatar vdurante commented on May 28, 2024

SignalR doesn't help with scaling, but it does help if your infrastructure doesn't support websockets, etc. That was my initial problem.

We have a limitation on our infra since it runs on stateless pods and there is no way of keeping an open connection to the pods. Besides that, we also don't have a load balancer that is able to direct all websocket calls to the same pod.

I will definitely contribute once my solution is working decently hehe. Right now it is a mess of code spread everywhere.

from ydotnet.

SebastianStehle avatar SebastianStehle commented on May 28, 2024

Even if you use SignalR, you get problems, if you have more than one server. It depends on your use case, but if you use ydotnet for a text editor (like prosemirror), you handle every single key stroke. So you get a lot of messages and you cannot load the document for every single key stroke. Perhaps you can use signalr for that together with a stateful set. So you use a stable number of servers and assign the documents based on the hashset of the pod name. Then use SignalR groups and messaging to redirect the message to the correct pod. But it is also not ideal.

Btw: Even with stateless pods your web socket connection should stay open as long as no one closes it. But afaik SignalR also requires sticky sessions: https://learn.microsoft.com/en-us/aspnet/core/signalr/scale?view=aspnetcore-8.0

from ydotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.