Skip to content

Use vertx blockingHandlers to run Bookkeeper http handlers which could be blocking#4266

Merged
hezhangjian merged 1 commit into
apache:masterfrom
lhotari:lh-use-blocking-threadpool-for-vertx-handlers
Apr 8, 2024
Merged

Use vertx blockingHandlers to run Bookkeeper http handlers which could be blocking#4266
hezhangjian merged 1 commit into
apache:masterfrom
lhotari:lh-use-blocking-threadpool-for-vertx-handlers

Conversation

@lhotari

@lhotari lhotari commented Apr 3, 2024

Copy link
Copy Markdown
Member

Motivation

  • The http handler implementations in Bookkeeper aren't necessarily non-blocking. That's why they should be executed on the blocking thread pool in vertx.

Changes

Executing on blocking thread pool in vertx can be achieved by registering the handlers using the blockingHandler method instead of the handler method.

@hezhangjian
hezhangjian merged commit 15a3840 into apache:master Apr 8, 2024
hezhangjian pushed a commit that referenced this pull request May 24, 2024
### Motivation

- The http handler implementations in Bookkeeper aren't necessarily non-blocking. That's why they should be executed on the blocking thread pool in vertx.


### Changes

Executing on blocking thread pool in vertx can be achieved by registering the handlers using the `blockingHandler` method instead of the `handler` method.
hezhangjian pushed a commit that referenced this pull request May 25, 2024
### Motivation

- The http handler implementations in Bookkeeper aren't necessarily non-blocking. That's why they should be executed on the blocking thread pool in vertx.

### Changes

Executing on blocking thread pool in vertx can be achieved by registering the handlers using the `blockingHandler` method instead of the `handler` method.

(cherry picked from commit 15a3840)
Ghatage pushed a commit to sijie/bookkeeper that referenced this pull request Jul 12, 2024
…he#4266)

### Motivation

- The http handler implementations in Bookkeeper aren't necessarily non-blocking. That's why they should be executed on the blocking thread pool in vertx.


### Changes

Executing on blocking thread pool in vertx can be achieved by registering the handlers using the `blockingHandler` method instead of the `handler` method.
@dragonls

dragonls commented Aug 6, 2025

Copy link
Copy Markdown
Contributor

In our case, we are using /api/v1/ledger/list to get the ledgers in bookie, which may run more than 30 seconds due to lots of ledgers. At the same time, all the other http request will be blocked, such as /metrics or even /heartbeat. It seems that all http requests in bookie is processed by a single thread.

We found that if we update the code to:

        HttpRouter<VertxAbstractHandler> requestRouter = new HttpRouter<VertxAbstractHandler>(handlerFactory) {
            @Override
            public void bindHandler(String endpoint, VertxAbstractHandler handler) {
                router.get(endpoint).blockingHandler(handler, false);
                router.put(endpoint).blockingHandler(handler, false);
                router.post(endpoint).blockingHandler(handler, false);
                router.delete(endpoint).blockingHandler(handler, false);
            }
        };

then the http requests could be run concurrently by updating the second parameter ordered from true to false.

I am not sure why the bookie process all the http request by a single thread. Is it necessarily?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants