Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] using Centrifugo Proxy endpoint in stateful services ? #747

Closed
sajjad-fatehi opened this issue Dec 25, 2023 · 5 comments
Closed

Comments

@sajjad-fatehi
Copy link

Hey guys,

There is a situation we need help with, so if anyone can help, it would be greatly appreciated.

During the previous conversation, you advised against using client SDK (websocket) in the backend. Due to the stateful nature of our service and the fact that it runs in a K8s environment, we cannot manage the RPC proxy endpoint, and using Centrifugo API seems impossible. Could we use the server API without changing our software architecture? Is there anything you can advise me on?

@sajjad-fatehi sajjad-fatehi changed the title [question] using Centrifugo API in stateful service routing ? [question] using Centrifugo Proxy endpoint in stateful service ? Dec 25, 2023
@sajjad-fatehi sajjad-fatehi changed the title [question] using Centrifugo Proxy endpoint in stateful service ? [question] using Centrifugo Proxy endpoint in stateful services ? Dec 25, 2023
@FZambia
Copy link
Member

FZambia commented Dec 25, 2023

@sajjad-fatehi hello, to be honest I do not understand the problem here – could you elaborate more? Why k8s is a limiting factor? Why exactly using RPC proxy endpoint is impossible? K8s provides services, services have DNS address, so communication between Centrifugo and your backend should be definitely possible.

@sajjad-fatehi
Copy link
Author

you are right ! its possible in k8s to communicate between services.
let me explain more :
our service is not stateless ! so we have to create channels isolated . i mean a channel only will be created and used in one of our PODs.
so if we suppose we have 2 PODs , we have two api endpoint addresses like :

  • k8s-link-pod-1
  • k8s-link-pod-2
    correct me if im wrong here
    now if any client connect to centrifugo and send RPC to Channel-1 ... i want to all RPCs proxies to only k8s-link-pod-1.
    something like this .

@FZambia
Copy link
Member

FZambia commented Dec 26, 2023

RPCs are not sent to channel, they have method and data fields. I.e. no relation to channels at all.

Does Granular proxy mode solves this for you? You can configure different RPC endpoints for different RPC namespaces. If you need more complex logic on per-method level – then I suppose you can create HTTP proxy service which will route RPC requests from Centrifugo to proper destinations.

@sajjad-fatehi
Copy link
Author

sajjad-fatehi commented Dec 26, 2023

thank you .

I suppose you can create HTTP proxy service which will route RPC requests from Centrifugo to proper destinations

i think this is our solution.

@FZambia
Copy link
Member

FZambia commented Dec 26, 2023

There is a very similar issue about channel-related proxying - #483 - the idea is to have some templating for proxy endpoint construction, based on variables available at the moment of issuing the request.

In this case you are talking about RPCs, so I suppose all we have is user and method at this point - sth like pattern matching to detect endpoint could be done I suppose, but this requires full understanding how exactly you want to transform methods to endpoints. Probably describe your use case there, maybe it will be possible to address one day – but it's definitely not a quick addition

@FZambia FZambia closed this as completed Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants