TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Need help...Rails app seems to take 300ms+ for everything.

4 点作者 shail大约 12 年前
Ok, I will admit. Its not the simplest app but yet its not the most complicated one either.<p>The rather frustrating part is that most of the time is being spent in rendering views. Here are few examples.<p>- Completed 200 OK in 272ms (Views: 236.9ms | ActiveRecord: 15.7ms)<p>- Completed 200 OK in 275ms (Views: 148.2ms | ActiveRecord: 42.6ms)<p>- Completed 200 OK in 384ms (Views: 335.1ms | ActiveRecord: 3.5ms)<p>I am not doing partials in a loop etc. I am NOT querying while rendering either. Its just ruby hash operations etc which are taking up lot of ms. Now I am starting to wonder is how many SQL queries is considered normal, like in my app its around 4 - 10 queries. Is 300ms+ an acceptable response time for a Rails app which is not even launched yet (so no server load as of now). Hosted on $20 VPS Linode.<p>Thanks in advance for sharing your insights.

5 条评论

bjourne大约 12 年前
No one can tell you what the problem is with that little information. However, here are some suggestions on how <i></i>you<i></i> can yourself debug your problem:<p>Isolate: Eliminate as much as possible until nothing except the problem remains. You can't fix the problem until you know what the problem is, and guessing about it will just lead you astray.<p>Is performance still crap when you remove the db calls? When you replace the db connection with sqlite? When you remove the view logic and just render a static template? When you remove the templates altogether and just render a simple "Hello, world" string? When you put the application on a free Heroku instance instead of Linode?<p>Then ask yourself, does it make sense? Is Ruby so slow that a simple page takes 300 ms to load? Is a $20 (per month? per year?) Linode VPS that crappy?
chuhnk大约 12 年前
Have you tried running this anywhere else? How much processing time does a linode vps actually give you? It says activerecord is taking 15ms, that's the time spent querying the database. The view is taking the majority of the time which is normally going to be cpu time because it has to compile the template. Are you running it in cached mode? Because if not its going to read each template off disk before generating the view right?
bobfirestone大约 12 年前
Have you done any view caching? You should take a look at fragment caching and how Russian doll caching works with the cache_digest gem.
评论 #5695359 未加载
palidanx大约 12 年前
Have you installed newrelic.com and compared the performance difference between your dev and prod?
coolsunglasses大约 12 年前
Post code.<p>Ruby hash operations - your code or the framework?