Ruby服务器在本地之外(Teambox)运行非常缓慢

5
我刚在我的Ubuntu 9.10服务器上安装了TeamBox。我使用提供的服务器脚本将其运行在3000端口。但是,当从另一台计算机连接时,每个HTTP请求需要长达30秒的时间,运行速度极慢。
我使用链接从shell中加载TeamBox,这只需要短暂的时间。我还设置了SSH隧道,它也非常快速。
我在这个服务器上通过apache运行大约30个虚拟主机,以及SAMBA等服务,没有任何问题。如何解决这个问题?

你解决了这个问题吗?我遇到了一个非常类似的问题:Ubuntu 10.04,rails 3.0.1,在本地工作时一切都很快。但是当使用网络上的任何其他服务器时,页面需要30秒以上才能加载。即使是全新/干净的rails应用程序也会出现这种情况,因此我强烈怀疑这是某个库/网络/配置问题。 - Yevgeniy Brikman
经过进一步调查,我可以从其他计算机和其他Web服务器(例如Grails)轻松地ping通该服务器。因此,这不太可能是系统或网络范围的问题,而只是Rails的问题。 - Yevgeniy Brikman
3个回答

10

我的 Redmine(基于Ruby和Webrick)非常缓慢。现在我解决了这个问题:

apt-get install mongrel
ruby /home/redmine/redmine/script/server mongrel -e production

执行以上命令后,Redmine的速度明显提升!

by


只想指出这个解决方案完美地运作。安装Mongrel,然后运行“rails server mongrel”,现在本地和其他机器的请求同样快速。不确定问题是什么,但我猜WEBrick在Ubuntu上有一些问题。 - Yevgeniy Brikman

2

您正在使用Passenger吗?几周前我也遇到了同样的问题,并通过将以下内容添加到我的vhost文件中解决了该问题。

 # Speeds up spawn time tremendously -- if your app is compatible.
    # RMagick seems to be incompatible with smart spawning
    RailsSpawnMethod smart

    # Just in case you're leaking memory, restart a listener
    # after processing 5000 requests
    PassengerMaxRequests 5000

    # only check for restart.txt et al up to once every 5 seconds,
    # instead of once per processed request
    PassengerStatThrottleRate 5

    # Keep the spawners alive, which speeds up spawning a new Application
    # listener after a period of inactivity at the expense of memory.
    RailsAppSpawnerIdleTime 0

    # Additionally keep a copy of the Rails framework in memory. If you're
    # using multiple apps on the same version of Rails, this will speed up
    # the creation of new RailsAppSpawners. This isn't necessary if you're
    # only running one or 2 applications, or if your applications use
    # different versions of Rails.
    RailsFrameworkSpawnerIdleTime 0

    # Keep the application instances alive longer. Default is 300 (seconds)
    PassengerPoolIdleTime 1000

不使用 Passenger。我没有通过 apache 运行 Teambox,而是使用它自带的 Python 服务器。我很困惑为什么在通过本地主机和通过局域网访问之间会有如此大的速度差异。 延迟发生在每个 HTTP 请求到服务器时。这似乎更像是网络问题。一旦 Python 服务器接收到请求,它会非常快地处理它。可能是什么原因导致这种情况? - ncatnow
@natcow:如果没有使用IP地址,则DNS查找是最常见的。 - Abe Petrillo

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接