voryx / Thruway

PHP Client and Router Library for Autobahn and WAMP (Web Application Messaging Protocol) for Real-Time Application Messaging
MIT License
675 stars 117 forks source link

question: synchronous, slow clients - what happens #243

Closed far-blue closed 6 years ago

far-blue commented 7 years ago

I'm very new to WAMP and I'm still getting to grips with some of the concepts but none of the WAMP client implementations seem to cover clients that respond slowly to RPC calls. We have an existing Rest API in PHP and some of our Rest endpoints are relatively slow (few hundred ms) but because of PHP's traditional request/response setup we are actually relying on PHP-FPM to handle concurrent requests.

If I was to convert this code over to WAMP I assume I'd basically just define RPC providers for the equiv. functionality, running in a WAMP client that would register with a WAMP router. But if an RPC call takes a little time to complete, what happens when additional RPC requests come in from other clients? Are they queued? Can you run multiple instances of the same client to spread the load?

And if a client handles multiple RPC endpoints I assume a long RPC request will also block all other RPC calls on the same client. Does Thruway do something to handle this?

Thankyou in advance for what might be a very noob question!

mbonneau commented 7 years ago

@far-blue You can run multiple instances of the RPC handler and the router can use different strategies to send the requests to these RPC endpoints.

Each RPC would need to be in its own process and would only block that process - the router would be able to handle other incoming requests and does not block (generally speaking).

Let me know if this answers your question.

far-blue commented 7 years ago

Yes, that's great, thanks. I guess depending on the work being done you could also have clients dedicated to the slow tasks and run more of them than the client(s) for other tasks. I assume the router knows which clients are busy and will spread incoming RPC calls among a pool of clients that have all registered the same RPC endpoint.

davidwdan commented 6 years ago

That's right. The router knows how to distribute the calls based upon the strategy that's used.

The supported strategies are:

I'm going to close this issue, because it seems like the question was adequately answered.