Scalable Web Service Development Template

I am writing a web service in Java that needs to process a large number of requests / second. The total flow will be:

  • Web service receives a request from a client
  • Returns the answer "keep polling me" to the client
  • Calling another web service (or services), and waiting for them to answer (with a timeout)
  • A client checks our web service while it receives a response (with a timeout)

Researching on the Internet, I found two common approaches to writing web services:

  • Create a stream for each request
  • Use a Reactor pattern (central dispatcher thread responds to I / O events)

Do you have a recommendation, which approach is usually better, and what are the advantages / disadvantages of each approach? I would also like to draw attention to examples.

+3
source share
3 answers

Do not think about multithreading. Think asynchronously. I accidentally encoded an async handler that ran 2000 RPS with <10 threads in IIS. I don’t know how java works since I am a .net guy, but I believe that they have similar BeginXXX / EndXXX methods. If you have ever created a stream, then you do not consider all the places that your code may block: IO database, file I / O, web services, etc. These are places that your performance will slow down your site.

Async, Async, Async.

Repeat and repeat.

+2
source

" ", , "Think Asynchronously", / -, , , .., .

EDIT: , , , / ...

0

- , , -, -, JAX-WS 2.0 ( Future / Executor java.util.concurrent). . - JAX-WS 2.0.

0
source

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


All Articles