I'm trying to implement RPC broker. The broker takes commands, sends them to the RPC servers, waits for result and then sends the result to the client. My approach is like this pseudocode:
function onClientCommand(cmd) {
sendCommandToRPCServer.then(function(result){
returnResultToClient(cmd.client,result)
})
}
As you can see sendCommandToRPCServer returns a promise. I'm expecting this function to be called very frequently (several thousands calls per second). When the system get under heavy load, RPC servers get slow and there will be more and more unresolved promises in Broker memory.
So my question is:
If the Broker rejects promises after some timeout, will this remove promises (e.g. its resolve and reject functions with their contexts, there is no reference to that promise) from memory? I know I can solve this by array of callbacks and periodically clear old items of it, but "promise-like" approach is better for me, because sometimes broker needs to wait for several RPC calls and then return result to client and this is easier with promises.