0
votes

I have a small vertx application. A http verticle gets a request and sends it over eventbus with request-response pattern. So something like:

vertx.eventBus().request(queue, request, options, reply -> {
            if (reply.succeeded()) {
                JsonObject body = (JsonObject) reply.result().body();
                context.response().end(body.encode());  
            } else {
                JsonObject result = new JsonObject().put("errorMessage", reply.cause().getMessage());
                    context.response().end(result.encode());
            }
        });

In the DB Vertical i use the consumer to get a message to go to DB, do some changes and send back to HTTP verticle. My problem is, i have a delete action that must do a lot of checks, so this process can take up to 10 seconds. In this moment HTTP verticle can still get some new requests, but DB consumer does not receive anything until the delete action is done. So no requests are processed. The only thing that helps is setmultithreaded to DB verticle and that is depricated. Vertx.executeBlocking or JAVA Thread pool around DB execution also does not help, as consumer just does not get anything until it replies. Do i miss something? Thank you

1
Is DB verticle deployed as worker? How many instances are created? - tsegismont
DB is as worker with 1 instance. I though that setmultithreaded can be implemented somehow different, as by start of the DB verticle some initialisation process takes place. So if i start 10 instances, then i need 10 times initialize the process - Andrey
If you create 10 separate instances, then you don't need a pool of connections to DB, or? - Andrey
you can also share a DB pool across your worker verticles - injecteer
provide your db verticle, also you can share datasource during verticle instance creation: DataSource ds = ... ;// init datasource vertx.deployVerticle(() -> new DbVerticle(ds), ...); - Didar Burmaganov

1 Answers

0
votes

I take from your question that the DB verticle is deployed with one instance. The DB verticle needs to be deployed as a worker. You can also deploy multiple instances of this verticle so that you always have one DB verticle that can take the next request.

Suggestion for optimization: If only the delete action is taking up so much time, separate this action in a special DB verticle. In this way your system is more responsive and you are able to control how many of the DB-"delecte-action"-Verticles are deployed and thus how many connections to the database are at may blocked for a longer time.