韦布里克的反应非常缓慢。 如何加快速度?

发布于 2024-07-29 11:08:08 字数 237 浏览 9 评论 0原文

我的服务器上运行着一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

人生戏 2024-08-05 11:08:08

这里有同样的问题(甚至一年后)。 在 Linux 下,您必须执行以下操作:

查找文件 /usr/lib/ruby/1.9.1/webrick/config.rb 并编辑它。

Restart webrick替换该行

:DoNotReverseLookup => nil,

:DoNotReverseLookup => true,

,它将像魅力一样工作:)

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

:DoNotReverseLookup => nil,

with

:DoNotReverseLookup => true,

Restart webrick and it'll work like a charm :)

颜漓半夏 2024-08-05 11:08:08

有同样的问题。 对我来说,这篇文章提供了解决方案。 如果您使用的是 Ubuntu,请停止(或卸载)avahi-daemonservice 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.

安穩 2024-08-05 11:08:08

刚刚遇到了同样的问题。 这

...
:DoNotReverseLookup => true,
...

也为我做到了。
以防万一您在 rvm 下运行 ruby​​,以下是要执行的路径:

~/.rvm/rubies/ruby-<version>/lib/ruby/<version>/webrick/config.rb

Just had the same problem. The

...
:DoNotReverseLookup => true,
...

did the trick for me too.
Just in case you´re running ruby under the rvm, here is the path to go for:

~/.rvm/rubies/ruby-<version>/lib/ruby/<version>/webrick/config.rb
瞄了个咪的 2024-08-05 11:08:08

“Thin”现在是在本地和 Heroku 上运行的绝佳选择:


On Heroku:
https://devcenter.heroku.com/articles/rails3#webserver

网站:
http://code.macournoyer.com/thin/

您可以通过将您的Gemfile:

gem "thin"

...然后运行bundle并使用thin startrails s启动服务器。

Heroku 更新

Thin 现在被认为是 Heroku 的一个选择。 更多信息请参见:

https://blog.heroku.com/archives/2013/ 4/3/routing_and_web_performance_on_heroku_a_faq

他们的建议:

切换到并发 Web 后端,例如 JRuby 上的 Unicorn 或 Puma,这允许 dyno 管理自己的请求队列并避免阻塞长请求。

"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:

gem "thin"

... and then run bundle and start your server with thin start or rails 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:

Switch to a concurrent web backend like Unicorn or Puma on JRuby, which allows the dyno to manage its own request queue and avoid blocking on long requests.

小姐丶请自重 2024-08-05 11:08:08

当我通过 VPN 访问 WEBrick 服务器时,我遇到了一个隐约相似的问题。 请求会花费很长时间,其中大部分时间都没有发生任何事情。
由于 mongrelthin gems 都无法在 Windows 上使用 Ruby1.9,并且我无法让自己卷入从源代码编译的内容,因此我需要坚持使用 WEBrick。

修复方法是在创建 WEBrick 服务器时将配置参数 DoNotReverseLookup 设置为 true

server = HTTPServer.new {: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 nor thin 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 to true, when creating the WEBrick server:

server = HTTPServer.new {:DoNotReverseLookup => true, ...}
热血少△年 2024-08-05 11:08:08

您可以使用 Apache 或安装 Thin。 在您的 Gemfile 中: gem 'thin'

您还可以检查 的列表Rails 的网络服务器

You can use Apache or install Thin. In your Gemfile : gem 'thin'

Also you can check the list of web-servers for rails.

热风软妹 2024-08-05 11:08:08

尝试在 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..

⊕婉儿 2024-08-05 11:08:08

我在使用 Sinatra 时经常遇到 10 秒的延迟。 这个片段为我解决了这个问题。

将其添加到 app.rb 文件顶部附近

class Rack::Handler::WEBrick
    class << self
        alias_method :run_original, :run
    end
    def self.run(app, options={})
        options[:DoNotReverseLookup] = true
        run_original(app, options)
    end
end

请参阅源代码

I experienced 10 seconds delays frequently with Sinatra. This snippet solved it for me.

Add this near the top of your app.rb file

class Rack::Handler::WEBrick
    class << self
        alias_method :run_original, :run
    end
    def self.run(app, options={})
        options[:DoNotReverseLookup] = true
        run_original(app, options)
    end
end

See source

坠似风落 2024-08-05 11:08:08

这是一个旧的问答线程,帮助我解决了本地开发虚拟机上的 :DoNotReverseLookup 问题,并希望添加其他信息。 此网页解释了回归错误 Ruby 核心导致某些人出现此问题; 重点是我的; 总而言之,GitHub 上有一个 Ruby 核心修复请求,希望它能得到批准并合并到即将发布的 Ruby 中:

经过几个小时的排查,事实证明是这样!
显然,Ruby 标准库从
从 1.8.6 到 2.0.0,WEBrick 获得了一个新的配置选项 :DoNotReverseLookup,默认设置为 nil。 然后,在内心深处
WEBrick 请求处理代码的核心,它设置
传入连接套接字实例上的 do_not_reverse_lookup 标志
config[:DoNotReverseLookup] 的值。 由于该值为nil
这是 false,效果与设置为 false 相同,
覆盖全局 Socket.do_not_reverse_lookup 标志。 所以,除非
你有:DoNotReverseLookup =>; true 在你的 WEBrick 配置中,相反
每个新连接都可能会进行 DNS 查找
导致严重的延迟。

与此发现相关的是来自作者的 GitHub Pull 请求 建议如何修复 Ruby WEBrick 源代码中的问题:修复 WEBrick 的 :DoNotReverseLookup 配置选项中的回归错误实现 #731

请求中概述的解决方案是将 lib/webrick/server.rb 中的第 181 行从以下位置更改为:

sock.do_not_reverse_lookup = config[:DoNotReverseLookup]

如果

unless config[:DoNotReverseLookup].nil?

有人偶然发现这个备受关注的问题,请在此处共享/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:

After a few hours of troubleshooting, it turned out that it was!
Apparently, somewhere along the evolution of Ruby's standard lib from
1.8.6 to 2.0.0, WEBrick acquired a new configuration option :DoNotReverseLookup that is set to nil by default. Then, deep in the
guts of WEBrick's request processing code, it sets the
do_not_reverse_lookup flag on the incoming connection socket instance
to the value of config[:DoNotReverseLookup]. Since this value is nil,
which is falsy, the effect is the same as setting it to false,
overriding the global Socket.do_not_reverse_lookup flag. So, unless
you have :DoNotReverseLookup => true in your WEBrick config, reverse
DNS lookup will always happen for each new connection, potentially
causing serious latency.

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:

sock.do_not_reverse_lookup = config[:DoNotReverseLookup]

To this:

unless config[:DoNotReverseLookup].nil?

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?

沒落の蓅哖 2024-08-05 11:08:08

这是一个很晚的答案,但我花了一天的大部分时间来调试在 Vagrant 上运行的 Rails 的这个问题。 更改反向 DNS 查找实际上根本没有改善请求时间。 两件事的结合使我的页面加载在开发模式下从约 20 秒减少到约 3 秒:

用 mongrel 替换 WEBrick。 我必须使用预发布版本,否则无法安装:

sudo gem install mongrel --pre

然后将其添加到我的 Gemfile for dev: 然后

group :test, :development do
  gem 'mongrel'
end

像这样启动我的服务器:

rails server mongrel -e development

这减少了几秒钟,5 或 6 秒,但它仍然非常慢。 这是锦上添花 - 将其添加到 Gemfile 中:

group :development do
  gem 'rails-dev-boost', :git => 'git://github.com/thedarkone/rails-dev-boost.git'
end

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:

sudo gem install mongrel --pre

Then add it to my Gemfile for dev:

group :test, :development do
  gem 'mongrel'
end

Started my server like this then:

rails server mongrel -e development

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:

group :development do
  gem 'rails-dev-boost', :git => 'git://github.com/thedarkone/rails-dev-boost.git'
end
原来分手还会想你 2024-08-05 11:08:08

ruby 1.8.x webrick 中没有 DoNotReverseLookup 选项。 解决方案是将:

Socket.do_not_reverse_lookup = true

放在脚本开头的某个位置。

来源:WEBrick 和 Socket.do_not_reverse_lookup:两个故事使徒行传

There is no DoNotReverseLookup option in ruby 1.8.x webrick. The solution is to put:

Socket.do_not_reverse_lookup = true

somewhere at the beginning of your script.

Source: WEBrick and Socket.do_not_reverse_lookup: A Tale in Two Acts

宣告ˉ结束 2024-08-05 11:08:08

在我可能罕见的情况下,它在我刷新我的 iptables 后起作用,这没有任何副作用,因为我没有任何自定义规则(只是默认的 Ubuntu 允许所有规则):

sudo iptables -F

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):

sudo iptables -F
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文