2010-03-13 38 views
5

我剛剛在我的Ubuntu 9.10服務器上安裝了TeamBox。我使用提供的服務器腳本啓動並在端口3000上運行。Ruby服務器在localhost外很慢(teambox)

當從另一臺計算機連接時,它運行速度非常慢,每個HTTP請求最多30秒。

我使用鏈接從shell中加載TeamBox,並且沒有花費任何時間。

然後我設置了一個SSH隧道,並且工作速度非常快。

我在這個服務器上運行了大約30個虛擬主機,通過apache,以及SAMBA等,並沒有任何問題。

如何解決此問題?

+0

你有沒有得到這個解決?我只是遇到了一個非常類似的問題:Ubuntu 10.04,rails 3.0.1,從本地主機快速工作時。在網絡上使用其他服務器時,頁面需要30多秒才能加載。這甚至發生在一個全新的乾淨的rails應用程序中,所以我強烈懷疑它是一些庫/網絡/配置問題。 – 2010-12-03 04:14:36

+0

經過進一步調查,我可以很好地從其他計算機和其他Web服務器(例如Grails)平穩地運行服務器。所以這不太可能是一個系統或網絡廣泛的問題,但只是一個軌道問題。 – 2010-12-03 04:25:14

回答

10

我的redmine(ruby,webrick)太慢了。 現在我解決了這個問題: apt-get install mongrel
ruby /home/redmine/redmine/script/server mongrel -e production
完成了,redmine的工作速度非常快! 通過

+0

只是想說明,這個解決方案完美的作品。安裝雜種,並運行「rails服務器雜種」,現在請求本地主機和其他機器同樣快速工作。不知道這個問題是什麼,但我想WEBrick在Ubuntu上有一些問題。 – 2011-01-18 19:38:34

2

您是否在使用乘客?幾周前我遇到了同樣的問題,並通過將其添加到我的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 
+0

不使用乘客。我沒有通過apache運行Teambox,而是使用它附帶的python服務器。我很困惑爲什麼在通過本地主機訪問它並通過局域網訪問它之間存在如此巨大的速度差異。 延遲發生在每個HTTP請求到服務器。這看起來更像是一個網絡問題。一旦python服務器收到請求,它會很快處理它。什麼會造成這種情況? – ncatnow 2010-03-13 09:56:43

+0

@natcow:DNS查找,如果不使用IP是最常見的 – 2011-08-03 08:31:50