Comments (11)
Yep you should put val redis = RedisClient()
outside of your main loop (here Action)
RedisClient()
does a lot of thing (initialise a connection to redis server, pop 2 actors ...)
from rediscala.
Thanks for your reply, as the jedis client is not threadsafe, I put it at method level, and I did the same for your driver!
Trying now :)
from rediscala.
Now its works perfectly, and it's very fast!
My conclusions now are that the fastest test is redisscala with blocking code and a big thread pool (but the nb ofthreads will not be infinite...) , then the async redisscala, and then Jedis.
Thanks for your help!
from rediscala.
Do you have numbers ?
Could you show the "redisscala with blocking code" ?
from rediscala.
Yep,
In fact I've relunched the load test and it's quite similar in blocking or not blocking mode (I hope it's readable on github) :
blockingredissimulation :
STATISTICS
Requests Executions Response Time (ms)
Total OK KO Min Max Mean Std Dev 95th pct 99th pct Req/s
Global Information 10000 10000 0 0 80 1 5 10 30 906
request_blocking_redis 10000 10000 0 0 80 1 5 10 30 906
async redissimulation :
STATISTICS
Requests Executions Response Time (ms)
Total OK KO Min Max Mean Std Dev 95th pct 99th pct Req/s
Global Information 10000 10000 0 0 120 2 6 10 30 929
request_redis 10000 10000 0 0 120 2 6 10 30 929
The blocking redis code is very simple :
def blockingRedisQuery(q: String) = Action {
val result = Await.result(redis.get(q), 10 seconds).map(_.utf8String).getOrElse("not found")
Ok(result)
}
It uses the default thread pool with 500 threads
from rediscala.
Thanks.
If you are going for async, you can reduce the thread pool size.
What was the number with Jedis?
from rediscala.
Also you should avoid doing many map on a Future when you can write it in one map :
.map(_.get).map(_.utf8String).map( result =>
Ok(result)
)
.map(r => Ok(r.get.utf8String))
Each time you map
, you add a Future to threadpool which will have to be scheduled
from rediscala.
Thanks for the tip, I'll try like this
For the thread pools, I have 500 threads for Jedis and "blocking redisscala", but for the async redisscala test, I have only 1 thread by cpu
from rediscala.
I've removed the useless map operation
Now I have EXACTLY the same performance with async and blockign simulations : 997 request/sec and 84% of requests <= 1ms
I can put the benchmark on github if you wish
from rediscala.
Yep good idea, it might help other.
from rediscala.
I've pushed everything here : https://github.com/loicdescotte/play-redis-benchmarks
from rediscala.
Related Issues (20)
- Rediscala v2.0 roadmap
- Builds for Scala 2.13 (-M5) in Central Maven Repo HOT 1
- can update akka 2.5.10+? HOT 2
- stop() not part of a trait
- Question: How to distinguish between operation failures
- Timeouts for RedisClientPool
- rediscala endless retry loop when connection fails
- Redis streams support? HOT 1
- This is a mistaken issue..deleted.
- UnsupportedClassVersionError HOT 8
- Redis Protocol error: Got 43 as initial reply byte
- Please make a patch release, with fixes for RedisCluster
- Smembers is set as isMasterOnly = true HOT 1
- [Question] why sentinel not support sentinel auth?
- [Question] Should RedisClientPool extend Transactions?
- [Question] Use SSL to Authenticate
- creating a RedisClient from a typed akka behavior
- [Question] Akka Dispatch error when using rediscala.
- How we can do health check for redis cluster using `redisscala`?
- Null pointer exception at redis.RedisCluster.$anonfun$onConnectStatus$1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rediscala.