对 servlet 的请求在队列中等待
我正在使用 GWT RCP 在 GWT 中开发 Web 应用程序构建。应用程序是为即时消息传递而设计的,我使用 redis 消息传递。
当在 servlete 中等待消息并且我在 redise 中订阅该频道时,一切都按计划进行。但是,当服务器上等待的请求数量超过 5 个时,第 6 个请求不会开始处理,而是在队列中等待,直到处理完前面的请求之一。我不确定问题是否出在 Redis 中(我正在使用 jedis 库),因此我尝试直接在 currentThread 上调用 sleep,但其行为相同。
public class TestServiceImpl extends RemoteServiceServlet implements
TestService {
@Override
public void syncWait(Date time) {
try{
Thread.currentThread().sleep(10000l);
}catch (Exception e) {
getLogger().error("sleep error", e);
}
return ;
}
}
这不仅仅是关于一个特定的 servlet,当打开 5 个请求时,第 6 个请求甚至不加载静态内容。我在jety、glassfish和tomcat上尝试过。
我还尝试更改 glassfish 中线程池的设置,将 maxthread-count 设置为 200,但它不起作用。
您能否就如何增加每个会话和每个服务器处理的请求数量提出建议?
I am developing web app build in GWT using GWT RCP. Application is designed for instant messaging which I use redis messaging for.
When waiting in servlete on a message and I am subscribe on that channel in redise everything works as planned. Though when number of awaiting requests on server is more than 5, the 6th request doesn't start to be processed and waits in que until one of the previous requests is processed. I wasn't sure if the problem is in redis (I am using jedis library) therefore I tried to call directly sleep on currentThread but it behaved the same.
public class TestServiceImpl extends RemoteServiceServlet implements
TestService {
@Override
public void syncWait(Date time) {
try{
Thread.currentThread().sleep(10000l);
}catch (Exception e) {
getLogger().error("sleep error", e);
}
return ;
}
}
It's not just about one particular servlet, when 5 requests are opened, 6th doesn't even load static content. I tried it on jety, glassfish and tomcat.
I also tried to change settings of threadpool in glassfish, maxthread-count I set up on 200 but it didn't work.
Could you please advice on how to increase the number of requests processed pers session and per server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,您确实需要使用 servlet Comet 实现之一和 NIO 连接器。我对 Glassfish 或 Jetty 不太熟悉,但在 Tomcat 上,您可以使用 APR 的组合(请参阅 http://tomcat.apache.org/tomcat-6.0-doc/apr.html)和高级 IO(参见 http://tomcat.apache.org/tomcat-6.0-doc/aio.html) 来做你想做的事。
请注意,使用 Tomcat 的 Advanced IO 比标准 Servlet 2.5 api 更复杂(且文档较少)。
Resin、Tomcat 7 和 Glassfish(我相信)支持 Servlet 3.0 规范,该规范也提供对类似功能的支持:您可能想看一下。
For this you REALLY want to use one of the servlet Comet implementations and an NIO connector. I'm not intimately familiar with Glassfish or Jetty, but on Tomcat you can use a combination of APR (see http://tomcat.apache.org/tomcat-6.0-doc/apr.html) and advanced IO (see http://tomcat.apache.org/tomcat-6.0-doc/aio.html) to do what you want.
Please note that using Tomcat's Advanced IO is more complicated (and less well documented) than the standard Servlet 2.5 api.
Resin, Tomcat 7 and Glassfish (I believe) support the Servlet 3.0 spec which also offers support for similar features: you may want to take a look at that.