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

One-shot rpc invocation option instead of a persisted ws session #228

Open
lsafer-meemer opened this issue Nov 6, 2024 · 3 comments
Open
Assignees
Labels
feature New feature or request

Comments

@lsafer-meemer
Copy link

Is your feature request related to a problem? Please describe.
Websocket sessions could reach thousands when thousands of users have the client app open.
Yet, the only option to reduce that is to establish a ws connection in each invocation or establish
a ws connection that lives with the lifecycle of the app.

Don't get me wrong, I want long lived ws connection for communication between services but
not for communication between user client applications and a service.

Describe the solution you'd like
I don't exactly know if websocket sessions are very light or not for thousands of simultaneous long-lived
connections to be a problem but if so, there should be a way around that.

Maybe supporting different kinds of RemoteServices were one has instance-per-connection policy and
another is invocation-per-connection policy?

Describe alternatives you've considered
If kotlin-rpc was aimed to service-to-service communication, I think a gRPC kotlin wrapper would be a better choice.

On the other hand (if kotlin-rpc was aimed to client-to-service communication), I think the only alternative would
be Ktor resources (yuk!)

Additional context
I am creating a KMP project were the client app and the server app are both in Kotlin and I am searching for an
elegant more "natural" way of communication between the two.

@lsafer-meemer lsafer-meemer added the feature New feature or request label Nov 6, 2024
@Mr3zee
Copy link
Collaborator

Mr3zee commented Nov 6, 2024

Hi, @lsafer-meemer! Thank you for the feature request. We are thinking about protocol enhancements, and we'll take this into consideration during the design

@PicoPocoo
Copy link

Or maybe keep the websocket connection open as long as one of the registered services are invoked. After an idle period of ( for example ) 5 seconds close the websocket and create a new websocket when there is another invocation of a registered service?

But to the be brutally honest, I have no idea how resource intensive it is to keep thousands of ( maybe mostly idle ) simultaneous websocket connections alive. Ktor is kinda great, so maybe they figured something smart out :)

@TheDome0
Copy link

I haven't found a way to detect when the underlying websocket session has closed. For example trying to add webSocketSession.outgoing.invokeOnClose {} throws an IllegalStateException saying that there already is another handler registered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants