Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Since Ruby isn't a scalable back end solution

It has been my understanding that Ruby can't scale and it seems that this site is built using the Rails framework. Since this site appears to be growing at a considerable rate is there going to be a massive overhaul to the site by switching to a Java based framework on the back end such as Spring or Java EE 7?

9 Answers

see this excerpt from the rails tutorial by Michael Hartl on rails scalability.

"Before moving on with the rest of the introduction, I’d like to take a moment to address the one issue that dogged the Rails framework the most in its early days: the supposed inability of Rails to “scale”—i.e., to handle large amounts of traffic. Part of this issue relied on a misconception; you scale a site, not a framework, and Rails, as awesome as it is, is only a framework. So the real question should have been, “Can a site built with Rails scale?” In any case, the question has now been definitively answered in the affirmative: some of the most heavily trafficked sites in the world use Rails. Actually doing the scaling is beyond the scope of just Rails, but rest assured that if your application ever needs to handle the load of Hulu or the Yellow Pages, Rails won’t stop you from taking over the world."

This is a pretty good article covering the misconceptions surrounded by attributing lack of scalability to language or framework. Above explanation is also good, but if you're interested in a more in-depth discussion on popular sites and scalability, it's a good read too!

Just to add to Stones answer with some info on how you could scale Ruby, Ruby could be scaled using multiple instances of Ruby mirroring the same files connecting to say multiple databases e.g. a mysql cluster. In theory to break it down any language can be scaled as when you look at a Network there are 7 Layers. Ruby would rest on Layer 7 so you could either scale by a software based load balancer on Layer 7 e.g. an instance that takes visitors and redirects them based on the load of other instances or via a hardware based load balancer which could direct traffic based on bandwidth, number of IP's connection and any other number of network variables. Typically you would locate a hardware load balancer on Layer 3(The routing layer) of a network to best route traffic but it can be done in any number of ways in theory on any network layer. Its simply down to personal preference and experience.

Hope this helps

I'll just throw in my quick word on this as well. The company I work for built our entire platform on Rails and we handle hundreds of thousands of transactions on a daily basis. There has been some complaint of Rails being a "slow" framework, but all in all with the right optimization and some experience with Rails it is a great tool.

This is a super interesting topic to me, as I'm primarily focused on scaling and automating Treehouse. Most of the issues we've seen that people would typically attribute to Ruby/Rails not scaling are problems that can be solved by optimizing database queries (and/or adding indexes) or adding additional caching. So far Ruby is doing the job for us.

Nathan Williams
seal-mask
.a{fill-rule:evenodd;}techdegree
Nathan Williams
Python Web Development Techdegree Student 6,851 Points

I'll second this. rails scales just fine, though it's more memory-hungry than some alternatives (happily ram is pretty cheap these days). I've personally worked on teams that scaled Rails apps to > 100K RPM, and the bottlenecks were never Rails itself, but rather the ecosystem around rails, the total application infrastructure comes into play.

Bypassing rails for requests that don't need to pass through the app (google "unicorn nginx try_files") and using the appropriate rack http server for your workload automatically takes care of 80% of scaling the application. after that you're just scaling horizontally behind a load balancer, and caching what you can (Dalli + Memcache is a nice mix here), which can go on well past the point where you're going to start running into the need to start scaling other system components like your database server or your queueing system.

using the appropriate rack http server for your workload automatically takes care of 80% of scaling the application. after that you're just scaling horizontally behind a load balancer, and caching what you can

I think this is an important take away from this thread.

Nathan Williams
seal-mask
.a{fill-rule:evenodd;}techdegree
Nathan Williams
Python Web Development Techdegree Student 6,851 Points

hey james,

before i get crucified by the world at-large: that is obviously pretty drastically oversimplified, and leaves a lot of things out (scaling caches, load distribution, &c).

there's also a lot you can do within the application itself to optimize performance, and keeping an eye on your database queries and indexes is huge (we like to say "don't trust rails to be your DBA"). but strictly talking about app runtime environment, that does cover most of it.

we like to say "don't trust rails to be your DBA"

Yeah, I like to say *don't send a dev to do a DBA's job", so I get where you are coming from.

I'm sorry for being a troll guys. Perhaps we should make a course?

and girls

Scaling an application up would need to be a very broad course as as some of the different methods you can use require advanced network stack knowledge.

Nathan Williams
seal-mask
.a{fill-rule:evenodd;}techdegree
Nathan Williams
Python Web Development Techdegree Student 6,851 Points

hey christopher,

i didn't think you were trolling. it's a common misconception in the industry, and it's worth discussing.

there are some things that make a big difference to performance, and they should be talked about to help spread awareness: for example: going from ruby 1.9.3 to ruby 2.1, we saw a big increase in throughput, with a slight increase in memory use. this change is attributable to improvements made to garbage collection in ruby core.

as for a course, i don't do content, but i'll forward the idea to some folks internally and see what they think about producing some content around operations.

cheers!

nathan w

Nathan Williams At an internship where they ran a Java Struts 1 web application in a WebLogic application server the software engineers spent 70% of their time trying to reduce memory usage because it was always about to run out. I remember one of the "optimizations" they came up with to shave what little free they could was to replace primitive boolean instance variables with the TRUE/FALSE constants from the Boolean class instead. Which doesn't really make much sense to me but I have a lack of knowledge in regards to the stack and heap.

Do Ruby web applications require more regression testing before putting a new build on production? I ask in regards to what I understand about Java being half or semi-compiled and being able to catch more errors at run-time as opposed to (assuming it is an interpreted language) Ruby web development?

Like do you as a Ruby web developer lean on a QA partner a lot while developing due to not being able to compile for error checking? and require more user based testing?

Nathan Williams What is the application container called that Rails uses? Do you have to restart your web applications container have to restart when applying a new build to production?

Nathan Williams Thanks in advance if you have time to answer as I am really just curious. If not I understand and thanks for the other info you already gave!

Nathan Williams
seal-mask
.a{fill-rule:evenodd;}techdegree
Nathan Williams
Python Web Development Techdegree Student 6,851 Points

as to what application container, it varies hugely.

some popular ones are:

  • passenger
  • unicorn
  • puma
  • thin

there's an article giving a pretty good overview of their advantages and capabilities here. there's lots more out there comparing and contrasting as well.

edit: and to make that response a little less of a cop-out. i prefer unicorn, which supports "hot restarts", and works pretty well for most applications i've worked with.

Nathan Williams
seal-mask
.a{fill-rule:evenodd;}techdegree
Nathan Williams
Python Web Development Techdegree Student 6,851 Points

hey christopher,

i can't really say whether rails requires 'more' or 'less'. while i've often deployed java apps to production (elasticsearch, logstash, solr...), i've not worked in a shop producing their own java applications.

i can say that the ruby/rails community seems fully aware of the importance of (unit/integration/regression) testing, and good test coverage is a point of pride for a lot of developers.

Nathan Williams Thanks. Yeah the only time I've ever had to use Ruby was when I found some really nice scripts already written for downloading the application log files over ftp while parsing based on time stamps. Appreciate the information and I'll look at that article you linked.