【发布时间】:2016-03-12 02:42:11
【问题描述】:
我们有一些并发问题,我想在我的机器上重现这些问题。在生产中,我们有一个乘客实例正在运行。为了获得并发请求,我尝试使用这样的瘦和线程选项启动 rails 应用程序(Rails 3.2):
bundle exec thin --threaded -p 3000 --threadpool-size 50 start -e production
我还运行了RAILS_ENV=production bundle exec rake assets:precompile 以获取生产中的所有内容。
但是,当我在浏览器中访问 localhost:3000 时,我得到了 HTML 的一部分(它显示),但随后浏览器遇到了 GET http://localhost:3000/ net::ERR_EMPTY_RESPONSE 的超时并且页面的加载停止。
当我使用 Ctrl-C 停止瘦身时,我多次收到以下消息:
Unexpected error while processing request: Attempt to unlock a mutex which is not locked
任何人都知道,为什么浏览器会超时,或者如何让并发请求在本地机器上运行瘦?尝试 puma 之类的其他服务器也没有问题,但是整个 apache/passenger 安装太多了。
更新
我在没有浏览器的情况下尝试了它,然后执行curl --verbose http://localhost:3000。第一次,我得到了 HTML:
* Rebuilt URL to: http://localhost:3000/
* Trying ::1...
* connect to ::1 port 3000 failed: Connection refused
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET / HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=utf-8
< Content-Length: 88748
< X-UA-Compatible: IE=Edge,chrome=1
< ETag: "d16fa9f8e279774f09c2172988a6d5a6"
< Cache-Control: max-age=0, private, must-revalidate
< Set-Cookie: _session_id=c23af3cc254b66789b635edfefd4a120; path=/; HttpOnly
< X-Request-Id: 539b87c3916cf6733fc9e91a05c4f8e9
< X-Runtime: 0.488556
< Date: Mon, 07 Dec 2015 13:33:26 GMT
< X-Rack-Cache: miss
< Connection: keep-alive
< Server: thin
<
<!DOCTYPE html>
... (more html)
但是我第二次运行 curl 命令时,它超时了:
* Rebuilt URL to: http://localhost:3000/
* Trying ::1...
* connect to ::1 port 3000 failed: Connection refused
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET / HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.43.0
> Accept: */*
>
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
很遗憾,thin 的输出或log/production.log 中没有写入任何错误。
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-3 concurrency thin