etaty / rediscala

Non-blocking, Reactive Redis driver for Scala (with Sentinel support)
Apache License 2.0
790 stars 142 forks source link

Throttling Redis Requests #138

Open wb14123 opened 8 years ago

wb14123 commented 8 years ago

Hi,

In our service, we read requests from a queue and send it to Redis backend. If I use the non-blocking way in rediscala, then there will be too many jobs for actors. So I'd like to throttling redis requests, set a rate limit on it.

I think I can implement it by throttling the RedisClientActor messages. What is your suggestion?

wb14123 commented 8 years ago

I think it's better to control it in my own queue. So closed it.

wb14123 commented 8 years ago

But here is another question. I don't know the ability of the backend Redis. So I think it is better to set a capability for RedisClientActor, when its pending messages exceed the capability, it should blocking the next request. What do you think?

etaty commented 8 years ago

yes there is no throttling in the redis protocol. Only way is to send a batch and wait for the Futures complete state, and send another batch.

etaty commented 8 years ago

I have not played with it, but there is bounded queue in akka, if you are able to tell the RedisActor to use a bounded queue.

etaty commented 8 years ago

Hum wait that doesn't work (The redis actor always consume and add to a queue the rediscommands). Only way is to listen for the redis response and send more.

wb14123 commented 8 years ago

Thanks, I'll have a look at it.

wb14123 commented 8 years ago

Is it possible to add a capability for the rediscommands queue?