-
Notifications
You must be signed in to change notification settings - Fork 2
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
General questions about capabilities #1
Comments
Hi @ywang-clarify, I would love to get you up & running on pohl. Question 1 -> I am looking into this and will give you an update later. Having auto-redis-res-subscription active is not required, as ioredis is able to handle re-connects itself (it is built in though for firewall and other networking reasons) you can deactive it by passing "autoReconnectInterval" with value: null in the config. Question 2 -> You should never have to create more than one RPC client per service/application instance (per pohl topic) and if you do create more than one than that is most certainly the reason why you see "mixed up results". Question 3 -> Yes, currently 2 redis channels are opened per topic inc:topic and out:topic and every instance sender or receiver subscribes to the same topic, the idea was to achieve scalability quickly, by spreading messages to all receivers and making them decide via redlock which one is allowed to work on the task. If you wouldnt want other receivers to listen, you would have to create another rpc client sender and receiver using another topic. Pohl is not built for secure rpc exchange, its goal is to replace http-communication in a microservice world. By sharing high workloads quickly between microservices using redis messages. |
Hi @krystianity, Thanks for the rapid response. I tried setting autoReconnectInterval to null. That avoids the repeated attempts to re-sub, but there's still one re-sub failure reported. And test1 still fails to send.
For question 2, that's exactly the answer I was hoping to hear. So hopefully, after resolving the above issue, everything will be great. For question 3, I think you misunderstood my concern. I like your design for multiple workers which exclusively pick up and work on requests. What concerned me was Pohl.js:182:
I'm working on a healthcare application where there are single-tenant services that want to make RPC calls to a multi-tenant service. So if each single-tenant service brings up a RPC client, there's nothing in the pohl configuration that would differentiate them. They would all end up subscribing to the same redis channels and receive each others responses. The quoted code above would ignore the messages that weren't generated by any particular RPC client, but the response data would still flow to that RPC client. The fact that response data meant for a RPC client at one hospital would flow to an RPC client at another hopsital is a problem. I think with the way things are currently working, you'd have to use a different topic for each hospital to avoid this. But it's difficult to work with a server that has to be aware of the list of hospital clients so it could start dedicated listeners for each of them. It seems better to build dedicated response channels into the protocol. So each client listens for responses on a specified channel. The channel name could even be randomly generated if not specified or defaulted to the topic the way it is right now to maintain the current behavior if not specified. Then in the sendTask(), the task gets a replyTo property that tells the server which redis channel to send the response when it's ready. This way, you can set up a pool of one or more RPC clients listening on the same response channel and apply the same redlock approach to make sure only one of those clients processes the response through the callback. This way, responses for one client pool would never get sent to any other client pool. |
Hi @krystianity, were you able to reproduce the issue in Question 1 where sending two concurrent tasks from the same rpc client fails to run both as expected? |
Hi @krystianity,
There aren't many rpc-over-redis modules for out there. node-pohl seems promising to me and in your README, you mention a lot of important considerations.
But after playing with it for a day, I have some questions. I have a need for an RPC server that can handle requests of the same task type coming from different RPC clients. The clients should only receive responses to their own requests. With that in mind, any clarifications you can provide on the following questions would be greatly appreciated.
Question 1:
I can't seem to figure out how to send multiple requests using the same RPC client without getting stuck.
RPC Client code:
RPC Server code:
Combined output:
It looks like the request for test1 is never sent because something keeps trying to re-sub while a connection is being reported as closed? I can get the same results by taking one of the included usage-tests and adding a second .sendTask() call.
Question 2:
If I create a new RPC client for every request (seems wasteful), I can run concurrent requests. But if I kick off a lot of concurrent requests, the responses seem to get mixed up and the 'result' passed to the RPC client's callback is sometimes undefined for some reason. Have you ever seen that or have an explanation for why that might happen?
Question 3:
It looks like the clients will actually receive messages for all requests and it's just choosing to ignore the ones that it didn't originate (or timed out). Can you confirm that? Basically, the responses for all client are shared with all other clients? That seems a little dangerous. I think I would have to create a dedicated RPC server instance for each client if I want the responses to be private to that client? That seems difficult since I don't want to write server code to be aware of its client base. I was thinking that maybe it'd be possible to add a replyTo to the task protocol and have the RPC clients listen on a private channel for its response.
The text was updated successfully, but these errors were encountered: