SpringBoot + JPA + MariaDB许多连接?

时间:2018-11-21 01:44:14

标签: spring

我对SpringBoot项目有疑问。

基本REST Api可以处理100个请求。

@RestController
public class DustController {
private static final Logger logger = LoggerFactory.getLogger(DustController.class);

@Autowired
DustInfoDBRepository repositoryDustInfo;


private static int run_id = 0;
/*
 *  단지서버에서 미세먼지 요청 메세지
 *  /dustinfo
 *  
 */
@RequestMapping(
        value = "/dustinfo",
        method = RequestMethod.POST,
        consumes = "application/json")
public @ResponseBody Map<String, Object> reqDustInfo(@RequestHeader HttpHeaders headers,
                                                @RequestBody Req_dust obj,
                                                HttpServletResponse response) throws Exception {
    long DelayTime = System.currentTimeMillis();
    logger.debug("POST Method reqDustInfo Start Time :" + DelayTime);
    Thread.sleep(1000);     // 아무것도 없을때...초당 
//      List<DustInfoDB> list = repositoryDustInfo.findBySitecode(obj.getSite_code());
    logger.debug("POST Method reqDustInfo End Time :" + (System.currentTimeMillis() - DelayTime));
    return null;
}

结果符合预期。

enter image description here

使用jpa + mariaDB

修改上面的代码

        long DelayTime = System.currentTimeMillis();
    logger.debug("POST Method reqDustInfo Start Time :" + DelayTime);
    Thread.sleep(1000);     // 아무것도 없을때...초당 
    List<DustInfoDB> list = repositoryDustInfo.findBySitecode(obj.getSite_code());
    logger.debug("POST Method reqDustInfo End Time :" + (System.currentTimeMillis() - DelayTime));

与上述结果相同。

如果您再次更改代码,然后将“睡眠”移回

        long DelayTime = System.currentTimeMillis();
    logger.debug("POST Method reqDustInfo Start Time :" + DelayTime);
    List<DustInfoDB> list = repositoryDustInfo.findBySitecode(obj.getSite_code());
    Thread.sleep(1000);     // 아무것도 없을때...초당 
    logger.debug("POST Method reqDustInfo End Time :" + (System.currentTimeMillis() - DelayTime));

输出令人费解。

仔细查看处理时间

将只处理10个

enter image description here

如何正常处理它而没有延迟?

我需要添加代码或设置信息来对其进行修复吗?

我不明白。

我希望你能帮助我。

0 个答案:

没有答案