【发布时间】:2016-12-10 17:23:37
【问题描述】:
我使用 Spring Boot 构建了一个 REST api,它基本上通过 POST 接受两个图像并对它们执行图像比较。 api 是同步调用的。我没有使用外部应用程序服务器来托管服务,而是将其打包为 jar 并运行它。
@RequestMapping(method = RequestMethod.POST, value = "/arraytest")
public String compareTest(@RequestParam("query") MultipartFile queryFile,@RequestParam("test") MultipartFile testFile,RedirectAttributes redirectAttributes,Model model) throws IOException{
CoreDriver driver=new CoreDriver();
boolean imageResult=driver.initProcess(queryFile,testFile);
model.addAttribute("result",imageResult);
return "resultpage";
}
服务可以在多台机器上并行调用,我需要我的服务高效执行。我试图了解如何处理对 REST 服务的并行调用? 当请求发送到服务时,是否会创建服务的单个对象,并在多个线程中使用同一个对象来处理多个请求?
一个后续问题是是否有可能从处理请求的角度来提高服务的性能,而不是提高服务功能的性能。
【问题讨论】:
标签: java spring multithreading rest spring-boot