views:

995

answers:

5

I have a memory of talking to people who have got so far in using Ruby on Rails and then had to abandon it when they have hit limits, or found it was ultimately too rigid. I forget the details but it may have had to do with using more than one database.

So what I'd like is to know is what features/requirements fall outside of Ruby on Rails, or at least requires such contortions that it is better to use another more flexible framework, even though you may have to lose some elegance or write extra boilerplate code.

+5  A: 

Ruby on Rails does not support two-phase commits out of the box, which maybe required if your database-backed application needs to guarantee immediate consistency AND you need to use two or more database schemas.

For many web applications, I would venture that this is not a common use-case. One can perfectly well support eventual consistency with two or more databases. Or one could support immediate consistency with one database schema. The former case is a great problem to have if your app has to support a mondo amount of transactions (note the technical term :). The latter case is more typical, and Rails does just fine.

Frankly, I wouldn't worry about limits to using Ruby on Rails (or any framework) until you hit real scalability problems. Build a killer app first, and then worry about scalability.

CLARIFICATION: I'm thinking of things that Rails would have a hard-time supporting because it might require a fundamental shift in its architecture. I'll be generous and include some things that are part of the gem/plugin ecosystem such as foreign key enforcement or SOAP services.

By two-phase commits, I mean attempting to make two commits to physically distinct servers within one transactional context.

Use case #1 for a two-phase commit: you've clustered your database, so that you have 2 or more database servers and your schema is spread across both servers. You may want to commit to both servers, because you want to allow ActiveRecord think do a "foreign key map" that traverses across the different servers.

Use case #2 for a two-phase commit: you're attempting to implement a messaging solution (sorry, I'm J2EE developer by day). The message producer commits to the messaging broker (one server) and to the database (a different server).

Alan
While this is technically true, I believe you can use db middleware to achieve two-phase commits, or just use a db that supports it by itself and it will work fine. I'm not sure I'd call it a limitation, maybe just not a priority for the framework.
PJ
what exactly do you mean by 2 phase commits in this example?
Orion Edwards
+12  A: 

Rails (not ruby itself) is proud to be "Opinionated Software".

What this means in practice is that the authors of rails have a certain target audience in mind (themselves basically) and aim rails specifically at that. If X feature isn't needed for that target audience, it doesn't get added.

Off the top of my head, things that rails explicitly doesn't support that people may care about:

  1. Foreign keys in databases
  2. Connections to multiple DB's at once
  3. SOAP web services (since rails 2.0)
  4. Connections to multiple database servers at once

That said, it is very easy to extend rails with plugins, and there are plugins which add all of the above functionality to rails, and a lot more, so I wouldn't really count these as limits.

The only other caveat is that rails is built around the idea of creating CRUD web applications using MVC. If you're trying to do something which is NOT a CRUD web app (like twitter, which is actually a messaging system, or if you are insane and want to use a model like ASP.NET webforms) then you will also encounter problems. In this case you're better off not using rails, as you're essentially trying to build a boat out of bicycle parts.

In all likelihood, the problems you will run into that can't just be fixed with a quick plugin or a day or 2 of coding are all inherent problems with the underlying C Ruby runtime (memory leaks, green threads, crap performance, etc).

Orion Edwards
And given that we're right on the edge of having more than 1 Ruby runtime to choose from, even some of these issues are becoming moot.
Toby Hede
Rails supports connections to DBs/multiple DB servers right out of the box these days. (On a per model or per request basis, your call.) I'm using it right now -- got one postgres running on localhost, and one Oracle DB running on the company BigFreakingOracleBox, no issues whatsoever.
Patrick McKenzie
No support for (gasp) Foreign Keys? /me looks at calendar... what decade do these people think they are in?
Randal Schwartz
It supports foreign keys as long as they're id columns.
Alan Hensel
It supports foreign keys! Sure, it's opinionated against too much database logic and there's no built-in helper for adding key constraints in the migration file, but you can add them very easily: `execute "alter table people add constraint..."` and it works.
Andrew Vit
It doesn't *prevent* you from using foreign keys manually, but personally I wouldn't call that "support" for them...
Orion Edwards
A: 

Orion's answer is right on. There are few hard limits to AR/Rails: deploying to Windows, AR connectors that aren't frequently used, e.g. Firebird, ), but even the things he mentioned, multiple databases and DB servers, there are gems and plugins that address those for legacy, sharding, and other reasons.

The real limitation is how time-consuming it is to keep on top of all the things that rails devs are working on, and researching specific issues, given how many blogs, and how much mailing list volume there are.

Gene T
+1  A: 

Also found some good discussion about the limits of ActiveRecord.

Hamish Downer
+1  A: 

I think there is a greater “meta-question” here, that could be answered and that is “when is it OK to lean on external libraries to speed up development time?”

Third party libraries are often great and can drastically reduce development time, however there is a major problem, Joel Spolsky calls this “the law of leaky abstractions.” If you look that up on Google his post will come up first. Essentially this means that the trade off in development time means that you have no idea what is going on under the covers. So when something breaks you are completely stuck and have very limited methods of debugging. This also means that if you hit one of the features that are simply unsupported in RAILS, that you really need, you’ll have no next step except to write the feature yourself, if you’re lucky. Many libraries can make this difficult to do.

We’ve been burned badly in my dev shop by this issue. Our solutions worked fine under normal load, but we found that the third party subscription libraries that we were using simply could not stand up to the kind of load that we experienced once our site started to get a large number of concurrent users. This puts us in a very difficult place; essentially we have to rewrite the entire subscription service ourselves, with performance in mind. Doing this means that we’ve wasted all the time that we spent using the library.

Third party libraries can be great for small to medium sized applications; they can drastically reduce development time and hide complexities that aren’t necessary to deal with in the early stages of development. However eventually they will catch up with you and you’ll likely have to rewrite or re-engineer your solution to get past the “law of leaky absctractions”

Joe Basirico
...Except of course that your experience using that pre-existing library helped teach you what you actually need to write. So, it's not a total loss.Frankly, I write everything I touch with the _ultimate_ in performance in mind and chuckle at the fools who say hardware will always catch up...
Richard T