I hate when people tell me that Rails doesn't scale because I have scaled Rails and it has nothing to do with the framework. The reason why websites can't scale is ALWAYS the DB. To fix the DB it is always master/slave, memcached, then sharding. For EVERY language. Good article, sums up a lot of the tools I used to scale my stuff. I'd like to add a little more. 1. Turn on slow-query logging in your DB and tail -f the…
Actually, this is generally good advice regardless of what language you're on. The database is almost always at fault. My general rule is that a query should generally take less than 0.001 seconds to execute. If you can get it down to that through proper indexing and whatnot, MySQL will execute the queries fast enough so that they don't get backed up and eventually kill the server. Don't start caching until you can w…
Building and Scaling a Startup on Rails: Things We Learned the Hard Way (by Posterous S08)
41–50 of 56 posts
Re: Building and Scaling a Startup on Rails: Things We Learned the Hard Way (by Posterous S08)
#42One obvious way around this is to ensure the DB joins are done correctly. But the article mentions batching/grouping up the requests. How does that work?
Re: Building and Scaling a Startup on Rails: Things We Learned the Hard Way (by Posterous S08)
#43I don't know jack about Rails, but there is some good general advise here too. I would have liked to see some DB commentary that didn't choose MySQL as a foregone conclusion. I can't think of many instances where I would recommend it in general.
May I ask what you do use exactly? MySQL has always been my goto for simple db needs. What do you normally use and what's your "general" cases where you wouldn't use it?
Re: Building and Scaling a Startup on Rails: Things We Learned the Hard Way (by Posterous S08)
#44Great article. Background/deferred job processing has been immensely painful for us, and I have no idea what the accepted best job queue is. We're still stuck on backgroundrb, which is a nightmare. Nanite looks like overkill, and has too many deps.
Workling has worked well for us -- Rany Keddo is a phenomenal open source guy. Tobi's deferred jobs also looked totally solid to me. That one's proven because it drives Shopify. We use his liquid plugin, which is also stellar. That underlines a big issue with Rails dev even today -- its really hard to know what's good / what works, and what is just some weekend project for someone.
Re: Building and Scaling a Startup on Rails: Things We Learned the Hard Way (by Posterous S08)
#45Great article. Background/deferred job processing has been immensely painful for us, and I have no idea what the accepted best job queue is. We're still stuck on backgroundrb, which is a nightmare. Nanite looks like overkill, and has too many deps.
>> myobject.very_slow_method
with
>> myobject.async :very_slow_method
and it's executed in background
Re: Building and Scaling a Startup on Rails: Things We Learned the Hard Way (by Posterous S08)
#46Earlier quoted context omitted.
Workling has worked well for us -- Rany Keddo is a phenomenal open source guy. Tobi's deferred jobs also looked totally solid to me. That one's proven because it drives Shopify. We use his liquid plugin, which is also stellar. That underlines a big issue with Rails dev even today -- its really hard to know what's good / what works, and what is just some weekend project for someone.
Found Tobi's delayed_job (not deferred) --- I think I like the design better than Workling; fewer moving parts, just a database backend end a rake script. The biggest problem we have with backgroundrb (which again: nightmare) is not really ever knowing the state of current running jobs.
Re: Building and Scaling a Startup on Rails: Things We Learned the Hard Way (by Posterous S08)
#47I hate when people tell me that Rails doesn't scale because I have scaled Rails and it has nothing to do with the framework. The reason why websites can't scale is ALWAYS the DB. To fix the DB it is always master/slave, memcached, then sharding. For EVERY language. Good article, sums up a lot of the tools I used to scale my stuff. I'd like to add a little more. 1. Turn on slow-query logging in your DB and tail -f the…
- If you're a serious startup that doesn't monetize off of display ads, use Engine Yard. Otherwise, you can't afford them.
Re: Building and Scaling a Startup on Rails: Things We Learned the Hard Way (by Posterous S08)
#48Here's some of our learnings:
1. Use query_trace to trace your DB calls and query_analyzer to automatically run EXPLAIN on each call:
http://github.com/ntalbott/query_trace/tree/master http://github.com/jeberly/query-analyzer/tree/master
2. Use our patches to mongrel proc_title to troubleshoot slow queries: http://asemanfar.com/Request-Queue-via-Mongrel-Proctitle
3. Don't use ActiveRecord.
4. Don't use any link or url helpers in Rails.
5. For that matter, don't use Rails. Rewrite your most hit components in something faster.
I love Ruby, but the simple truth of it is that we'd be saving a couple of engineer's worth of money if we weren't on Rails.
Re: Building and Scaling a Startup on Rails: Things We Learned the Hard Way (by Posterous S08)
#49I hate when people tell me that Rails doesn't scale because I have scaled Rails and it has nothing to do with the framework. The reason why websites can't scale is ALWAYS the DB. To fix the DB it is always master/slave, memcached, then sharding. For EVERY language. Good article, sums up a lot of the tools I used to scale my stuff. I'd like to add a little more. 1. Turn on slow-query logging in your DB and tail -f the…
Rails running on vanilla Ruby does have particular scaling issues due to the limitations of the Ruby garbage collector. You hit a GC cycle after every 8MB of allocation, which typically takes around 150ms to run, so can dominate the runtime of your requests. We've had 80% of the runtime in GC, even when you include database time. This isn't necessarily a killer, but it means there's sometimes more work than you might…
And by scaling here, we're talking about 1 M to 10 M, not 10,000 to 100,000.
Re: Building and Scaling a Startup on Rails: Things We Learned the Hard Way (by Posterous S08)
#50Rails scales just fine - the problem is that it's just really expensive to do it. Here's some of our learnings: 1. Use query_trace to trace your DB calls and query_analyzer to automatically run EXPLAIN on each call: http://github.com/ntalbott/query_trace/tree/master http://github.com/jeberly/query-analyzer/tree/master 2. Use our patches to mongrel proc_title to troubleshoot slow queries: http://asemanfar.com/Request-…
You absolutely can iterate faster with fewer people and less wasted time.
Servers are cheap. People (salaries) are expensive.
(Well.. until servers become expensive due to straight up load/scale, that is.)