Answer the question
In order to leave comments, you need to log in
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
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();
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 questionAsk a Question
731 491 924 answers to any question