反馈 ruby-china 的代码这么慢?

iceskysl · 2012年01月01日 · 最后由 Lucifer 回复于 2012年02月04日 · 4523 次阅读

Started GET "/topics" for 119.57.24.7 at 2011-12-31 21:40:24 -0500 Processing by TopicsController#index as HTML Rendered topics/_base.html.erb (3.1ms) Rendered topics/_sidebar_new_topic_box.html.erb (1.6ms) Rendered topics/_sidebar_for_gadget.html.erb (1.7ms) Rendered topics/_sidebar_for_topic_index.html.erb (11.8ms) Rendered topics/_node_info.html.erb (0.8ms) Rendered topics/index.html.erb within layouts/application (443.8ms) Rendered common/_search_form.html.erb (1.1ms) Rendered common/_user_nav.html.erb (16.2ms) Rendered common/_feeds.html.erb (1.6ms) Rendered common/_google_analytics.html.erb (0.7ms) Completed 200 OK in 1785ms (Views: 564.4ms | Mongo: 164.1ms | Solr: 0.0ms)

Started GET "/topics" for 119.57.24.7 at 2011-12-31 21:40:37 -0500 Processing by TopicsController#index as HTML Rendered topics/_base.html.erb (19.4ms) Rendered topics/_sidebar_new_topic_box.html.erb (2.0ms) Rendered topics/_sidebar_for_gadget.html.erb (2.5ms) Rendered topics/_sidebar_for_topic_index.html.erb (31.1ms) Rendered topics/_node_info.html.erb (0.1ms) Rendered topics/index.html.erb within layouts/application (773.4ms) Rendered common/_search_form.html.erb (0.2ms) Rendered common/_user_nav.html.erb (6.9ms) Rendered common/_feeds.html.erb (0.8ms) Rendered common/_google_analytics.html.erb (0.1ms) Completed 200 OK in 816ms (Views: 662.7ms | Mongo: 129.9ms | Solr: 0.0ms)

Started GET "/topics/1" for 119.57.24.7 at 2011-12-31 21:40:56 -0500 Processing by TopicsController#show as HTML Parameters: {"id"=>"1"} Rendered topics/_base.html.erb (2.3ms) Rendered app/cells/topics/sidebar_for_new_topic_node.html.erb (2.0ms) Rendered topics/_topic_info.html.erb (21.5ms) Rendered common/_share.html.erb (1.0ms) Rendered topics/_replies.html.erb (1.0ms) Rendered topics/_editor_toolbar.html.erb (1.2ms) Rendered app/cells/topics/reply_help_block.zh-CN.html.erb (0.4ms) Rendered topics/show.html.erb within layouts/application (599.2ms) Rendered common/_search_form.html.erb (0.1ms) Rendered common/_user_nav.html.erb (4.4ms) Rendered common/_feeds.html.erb (0.6ms) Rendered common/_google_analytics.html.erb (0.1ms) Completed 200 OK in 855ms (Views: 617.3ms | Mongo: 51.4ms | Solr: 0.0ms)

mongodb 好像不慢

db.setProfilingLevel(2); { "was" : 0, "slowms" : 100, "ok" : 1 } db.system.profile.find() db.system.profile.find() { "ts" : ISODate("2012-01-01T04:37:08.763Z"), "op" : "query", "ns" : "test.system.profile", "query" : { }, "responseLength" : 20, "millis" : 41, "client" : "127.0.0.1", "user" : "" } db.system.profile.find() { "ts" : ISODate("2012-01-01T04:37:08.763Z"), "op" : "query", "ns" : "test.system.profile", "query" : { }, "responseLength" : 20, "millis" : 41, "client" : "127.0.0.1", "user" : "" } { "ts" : ISODate("2012-01-01T04:37:16.577Z"), "op" : "query", "ns" : "test.system.profile", "query" : { }, "nscanned" : 1, "nreturned" : 1, "responseLength" : 156, "millis" : 74, "client" : "127.0.0.1", "user" : "" } db.system.profile.find() { "ts" : ISODate("2012-01-01T04:37:08.763Z"), "op" : "query", "ns" : "test.system.profile", "query" : { }, "responseLength" : 20, "millis" : 41, "client" : "127.0.0.1", "user" : "" } { "ts" : ISODate("2012-01-01T04:37:16.577Z"), "op" : "query", "ns" : "test.system.profile", "query" : { }, "nscanned" : 1, "nreturned" : 1, "responseLength" : 156, "millis" : 74, "client" : "127.0.0.1", "user" : "" } { "ts" : ISODate("2012-01-01T04:37:40.593Z"), "op" : "query", "ns" : "test.system.profile", "query" : { }, "nscanned" : 2, "nreturned" : 2, "responseLength" : 321, "millis" : 190, "client" : "127.0.0.1", "user" : "" }

索引建了吗?

#2 楼 @daqing mongodb 不慢,好像是 view 很慢~

#3 楼 @iceskysl 开发环境是这样,原因一直没查出来。

#4 楼 @huacnlee 在本上部了一套,速度还挺好~ 但部了一份道 linode 上以后,发现巨慢~ http://android-group.org/ 可以试试看~

我们把减肥加速作为下一阶段的主要目标吧:)

匿名 #7 2012年01月01日

#6 楼 @ashchan 新年伊始,男生也要注意减肥了。哈哈

#6 楼 @ashchan 查了下原因,有如下两个原因:

  1. 系统资源 linode 上 512m 内存记本没法跑,redis,mongodb ,memcached 一开,很快就 swap,然后 io 性能剧减,影响很明显;
  2. 项目用了很多性能一般的插件,可以考虑抛弃或者 fix 下~~

#8 楼 @iceskysl 加到 1g 内存后,速度明显好转 http://www.android-group.org/

我说,我这里访问速度并不慢。原来加过了

匿名 #11 2012年01月01日

#9 楼 @iceskysl 哈哈,以前华顺天天叫加到 4G 内存。Rails,Radis,MongoDB 都是吃内存的货。都在用空间换时间呢。

#4 楼 @huacnlee ruby-china 现在再盛大云上跑的是什么配置? 用了单独的云 monogdb?

#11 楼 @JohnsonWang 我去,1g 内存还是玩不起,开始还行,随便压力下就卡的不行~,不折腾了,下线~ 明个部署到我自己的服务器上算了~

#13 楼 @iceskysl mongodb 占的内存多少?

#14 楼 @Psi 有多少吃多少~ 我自己的服务器的 mongodb 单独 32g 内存~

#8 楼 @iceskysl 512M 上确实会这样。毕竟 MongoDB 和 Rails 本身都是耗内存的大户。如果是这种原因,app 本身调优效果不会太明显。

同意将一些明显性能或功能不佳的 gem 依赖去掉。

#14 楼 @Psi #15 楼 @iceskysl MongoDB 的内存和 swap 分配完全看系统的,确实是有多少吃多少。而且如果 index 设计不佳的话(index 可以完全放内存中时查询才会真正高效),内存使用会很有问题。

ruby-china 目前的数据量还很小,可能还感觉不出。

#7 楼 @JohnsonWang 嗯,是的。11 年减了 20 斤,这几天过年放假反弹了,今年要继续努力减:)

#12 楼 @iceskysl 盛大上面 1G 内存,跑了所有服务,64 位系统

我觉得你现在慢的原因可能是部署的问题

#20 楼 @huacnlee MongoDB 也在上面?

#22 楼 @iceskysl 是的,还有 Solr

#23 楼 @huacnlee #19 楼 @ashchan 找到慢得原因了~ 还是内存得问题,用 unicon 得时候启多了进程数导致得~ 减少到系统可分配得进程数内就各项指标正常了~

我公司还在用 256 内存跑~~

需要 登录 后方可回复, 如果你还没有账号请 注册新账号