How to use node redis with AWS Lambda ? Max number of clients reached #2778
Closed
TheUncharted
started this conversation in
General
Replies: 1 comment
-
I answering to my own question but redis cloud free tiers has only 30 connections N Lambdas x M max connection in the pool > 30 max connections limit |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi
I m using Redis cloud with the free tier with an AWS lambda that run a ft.search
I initialized my client like this at the start of the lambda file as a global variable
const redis = require("redis");
const client = createClient({
url:
redis://${Config.REDIS_USER}:${Config.REDIS_PASSWORD}@${Config.REDIS_HOST}
,});
client.on("error", (err) => console.log("Redis Client Error", err));
await client.connect();
When I was testing my app I noticed that I got an error :
Redis Client Error [ErrorReply: ERR max number of clients reached]
I tried multiple things like this article
https://dev.to/afrazkhan/reuse-redis-connecitons-across-aws-lambda-invocations-4kk
then I tried to use the isolationPoolOptions
const client = createClient({ url:
redis://${Config.REDIS_USER}:${Config.REDIS_PASSWORD}@${Config.REDIS_HOST}, isolationPoolOptions: { min: 5, max: 50, idleTimeoutMillis: 120 * 1000, }, });
But when I try to load test this lambda with a performance test with postman with a ramp up scenario of 20 user: I reach the max connection in maybe one minute
Do you think I m using the right initialization code for redis ? or is it because of the free tiers limitation of 256 connection ?
In my mind, the client should reuse the connection with the isolation pool and since I m calling the lambda several time
the global variable client should be reused
Any idea on how to manage this ?
Beta Was this translation helpful? Give feedback.
All reactions