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

ResetConsumers feature uses slow redis command #20

Open
mcweba opened this issue Jul 6, 2016 · 0 comments
Open

ResetConsumers feature uses slow redis command #20

mcweba opened this issue Jul 6, 2016 · 0 comments

Comments

@mcweba
Copy link
Collaborator

mcweba commented Jul 6, 2016

The feature to reset the consumers uses the KEYS command of redis. This command should not be used in productive environments because it may ruin performance when it's executed against large databases. See corresponding Documentation

See code below:

private void resetConsumers() {
    log.debug("RedisQues Resetting consumers");
    String keysPattern = redisPrefix + consumersPrefix + "*";
    if (log.isTraceEnabled()) {
        log.trace("RedisQues reset consumers keys: " + keysPattern);
    }
    redisClient.keys(keysPattern, keysResult -> {
        if(keysResult.failed()) {
            log.error("Unable to get redis keys of consumers");
            return;
        }
        List keys = keysResult.result().getList();
        if(keys == null || keys.size() < 1) {
            log.debug("No consumers found to reset");
            return;
        }
        redisClient.delMany(keys, delManyResult -> {
            if (delManyResult.succeeded()) {
                Long count = delManyResult.result();
                log.debug("Successfully reset " + count + " consumers");
            } else {
                log.error("Unable to delete redis keys of consumers");
            }
        });
    });
}

As an alternative to the KEYS command the SCAN command should be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant