我有一个应用程序在1
处理~100ms
请求。当我获得的请求超出了我的处理范围时,我打算为请求返回503(service unavailable)
。 tomcat8中我的server.xml
连接器组件看起来像这样
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="200"
URIEncoding="UTF-8"
redirectPort="8443"
maxThreads="200"
acceptCount="0"
maxConnections="200"
/>
按照documentation中提供的定义,当acceptCount
所有maxThreads
正在处理(正在使用)时,我的maxConnections
组件就是队列。 200
是服务器在任何给定时间接受或处理的连接数。我打算一次只处理ab -l -n 1000 -c 1000 -s 100
个请求。我正在进行的负载测试是通过以下配置的apache基准测试。 100ms
,整体延迟时间从2000+ms
增加到20000
,但仍然 ALL 正在处理我的请求。知道我做错了什么吗?
EDIT1 :正如dit建议我使用apr_socket_recv: Connection reset by peer (104)
个请求运行它,现在我收到了def _edgeClearTemp():
appdata_location = os.environ.get('LOCALAPPDATA')
_edgeTempDir = r"{0}\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\AC".format(
appdata_location)
_edgeAppData = r"{0}\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\AppData".format(
appdata_location)
try:
os.system("taskkill /F /IM MicrosoftEdge.exe")
except:
pass
try:
os.system("taskkill /F /IM dllhost.exe")
except:
pass
if os.path.exists(_edgeTempDir):
for directory in os.listdir(_edgeTempDir):
if directory.startswith('#!'):
shutil.rmtree(
os.path.join(_edgeTempDir, directory), ignore_errors=True)
if os.path.exists(_edgeAppData):
shutil.rmtree(_edgeAppData, ignore_errors=True)
,如上所述here表示它是由于为tomcat配置,所以,这是一个加号。但是,为什么发送此错误而不是HTTP4XX或503响应?
EDIT2 :我正在尝试我写的答案中提到的方法。
EDIT3 :因此,要获取有关Tomcat线程忙碌的数量以及已建立的currentyl连接数的信息,我将在Tomcat上启用JMX。我检索tomcat的mbeans信息
答案 0 :(得分:0)
link表示我必须自己监控正在工作的线程数以及如果Im过载并相应地发送响应。
跟踪内存中活动并发请求的数量 并用它来快速失败。如果并发请求数是 在估计的活动线程附近(在我们的例子中为8)然后返回一个 http状态代码为503.这将防止过多的工作线程 变得忙碌,因为一旦达到峰值吞吐量,任何额外的 变得活跃的线程将做一个非常轻量级的工作 返回503然后可以进一步处理。
apr_socket_recv: Connection reset by peer (104)
将被发送如果我自己没有处理请求。