限制HTTP侦听器活动线程以控制并发m子流实例的数量 [英] Limiting HTTP Listener Active Threads to control number of concurrent mule flow instaces

查看:92
本文介绍了限制HTTP侦听器活动线程以控制并发m子流实例的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试测试如何限制并发传入HTTP请求的数量. 因此,我尝试模拟以下情况. 我创建了一个简单的流程 1. Http Listener作为Msg源 2.使用Groovy脚本,睡眠15秒以引入延迟 3.使用Hello world设置有效负载.

I am trying to do a test on how to limit the number of concurrent incoming HTTP requests. So I tried to simulate the following scenario. I have created a simple flow with 1. Http Listener as Msg source 2. Using Groovy Script, Sleeping for 15 seconds to introduce delay 3. Set the Payload with Hello world.

因此,任何单个请求都将具有至少15秒的响应时间.然后,为了限制活动线程的数量(即假设控制并发请求/处理线程),我将maxActiveThreads设置为1.因此,理想情况下,我将允许1个并发线程来处理流.

So any single request will have Min 15 sec of response time. Then in order to limit number of active threads (i.e assuming to control concurrent requests / processing threads) , I have set the maxActiveThreads to 1. So ideally I would allow 1 concurrent thread to process the flow.

现在,当我使用apache基准测试触发时,就像1个请求的简单获取一样,我收到的响应时间为15秒,这很好.现在,当我将并发请求数增加到2时,我仍然收到15秒的响应时间.我希望是30秒

Now when I fire using apache benchmarking, as simple get with 1 request, I receive with response time as 15 seconds, which is fine. Now when I increase the number of concurrent requests to 2, I still receive the response time as 15 seconds . I am expecting it be 30 seconds

我看到直到9个并发请求的行为.超过9,然后从第十个请求开始,将其放置在等待队列中.

I see the behaviour until 9 concurrent requests. Beyond 9, then from 10th request onwards it is placed in the waiting queue.

那么专家可以解释一下如何将活动线程的数量限制为1.如何将并发请求的数量设置为9(我在使用JConsole的线程中看到有9个SelectorRunner线程,我假设有链接到它).

So can an expert please explain how Can I limit the number of active threads to 1. And how is the number of concurrent requests set to 9 (I see in threads using JConsole there are 9 SelectorRunner threads, which I assume there are linked to it).

下面是简单的流程.

<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8082" doc:name="HTTP Listener Configuration">
<http:worker-threading-profile maxThreadsActive="1" />
</http:listener-config>
<flow name="getting-sartedFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP" />
<scripting:component doc:name="Groovy">
    <scripting:script engine="Groovy">
        <![CDATA[Thread.currentThread().sleep((long)(15000));]]>
    </scripting:script>
</scripting:component>
<set-payload value="Hello World" doc:name="Set Payload" />
</flow>

推荐答案

论坛,您需要为worker-threading-profile定义poolExhaustedAction.如果您不这样做,那么将使用默认值RUN,它解释了您所看到的行为.据我了解,您应该使用WAIT.

As answered in the forum, you need to define a poolExhaustedAction for the worker-threading-profile. If you don't then the default one will be used which is RUN, which explains the behavior you're seeing. From what I understand you should use WAIT.

<http:worker-threading-profile maxThreadsActive="1" poolExhaustedAction="WAIT"/>

这篇关于限制HTTP侦听器活动线程以控制并发m子流实例的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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