jooby icon indicating copy to clipboard operation
jooby copied to clipboard

What HTTP client should I use to not block the worker while request is processing?

Open nonetallt opened this issue 5 months ago • 4 comments

Background:

I'm completely new to Jooby and the last time I used Java was years ago. I'm pretty unfamiliar with the async http client ecosystem and how the libraries interact with frameworks (event loops or whatnot). Coming from PHP and Swoole, I know that I need to use a http client that is somehow integrated to the framework to not cause workers to hang up while waiting for requests to resolve.

I can think of at least two use cases where I would need a http client:

  1. using any external http APIs
  2. acting as a proxy for the user

Question:

What would be the suggested / best practice approach for implementing these features in Jooby without taking a performance hit from using a synchronous http client? What library/module should I use? I've looked through the docs, done some searches online and looked at the github issues but I've found 0 references to http client or sending requests besides for testing.

nonetallt avatar Jan 18 '24 23:01 nonetallt

I'm currently using Netty as the server implementation, in case that's relevant.

nonetallt avatar Jan 18 '24 23:01 nonetallt

there are quite a few of them, the JDK has one built in if you want to go free of dependencies.

SentryMan avatar Jan 19 '24 00:01 SentryMan

there are quite a few of them, the JDK has one built in if you want to go free of dependencies.

So what you're saying is that they should be pretty much interchangeable and any async client would work with jooby? No additional configuration required?

I don't really understand how the clients interact with the event loop / execution model and I thought some specific setup would be required for optimal performance with the Jooby framework, hence my question and confusion.

nonetallt avatar Jan 19 '24 00:01 nonetallt

Any http client worth its salt will have async capabilities (though with virtual threads blocking is back on the menu for most applications)

SentryMan avatar Jan 19 '24 04:01 SentryMan