Giter VIP home page Giter VIP logo

Comments (11)

etaty avatar etaty commented on August 17, 2024

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.

loicdescotte avatar loicdescotte commented on August 17, 2024

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.

loicdescotte avatar loicdescotte commented on August 17, 2024

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.

etaty avatar etaty commented on August 17, 2024

Do you have numbers ?

Could you show the "redisscala with blocking code" ?

from rediscala.

loicdescotte avatar loicdescotte commented on August 17, 2024

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.

etaty avatar etaty commented on August 17, 2024

Thanks.
If you are going for async, you can reduce the thread pool size.

What was the number with Jedis?

from rediscala.

etaty avatar etaty commented on August 17, 2024

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.

loicdescotte avatar loicdescotte commented on August 17, 2024

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.

loicdescotte avatar loicdescotte commented on August 17, 2024

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.

etaty avatar etaty commented on August 17, 2024

Yep good idea, it might help other.

from rediscala.

loicdescotte avatar loicdescotte commented on August 17, 2024

I've pushed everything here : https://github.com/loicdescotte/play-redis-benchmarks

from rediscala.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.