The server side performs several requests against cloud services

I am currently writing a web application that uses several web APIs. For one request from one user, my application may need to execute up to 30 HTTP requests to other sites. The site hosting the web application can have hundreds of concurrent users.

I look around trying to figure out which library should I use. I am looking for a mature project with detailed documentation and tested code, which will still be in the coming years. Not sure if something like this exists (!)

A couple of questions:

  • In the case described above, should I use an asynchronous HTTP client (without streaming) or a regular (possibly combined) HTTP client (with a stream) ? Asynchronicity saves my application from using threads, but makes the code more scattered - will the above number of requests load my server too much? (he says here that asynchronous is more scalable)

  • Which library is shared for use? Is it Apache HttpComponenets HttpClient or its asynchronous couterpart HttpAsynchClient - what is in Alpha ...)? What about jfarcand AsyncHttpClient ?


Well, let's say I will use streams. After digging, I understand that spawning threads from a servlet (in my case, the Struts action) can be a big No No:

related issues:

Recommended way to spawn streams from servlet in Tomcat

Need help developing java web applications for background tasks

Can I create a stream from a servlet?

The way I see it, these are my options:

- - ( ).

+2
4
. , , . .

, .

HttpClient . http, .

+1

HTTP- http-, , . , /. apache http .

, - netty . NIO, .

0

, , . . . , , .

, 30 , , . - , . . , . , .

, , Java, , , - 30 . -.

Nutshell: "" , parallelism.

0

Jetty, , , - . concurrency , , .

You can use either extensions or the asynchronous servlet 3.0 API, the end result is the same.

0
source

Source: https://habr.com/ru/post/1779887/


All Articles