spring boot 应用程序只接受 6 个请求,为什么? [英] spring boot app only accepts 6 requests why?

查看:37
本文介绍了spring boot 应用程序只接受 6 个请求,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这真的很烦我,希望有人能提供帮助.

This is really annoying me and hoping someone can help.

我有一个 Spring Boot 应用程序,我正在向邮递员发出请求,我需要同时发出大约 20 个单独的请求.但是,我的应用程序只接受 6,然后在这些完成后启动其他应用程序.

I have a spring boot application which I am firing requests to from postman and i need to fire about 20 separate requests at the same time. However my application only accepts 6 and then when these have finished starts the others.

我将示例麻木以便在此处发布

I numbed the example down so as to post it here

简单的控制器方法

@RequestMapping(value = "/testPost", method = RequestMethod.POST)
    public @ResponseBody String handleFileUpload() throws InterruptedException {
        System.out.println("Recieved request for Thread sleeping" + Thread.currentThread().getName());
        Thread.sleep(40000);
        System.out.println("Recieved request for Thread waking" + Thread.currentThread().getName());
        return "returning from post";
    }

application.properties:我将最大线程数改为 200 而不是默认值,但没有区别

application.properties: I changed the max thread count to 200 rather than default but made no difference

server.contextPath=/qas
server.port=8081

server.tomcat.max-threads=200

邮递员发出的请求的日志.如您所见,在 6 个请求之后,第 7 个请求仅在第一个请求空闲后才得到服务.我在没有负载平衡器的本地桌面上运行是这个原因吗?不太清楚为什么它会在 6 点停止?

Logs for requests fired from postman. As you can see after 6 requests the 7th request is only serviced after the 1st request becomes free. I am running on my local desktop with no load balancer is this the reason? Not really sure why it stops at 6?

日志:

2016-04-08 09:02:35.408  INFO 17700 --- [nio-8081-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/qas]    : Initializing Spring FrameworkServlet 'dispatcherServlet'
2016-04-08 09:02:35.408  INFO 17700 --- [nio-8081-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2016-04-08 09:02:35.421  INFO 17700 --- [nio-8081-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 13 ms
Recieved request for Thread sleepinghttp-nio-8081-exec-1
Recieved request for Thread sleepinghttp-nio-8081-exec-2
Recieved request for Thread sleepinghttp-nio-8081-exec-3
Recieved request for Thread sleepinghttp-nio-8081-exec-4
Recieved request for Thread sleepinghttp-nio-8081-exec-5
Recieved request for Thread sleepinghttp-nio-8081-exec-6
Recieved request for Thread wakinghttp-nio-8081-exec-1
Recieved request for Thread sleepinghttp-nio-8081-exec-7
Recieved request for Thread wakinghttp-nio-8081-exec-2
Recieved request for Thread sleepinghttp-nio-8081-exec-8
Recieved request for Thread wakinghttp-nio-8081-exec-3
Recieved request for Thread wakinghttp-nio-8081-exec-4
Recieved request for Thread wakinghttp-nio-8081-exec-5
Recieved request for Thread wakinghttp-nio-8081-exec-6
Recieved request for Thread wakinghttp-nio-8081-exec-7
Recieved request for Thread wakinghttp-nio-8081-exec-8

提前致谢

推荐答案

很多人不知道(或忘记)的是,大多数浏览器都有每个主机可以触发的最大并行请求数.多少取决于浏览器和浏览器版本.(显然你使用 Postman,它使用允许 6 个并发请求的 chrome).

What a lot of people don't know (or forget) is that most browsers have a maximum number of parallel requests that can be fired per hosts. How many depends on the browser and browser version. (Apparently you use Postman, which uses chrome which allows 6 concurrent requests).

参见 http://sgdev-blog.blogspot.nl/2014/01/maximum-concurrent-connection-to-same.html 以获得更详细的描述.

See http://sgdev-blog.blogspot.nl/2014/01/maximum-concurrent-connection-to-same.html for a more detailed description.

另请参阅https://stackoverflow.com/a/985704/2696260

这篇关于spring boot 应用程序只接受 6 个请求,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆