Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can one single Redis connection serve a thousand concurrent users?

Context: I am building an application that will be accessed concurrently by 1000 users and using Redis as the database. I am using node-redis client. I read that it's recommended to have only one or few connections open from each instance of the application because opening connections is expensive.

Question: Suppose the client sends a command to Redis. This command is in transit to Redis or being executed (essentially, not completed) when the application needs to send another command. Does the client wait for the first command to be completed or does it fire the second command to Redis right then?

This is important because if the client waits, the application is not really able to make full use of async and the network calls will become a big bottleneck when commands from a thousand users are trying to access Redis. It's better that the commands are queued up in Redis already instead of having them wait for an earlier command to complete before going through the network.

Thanks!

like image 977
aggarvit Avatar asked Sep 21 '25 00:09

aggarvit


1 Answers

It based on how the Redis client implemented.

On Redis server side, all commands are execute serializable. So single connection will not be a problem for Redis server.

On client side, if your framework uses blocking TCP connection(like Jedis), few connections will be a bottle neck as your commands will be blocked on client side to waiting for idle connections.

But if the client is using async / nio(like Lettuce), single connection will be ok since connections can be reused between threads.

Additionally, thousands of concurrent users will not be a problem for Redis but you should also focus on your web service if you are using single web server.

like image 181
Gawain Avatar answered Sep 22 '25 14:09

Gawain