韦布里克的反应非常缓慢。 如何加快速度?
我的服务器上运行着一个 Rails 应用程序。 当我转到远程桌面并尝试加载应用程序时,服务器需要 3-4 分钟才能响应简单的 HTML 页面。 但是,当我在服务器本地加载页面时,该页面仅一秒钟就会显示出来。 我尝试从远程桌面 ping 服务器,并且 ping 在合理的时间内成功完成。
这一切似乎是在我安装了Oracle的基本客户端和SQLPLUS之后开始的。 我应该怀疑 Oracle 吗? 有没有人经历过类似的事情?
I have a Rails application that I'm running on my server. When I go to a remote desktop and attempt to load the application, the server takes a good 3-4 minutes to respond with a simple HTML page. However, when I load up the page locally on the server, the page shows up in just a second. I tried pinging the server from my remote desktop and the pings are going through successful in a reasonable amount of time.
This all seems to have started after I installed Oracle's basic client and SQLPLUS. Should I suspect Oracle? Has anyone experienced anything similar to this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
这里有同样的问题(甚至一年后)。 在 Linux 下,您必须执行以下操作:
查找文件 /usr/lib/ruby/1.9.1/webrick/config.rb 并编辑它。
Restart webrick替换该行
用
,它将像魅力一样工作:)
Having the same issue here (even a year later). Under linux you have to do the following:
Look for the file /usr/lib/ruby/1.9.1/webrick/config.rb and edit it.
Replace the line
with
Restart webrick and it'll work like a charm :)
有同样的问题。 对我来说,这篇文章提供了解决方案。 如果您使用的是 Ubuntu,请停止(或卸载)
avahi-daemon
。service avahi-daemon stop
停止守护进程。Webrick 现在感觉速度非常。
该问题有 Rails Lighthouse 中的旧报告,但是,Ruby-on-Rails 已将他们的票证移至从那时起,github; 不幸的是,这个老问题仍然存在。
但请注意,如果您实际上使用
avahi-daemon
进行某些操作,例如 在您的网络上查找打印机和扫描仪,这将不再起作用。Had the same problem. For me, this post held the solution. If you are on Ubuntu, stop (or uninstall) the
avahi-daemon
.service avahi-daemon stop
stops the daemon.Webrick now feels very speedy.
The problem has an old report in Rails Lighthouse, however, Ruby-on-Rails have moved their tickets to github since then; Kind of unfortunate that this old problem persists still.
Be aware though, that if you actually use
avahi-daemon
for something, like finding printers and scanners on your network, that won’t work anymore.刚刚遇到了同样的问题。 这
也为我做到了。
以防万一您在 rvm 下运行 ruby,以下是要执行的路径:
Just had the same problem. The
did the trick for me too.
Just in case you´re running ruby under the rvm, here is the path to go for:
“Thin”现在是在本地
和 Heroku上运行的绝佳选择:On Heroku:
https://devcenter.heroku.com/articles/rails3#webserver
网站:
http://code.macournoyer.com/thin/
您可以通过将您的Gemfile:
...然后运行bundle并使用
thin start
或rails s
启动服务器。Heroku 更新
Thin 现在被认为是 Heroku 的一个坏选择。 更多信息请参见:
https://blog.heroku.com/archives/2013/ 4/3/routing_and_web_performance_on_heroku_a_faq
他们的建议:
"Thin" is now a great option for running both locally
and on Heroku:On Heroku:
https://devcenter.heroku.com/articles/rails3#webserver
Website:
http://code.macournoyer.com/thin/
You can use it locally by putting in your Gemfile:
... and then run bundle and start your server with
thin start
orrails s
.Update on Heroku
Thin is now considered a bad choice for Heroku. More information here:
https://blog.heroku.com/archives/2013/4/3/routing_and_web_performance_on_heroku_a_faq
Their recommendation:
当我通过 VPN 访问 WEBrick 服务器时,我遇到了一个隐约相似的问题。 请求会花费很长时间,其中大部分时间都没有发生任何事情。
由于
mongrel
和thin
gems 都无法在 Windows 上使用 Ruby1.9,并且我无法让自己卷入从源代码编译的内容,因此我需要坚持使用 WEBrick。修复方法是在创建 WEBrick 服务器时将配置参数
DoNotReverseLookup
设置为true
:I had a vaguely similar problem that manifested itself when accessing a WEBrick server via a VPN. Requests would take a long time, most of it with nothing happening on the wire.
Since neither
mongrel
northin
gems worked with Ruby1.9 on Windows and there was no way I was getting myself embroiled in compiling stuff from source, I needed to stick with WEBrick.The fix was to set the config parameter
DoNotReverseLookup
totrue
, when creating the WEBrick server:您可以使用
Apache
或安装Thin
。 在您的 Gemfile 中:gem 'thin'
您还可以检查 的列表Rails 的网络服务器。
You can use
Apache
or installThin
. In your Gemfile :gem 'thin'
Also you can check the list of web-servers for rails.
尝试在 1.8.7 上使用 webrick 执行此操作,但找不到要更改的配置。 然而,您可以使用的一个作弊方法是将其尝试反向查找的 IP 地址添加到运行 webrick 的服务器的主机文件中。
Was trying to do this with webrick on 1.8.7 and couldn't find the config to change. However, a cheat you can use is to add to the hosts file of the server which is running webrick the ip address it is trying to reverse lookup..
我在使用 Sinatra 时经常遇到 10 秒的延迟。 这个片段为我解决了这个问题。
将其添加到
app.rb
文件顶部附近请参阅源代码
I experienced 10 seconds delays frequently with Sinatra. This snippet solved it for me.
Add this near the top of your
app.rb
fileSee source
这是一个旧的问答线程,帮助我解决了本地开发虚拟机上的
:DoNotReverseLookup
问题,并希望添加其他信息。 此网页解释了回归错误 Ruby 核心导致某些人出现此问题; 重点是我的; 总而言之,GitHub 上有一个 Ruby 核心修复请求,希望它能得到批准并合并到即将发布的 Ruby 中:与此发现相关的是来自作者的 GitHub Pull 请求 建议如何修复 Ruby WEBrick 源代码中的问题:修复 WEBrick 的 :DoNotReverseLookup 配置选项中的回归错误实现 #731
请求中概述的解决方案是将
lib/webrick/server.rb
中的第 181 行从以下位置更改为:如果
有人偶然发现这个备受关注的问题,请在此处共享/answer 线程,并对 Ruby 核心中解决此问题的进展感兴趣。 希望这个拉动能够在 Ruby 的下一个版本中被合并或者以某种方式处理潜在的问题; 也许是2.1.6?
This is an old question and answer thread that helped me solve the
:DoNotReverseLookup
issue on a local development virtual machine and wanted to add additional info. This web page explains the regression error in Ruby core that lead to this issue appearing for some; emphasis is mine; the long an short of all of this is there is a GitHub pull request for a Ruby core fix to this and hopefully it will be approved and merged in a soon-ish release of Ruby:Related to this discovery is a GitHub pull request from the author proposing how to repair the issue in the Ruby WEBrick source code: Fix regression bug in WEBrick's :DoNotReverseLookup config option implementation #731
The solution as outlined in the request is to change line 181 in
lib/webrick/server.rb
from this:To this:
Sharing here if anyone stumbles over this well regarded question/answer thread and are interested in the progress in solving this issue in Ruby core. Hopefully this pull will be merged or the underlying issue be dealt with in some way in the next release of Ruby; maybe 2.1.6?
这是一个很晚的答案,但我花了一天的大部分时间来调试在 Vagrant 上运行的 Rails 的这个问题。 更改反向 DNS 查找实际上根本没有改善请求时间。 两件事的结合使我的页面加载在开发模式下从约 20 秒减少到约 3 秒:
用 mongrel 替换 WEBrick。 我必须使用预发布版本,否则无法安装:
然后将其添加到我的 Gemfile for dev: 然后
像这样启动我的服务器:
这减少了几秒钟,5 或 6 秒,但它仍然非常慢。 这是锦上添花 - 将其添加到 Gemfile 中:
This is a very late answer but I spent a good part of the day debugging this very issue with Rails running on Vagrant. Changing the reverse DNS lookup didn't actually improve request times at all. A combination of two things took my page load from ~20 seconds to ~3 seconds in development mode:
Replace WEBrick with mongrel. I had to use the prerelease version or it wouldn't install:
Then add it to my Gemfile for dev:
Started my server like this then:
That cut a few seconds off, 5 or 6 seconds, but it was still terribly slow. This was the icing on the cake - add this as well to the Gemfile:
ruby 1.8.x webrick 中没有
DoNotReverseLookup
选项。 解决方案是将:放在脚本开头的某个位置。
来源:WEBrick 和 Socket.do_not_reverse_lookup:两个故事使徒行传
There is no
DoNotReverseLookup
option in ruby 1.8.x webrick. The solution is to put:somewhere at the beginning of your script.
Source: WEBrick and Socket.do_not_reverse_lookup: A Tale in Two Acts
在我可能罕见的情况下,它在我刷新我的 iptables 后起作用,这没有任何副作用,因为我没有任何自定义规则(只是默认的 Ubuntu 允许所有规则):
In my probably rare situation, it worked after I flushed my iptables, this didn't have any side effects because I didn't have any custom rules (just the default Ubuntu allow all):