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 client performance issue #313

Open
glassfox opened this issue Oct 19, 2021 · 3 comments
Open

Redis client performance issue #313

glassfox opened this issue Oct 19, 2021 · 3 comments
Labels

Comments

@glassfox
Copy link

glassfox commented Oct 19, 2021

version 4.1.2
The performance of Redis client in Load is very pure. Lot of errors:

  1. java.io.IOException: Broken pipe
  2. io.netty.channel.StacklessClosedChannelException: null
  3. 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();
    }
}
@glassfox glassfox added the bug label Oct 19, 2021
@vietj
Copy link
Contributor

vietj commented Oct 19, 2021

@pmlopes ?

@pmlopes
Copy link
Member

pmlopes commented Oct 25, 2021

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.

@glassfox
Copy link
Author

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 ?

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

No branches or pull requests

3 participants