litefs icon indicating copy to clipboard operation
litefs copied to clipboard

Websocket connection on a replica node

Open adoublef opened this issue 8 months ago • 3 comments

Working on a pet project, exploring distributed systems & LiteFS. I'm hoping that someone may be able to weigh in on this with a potential solution.

If I wanted to build a chat application whereby clientA & clientB may be connected to a replica node sending messages between each other this data will need to be persisted to the database (on the primary). I'm wondering how this would work.

The http-proxy wouldn't be useful here as a websocket connection is neither a POST/PUT/DELETE request. And I've thought about using halting or forwarding the request but the former solution isn't recommended for high-frequent queries, and the latter would just mean the primary will ever be used (maybe causing it to be overwhelmed).

I'm also using NATS (with Jetstream) as my messaging bus for this application so I'm not sure if utilising their KV API somehow and then propagating the KV store data to the primary litefs node?

As this is an experiential project I'm very open for suggestions, or elaborating if you require more info. Thanks

adoublef avatar Nov 10 '23 23:11 adoublef