vertx-redis-client
vertx-redis-client copied to clipboard
Redis client performance issue
version 4.1.2 The performance of Redis client in Load is very pure. Lot of errors:
- java.io.IOException: Broken pipe
- io.netty.channel.StacklessClosedChannelException: null
- java.net.SocketException: Connection reset
Following test:
@Test
void test1(Vertx vertx, VertxTestContext context) {
int iterations = 100;
int instances = 100;
AtomicInteger countOfErrors = new AtomicInteger();
vertx.deployVerticle(() -> new AbstractVerticle() {
@Override
public void start() throws Exception {
var redis = RedisAPI.api(Redis.createClient(this.vertx, new RedisOptions().setConnectionString("redis://127.0.0.1:6379")));
this.vertx.eventBus().consumer("test.redis.load").handler(m -> {
redis.set(List.of("foo","bar")).onComplete(res ->{
if(res.failed()) {
countOfErrors.incrementAndGet();
}
});
});
}
}, new DeploymentOptions().setInstances(instances))
.onComplete(res -> {
for (int i = 0; i < iterations; i++) {
vertx.eventBus().publish("test.redis.load", true);
}
});
try {
context.awaitCompletion(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
}
if(countOfErrors.get() > 0) {
context.failNow("count of errors:" + countOfErrors.get());
} else {
context.completeNow();
}
}
@pmlopes ?
I've been trying to reproduce this issue in master, I've been increasing the values until it crashes, but on my side it seems to happen at REDIS side:
@Test
// @Ignore
public void perfRegression(TestContext should) {
final Async test = should.async();
int iterations = 500;
int instances = 100;
AtomicInteger count = new AtomicInteger();
AtomicBoolean done = new AtomicBoolean();
rule.vertx()
.deployVerticle(() -> new AbstractVerticle() {
@Override
public void start(Promise<Void> onStart) {
Redis redisClient = Redis.createClient(rule.vertx(), new RedisOptions()
.setConnectionString("redis://" + redis.getContainerIpAddress() + ":" + redis.getFirstMappedPort() + "/0")
.setMaxWaitingHandlers(iterations + 10)
.setMaxPoolSize(100)
.setMaxPoolWaiting(500));
rule.vertx().eventBus()
.consumer("test.redis.load")
.handler(m -> {
redisClient
.send(cmd(SET).arg("foo").arg("bar"))
.onSuccess(res -> {
if (count.incrementAndGet() == iterations * instances) {
if (done.compareAndSet(false, true)) {
rule.vertx()
.setTimer(2000L, v -> test.complete());
}
}
})
.onFailure(err -> {
should.fail(err);
});
});
onStart.complete();
}
}, new DeploymentOptions().setInstances(instances).setWorker(true))
.onComplete(res -> {
for (int i = 0; i < iterations; i++) {
rule.vertx().eventBus().publish("test.redis.load", i);
}
});
}
The first failure happens with:
Oct 25, 2021 10:18:19 AM io.vertx.redis.client.impl.RedisStandaloneConnection
WARNING: No handler waiting for message: ERR max number of clients reached
CONNECTION_CLOSED
So we've reached the maximum allowed client connections from redis.
If I reduce to 100, 100 like in the OP and avoid thread pools by not making the verticles workers, the test passes on my side.
The test is failed in my side in versions 4.2.0-SNAPSHOT and 4.1.2 (mac and centos 7 x64) @pmlopes , in what version did you check ?