淺析Ruby on Rails部署方案(二)

Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 1827

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 1827

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 2180

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3025

Warning: implode() [function.implode]: Argument must be an array in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3077

Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3108

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3108

Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3151

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3151

Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3292

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3292

Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 1827

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 1827

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 2180

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3025

Warning: implode() [function.implode]: Argument must be an array in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3077

Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3108

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3108

Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3151

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3151

Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3292

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3292

Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 1827

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 1827

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 2180

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3025

Warning: implode() [function.implode]: Argument must be an array in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3077

Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3108

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3108

Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3151

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3151

Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3292

Warning: Invalid argument supplied for foreach() in /home/tewikico/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3292

後端的問題
在前面的測試報告中,我們似乎看不出什麼問題,好像即使處理速度不夠,多開幾個進程就可以了。這是因爲測試是在比較理想的環境下進行的,而實際的生產環境情況要複雜得多。雖然Mongrel在此次測試的結果中顯示了很好的穩定性,但是這並不能表示Mongrel就可以在生產環境中同樣保持很好的穩定性。
原因在於Ruby的線程機制。但首先這裏要強調的是,雖然Ruby的虛擬機有缺陷,線程是僞線程,線程性能較差,但這並不妨礙Ruby可以做一些同步或異步的工作(可以參考Erlang)。問題的關鍵在於Rails本身不是線程安全的,如果查看Mongrel的代碼則會發現,Mongrel在調用 Rails的分發器之前就加了鎖,直到Rails處理完這個請求。請參考/var/lib/gems/1.8/gems/mongrel-1.1.4 /lib/mongrel/rails.rb第74行(不同的系統上的目錄有所不同,不同版本的mongrel,代碼出現的位置也可能不同)如下:

<span style="background-color: rgb(255,255,0)">@guard.synchronize {</span><br > @active_request_path = request.params[Mongrel::Const::PATH_INFO] <br > Dispatcher.dispatch(cgi, <br >
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, [...]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章