Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis connection pools + Node.js

Tags:

node.js

redis

Are Redis connection pools necessary with Node.js asynchronous I/O?

Most of the Redis libraries I see allow you to create client connections but there aren't many connection pool modules so I assume it's not as important.

The one thing that confuses me is that Redis has a default of 16 different/segmented databases in one Redis instance.

So if you create a connection pool, which database of the 16 are you connected to? Can you connect to all 16 at once with the same connection pool?

Is there a Node.js Redis library that creates a connection pool with 1 client per database, depending on how many databases you are using?

like image 405
Alexander Mills Avatar asked Sep 03 '15 19:09

Alexander Mills


People also ask

Does Redis have connection pool?

If we create a separate Redis connection for a thread it will be overhead for the Redis server. We need to have a pool of connections in multi-threaded environments to address these challenges. This allows us to talk to Redis from multiple threads while still getting the benefits of reused connections.

Can Redis handle multiple connections?

Redis can handle many connections, and by default, Redis has a maximum number of client connections set at 10,000 connections. You can set the maximum number of client connections you want the Redis server to accept by altering the maxclient from within the redis. conf file.

What is connection pooling in node JS?

The Node. js driver supports connection pooling. Connection pooling allows your application to reuse existing connections by automatically saving the connection to a pool so it can be reused, rather than repeatedly creating a new connection to the SAP HANA database server.

How many connections can Redis handle?

Large number of connections Individual ElastiCache for Redis nodes support up to 65,000 concurrent client connections.


1 Answers

You've asked too many questions in one post.

Trying to answer them;

Are Redis connection pools necessary with Node.js asynchronous I/O?

Duplicate of Node.js Redis Connection Pooling

So if you create a connection pool, which database of the 16 are you connected to?

By default you're always connected to database 0. Databases in redis are numbered if you're thinking why 0. They cannot be renamed to a string.

Can you connect to all 16 at once with the same connection pool?

Connection pools are not necessary

Is there a Node.js Redis library that creates a connection pool with 1 client per database, depending on how many databases you are using?

After searching i find two :

  • node-redis-pool
  • redis-connection-pool
like image 155
Basit Anwer Avatar answered Nov 01 '22 11:11

Basit Anwer