Rediscala: Non-blocking Redis driver for Scala
github.com
github.com
I noted that Debasish Ghosh recently updated his redis client to have Akka as the underlying handler as well.
path("get_a_list" / PathElement) { externalKey =>
get {
complete {
for {
internalKey <- redis.get("internal_keys_from_external":externalKey)
finalResult <- redis.smembers(internalKey)
} yield (finalResult.toList)
}
}
}
Spray already expects an akka future, as does everything else, so this library fits in perfectly.Rediscala needs an akka actor System and sometime replies are of type ByteString.
> we have noticed performance issues as redis serves only 1 req every time there was too much time spending in thread-join
Performance should be better with an asynchronous client. When I've benchmarked e.g. jedis vs various async clients, that's been the case.
Redis serves 1 req at a time, but you can write to Redis socket and read from Redis socket during that time.
Rediscala (the RedisClient) use 2 actors: The first one handle I/O (I/O bounds). That actor also merge redis requests in a buffer, so there is less messages (but bigger) going to the TcpWorker (akka worker handling a tcp socket). The second decode replies (CPU bounds)
Also, even simplifying it, it still seems overcomplicated. The returning type: Future[Try[Option[(String, ByteString)]]] is too much. Can't you remove the Try or the Option? Futures can already hold either a Sucess or Failure, so isn't the Try redundant?
https://github.com/twitter/finagle/tree/master/finagle-redis
Benchmark : http://bit.ly/12QZsRs
May be helpful to compare the underworkings to see different approaches.