Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis Scaling Issue with Redisson Client #2711

Closed
Alok-Kumar-9 opened this issue Feb 24, 2024 · 2 comments
Closed

Redis Scaling Issue with Redisson Client #2711

Alok-Kumar-9 opened this issue Feb 24, 2024 · 2 comments
Labels

Comments

@Alok-Kumar-9
Copy link

Alok-Kumar-9 commented Feb 24, 2024

Hi @manast !
We are running a delayed queue in redis using redisson client. We are using a t3.small elastcache instance and our application has redisson version 3.23.5 with Spring boot 3.x and Java 17.
We are not setting any TTL for our records. Our records go to a blocking queue once its delay period is over. We are seeing high CPU spikes when there is increase in traffic to Redis. How can we mitigate this?
I tried using replicas and clustered mode but apparently they are not working here.

My redis config-

CommandsLoadBalancer loadBalancer = new CommandsLoadBalancer();
    loadBalancer.setAddress("redis://test-0001-002.qqqq.0001.aps1.cache.amazonaws.com:6379");
    loadBalancer.setCommands(
        List.of(RedisCommands.READONLY.getName(), RedisCommands.LPOP.getName(), RedisCommands.BLPOP_VALUE.getName()));
    redisConfig
        .useClusterServers()
        .setScanInterval(2000)
        .setConnectTimeout(5000)
        .setIdleConnectionTimeout(5000)
        .setTimeout(10000)
        .setFailedSlaveReconnectionInterval(1000)
        .setRetryAttempts(5)
        .setRetryInterval(2000)
        .setLoadBalancer(loadBalancer)
//        .setLoadBalancer(new WeightedRoundRobinBalancer())
        .setReadMode(ReadMode.SLAVE)
        .addNodeAddress("redis://test-0001-001.qqqq.0001.aps1.cache.amazonaws.com:6379")
        .addNodeAddress("redis://test-0001-002.qqqq.0001.aps1.cache.amazonaws.com:6379");

    redisConfig
        .setTransportMode(TransportMode.NIO)
        .setThreads(64)
        .setNettyThreads(128);
    return Redisson.create(redisConfig);

My redis code-

public TestRedisDelay(RedissonClient managedClient, String queuePrefix, ObjectMapper objectMapper) {
    this.destinationQueue = managedClient.getBlockingQueue(queuePrefix + "test");
    this.delayedQueue = managedClient.getDelayedQueue(this.destinationQueue);

    this.objectMapper = objectMapper;
  }

public void pushToDelayedQueue(TestRequest testRequest) {
      try {
        String jsonTestRequest = objectMapper.writeValueAsString(testRequest);
        this.delayedQueue.offer(jsonTestRequest, 5L, TimeUnit.MINUTES);
      } catch (Exception e) {
        log.error("ERR_CONVERTING_TO_JSON_NODE :: {} :: REQ- {}", e.getMessage(), testRequest);
      }
  }

public TestRequest fetchRequests() {
      TestRequest testRequest = null;
      try {
        String revampedQueueRequest = destinationQueue.poll();
        if(!Strings.isEmpty(revampedQueueRequest)) {
          testRequest = objectMapper.readValue(revampedQueueRequest, TestRequest.class);
        }
      } catch (Exception e) {
        log.error("ERR_FETCHING FROM QUEUE :: {}", e.getMessage());
      }

    return testRequest;
  }

Can someone suggest anything?

Originally posted by @Alok-Kumar-9 in #1941 (comment)

@manast
Copy link
Member

manast commented Feb 24, 2024

Hello,
I am a bit confused, how can you run Bull using Java?

Copy link

stale bot commented May 2, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label May 2, 2024
@stale stale bot closed this as completed May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants