浅析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,代码出现的位置也可能不同)如下:

@guard.synchronize {
@active_request_path = request.params[Mongrel::Const::PATH_INFO]
Dispatcher.dispatch(cgi,

ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, [...]

你可能感兴趣的:(Rails,Ruby,PHP,Blog,HTML)