djc / bb8

Full-featured async (tokio-based) postgres connection pool (like r2d2)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Time taken to get a connection from bb8 redis pool is very high

vamshiaruru-virgodesigns opened this issue · comments

Hi all,
I am load testing my webapp with thousands of requests per second, and under heavy load the time taken to get a connection from pool is pretty high. It is taking in order of ~300 ms (I got this number by adding a log with elapsed time, so it might not be totally accurate). If I jus use an Arc<Mutex<>> and pass that connection along instead of the pool, I am actually getting better performance (To get connection that way, it is taking ~90 ms which is still not ideal). My code is pretty straightforward

        let start = Instant::now();
        let mut redis_conn = ctx // This is from async_grahpql context
            .data::<Pool<RedisConnectionManager>>()
            .expect("Couldn't get redis pool")
            .get()
            .await?;
        info!(
            "[TIMER] Time taken to get connection from redis pool: {} millis",
            start.elapsed().as_millis()
        );

What can I do to fix this?

I don't know -- you'd have to investigate where the time is being spent.

I think the time being spent is due to redis not being fast enough, and has got nothing to do with bb8. I'll close this issue.