M
M
MOWS2015-10-19 16:04:05
Java
MOWS, 2015-10-19 16:04:05

How does the controller work with a large number of requests?

Let's say I have a method in the controller, inside which there is complex logic and the execution speed is about 1 minute. I'm wondering what will happen if such a long time request is called by 100 users at the same time? they will all queue up and be executed sequentially or there will be multiple threads. And if sequentially, then how can this be done in several threads so that it is faster.

@RequestMapping(path = "/something", method = RequestMethod.GET)
@ResponseBody
public String calcSumm() {
    String summ = service.getCalcSumm(); //request too long
    return summ;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evhen, 2015-10-19
@MOWS

each request will run on a separate thread. In tomcat, for example, by default, there are a maximum of 200 threads, all other requests will take off on a timeout.
this method should be ready in multithreading
service.getCalcSumm();

M
MOWS, 2015-10-20
@MOWS

Eugene, I understand correctly that if I have logic before this method, then all threads will execute it and wait for service.getCalcSumm();

@RequestMapping(path = "/something", method = RequestMethod.GET)
@ResponseBody
public String calcSumm() {
    countRequest++; 
    String summ1 = service.getCalcSumm1(countRequest);
    String summ2 = service.getCalcSumm2(countRequest);//countRequest может поменяться????
    return summ1 + summ2;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question