0

有谁知道如何强制 WEBrick 一次处理多个请求?我在我的页面上使用了一些 Ajax 来处理与数据库相关的长时间运行的任务,并且我可以清楚地看到请求正在管道中进行处理。

4

4 回答 4

4

如果您使用 JRuby,请查看 GlassFish gem(以 gem 形式精简的 GlassFish 服务器)、Trinidad gem(使用 Tomcat 相同)或各种其他选项,如 warbler(生成可以直接运行或部署到任何应用服务器)。JRuby 是确保在 Ruby 上部署高并发应用程序的最简单方法,相比之下,C Ruby 选项看起来相当原始。

于 2010-06-16T21:25:42.123 回答
2

webrick 一次只处理一个请求,这通常适合开发。如果您希望并行运行,请查看 mongrel_cluster 或令人敬畏的独角兽乘客

于 2010-06-15T14:19:59.093 回答
0

您绝对不应该将 WEBrick 用于长时间运行的请求。最适合这项工作的 Web 服务器可能是 Thin,因为它由 EventMachine 提供支持,这使得编写异步代码成为可能,这样服务器就不会阻塞。

于 2010-06-15T21:42:44.170 回答
0

如果您正在运行 rails 4,您可以应用以下补丁,webrick 将同时开始服务请求。

diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb
index e3119ec..ef04aa8 100644
--- a/railties/lib/rails/commands/server.rb
+++ b/railties/lib/rails/commands/server.rb
@@ -93,14 +93,6 @@ module Rails
       middlewares << [Rails::Rack::Debugger]  if options[:debugger]
       middlewares << [::Rack::ContentLength]

-      # FIXME: add Rack::Lock in the case people are using webrick.
-      # This is to remain backwards compatible for those who are
-      # running webrick in production. We should consider removing this
-      # in development.
-      if server.name == 'Rack::Handler::WEBrick'
-        middlewares << [::Rack::Lock]
-      end
-
       Hash.new(middlewares)
     end
于 2013-05-28T19:57:13.537 回答