104 Comments
- rogersmj, on 12/08/2007, -0/+45Although I love Ruby on Rails and my company does almost all of our current projects in Rails, in general you are correct. It does require more horsepower to run Rails apps most of the time. The advantage is that Rails allows us to roll stuff out REALLY fast, but the tradeoff is that we may need some more power on the backend. That's a sacrifice most modern, agile development groups are wiling to make.
That said, there are ways to optimize Rails apps so that their overhead gets very comparable to a PHP app. We have a server guy whose job it is to do that, and when he's done with them they are lean and mean -- we have two Rails apps that get about 30 or 40 million hits a months between them running on a single dual-core server without problems. So you just have to know what you're doing and you can make Rails apps very efficient indeed. - wasabifan, on 12/08/2007, -1/+30Also, you are somewhat comparing apples to oranges here. Ruby on Rails is more of a framework for fast prototype builds. PHP itself is not a building framework, but a language. So if you want a straight language comparison, you should write and optimize at the language level. Ruby vs. PHP would make more sense for a head to head comparison of performance on similar hardware. Either way, the attraction of Ruby on Rails isn't its performance when it is deployed, it is it ability to quickly be developed and extended.
- cheald, on 12/08/2007, -0/+17Ruby is indeed slower than PHP in the general case. It's getting a pretty big fix-up in Ruby 1.9, though, which should be out quite soon. There are specific things in Rails that will kill your performance (like the built-in XML parser, rexml. It's a dog. Use hpricot instead.), but you can get a Rails app running pretty lean and mean if you need to.
The tradeoff is that it's a lot faster and easier to build and maintain a complex app in Rails than it is in straight-up PHP. Once you get to a certain level of complexity, you're going to pay a lot more in developer and QA time for a PHP app than you will for a Rails app.
Another point to consider is that PHP is a language, whereas Rails is a full web stack, so there's just going to be additional overhead compared to a simple scripting engine. - rogersmj, on 12/08/2007, -0/+14"Another point to consider is that PHP is a language, whereas Rails is a full web stack, so there's just going to be additional overhead compared to a simple scripting engine."
Exactly. The better thing to do here would be to compare Rails to a PHP framework, like Cake or something. I don't know much about those though. I love my RoR.
I do know that the most troublesome web app my company has by far is the site that was built in Drupal (PHP). That thing is constantly beating the crap out of servers. - bottiger, on 12/08/2007, -3/+16to all who is talking performance. Rails 2.0 has been enhanced with a lot of small performance tweaks, but nothing which will outperform a well written php-app. However, the question you need to ask yourself is: "Do I need performance?", or rather: "How much performance do I need?"
In a nutshell there are two kinds of websites out there: 1) small private website which runs on a shared host. 2) big professional sites with paid developers and dedicated servers.
In case one (that's me) you don't really need performance. My site ( http://bottiger.com ) is hosted on a cheap shared host but I still get better performance than I need. A typical hit is processed in 0.00230 seconds (434 reqs/sec), do you really think you would be able to feel any difference it was twice or ten times as fast?
In case two performance really means something, but today computational is very cheap. What do you think costs more: developers or servers? (a dedicated server is around $200/month).
I'm not saying rails is the second coming of Christ, and you should abandon PHP. I'm just trying to say that performance isn't everything. low performance just means you have to spend more money on servers, but slow development means more developers. - rogersmj, on 12/08/2007, -1/+14It would be better to compare Rails (a full Ruby framework) to Cake or some other PHP framework.
- teamvincent, on 12/08/2007, -0/+11Ruby 1.9 official release is due soon. Performance has been greatly improved.
- WallyAnti, on 12/08/2007, -3/+14I've had experiences here that would make me think more than a few people here aren't so much interested in spreading knowledge as they are in knee jerk, "look how smart I am" reactions. I guess for some folks thats all there is.
- deadmoo, on 12/08/2007, -4/+12A final release of Ruby 2.0 would have been more exciting.
- rmxz, on 12/08/2007, -0/+8Depends a lot how you write it.
Yes, RoR encourages slow/wasteful practices (ActiveRecord sucking in whole objects; rather than SQL sucking in the parts that are needed); and yes Ruby can be very slow if you use the wrong libraries (say, doing matrix math using Ruby arrays rather than narray).
But the niceness of ActiveRecord for prototyping (and for production in all the non-performance critical places) more than makes up for the overhead.
In conclusion.
1) Write it in RoR - yeah, it'll start slower than PHP
2) Find the performance hotspots and re-code them using SQL or Ruby extensions like nArray
3) Now it'll be as fast or faster than PHP, and you'll still be ahead of schedule. - manitoba98xp, on 12/08/2007, -0/+7While those PHP frameworks are good, there are a few things I'd like to point out. First, Rails predates those, (many of them are based pretty closely on Rails' design), and has a larger community (not larger than PHP, but larger than any of those frameworks). Second, and this is a matter of personal preference, I've done PHP for years before I touched Rails, and I have tried Cake, but Rails is (in my opinion) cleaner and more full-featured, largely owing to Ruby's dynamic, flexible, object-oriented nature. PHP's OOP support, in particular, is cumbersome.
- Error601, on 12/08/2007, -2/+9Developer time is far more valuable than hardware. If you want to compare systems to pick one for a project, it should be on how well it encourages code re-use and modularity. PHP is really obsolete in that respect. This stuff is better but loses to Java in code portability.
- objc, on 12/08/2007, -2/+8Very nice, even for a Friday release.
- 1longtime, on 12/08/2007, -0/+6In general, hardware is now cheaper than developing time. RoR load balances well, so it's easy to throw more hardware at it.
- christor, on 12/08/2007, -0/+6Yes, when you gem update, it keeps 1.2.6. In your project's config/environment.rb, use your choice of these two lines:
RAILS_GEM_VERSION = '2.0.1' unless defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION = '1.2.6' unless defined? RAILS_GEM_VERSION - cheald, on 12/08/2007, -0/+5Heh. Goes to show that it's possible to write crappy code in any language. :)
Rails makes it easy to shoot yourself in the foot (ie, not understanding joins and eager loading will get you into a load of hurt with your DB), but it also makes it really easy to patch up once you do understand it. - riah, on 12/08/2007, -0/+5By that logic, what do Wordpress blogs on Digg say about PHP?
- thesledman, on 12/08/2007, -0/+5Cake: http://www.cakephp.org/
- llbbl, on 12/08/2007, -4/+9PHP frameworks are just as good as Rails at rapid prototyping. The best of the bunch, IMO is CodeIgniter.
CakePHP
http://cakephp.org/
Zend Framework
http://framework.zend.com/
Symfony
http://www.symfony-project.org/
CodeIgniter
http://codeigniter.com/
Comparison of web application frameworks
http://en.wikipedia.org/wiki/Comparison_of_web_app ... - multitude, on 12/08/2007, -0/+5Rails will be a bit slower than some PHP applications. However, I think that things like OOP being built into ruby from the start, rather than the fact that it is hacked on to PHP, is a big selling point for RoR. I always felt like I was trying to make PHP do things that it didn't want to do when I built an elegant application architecture. So, in this case perhaps you're trading the ability to encapsulate parts of your code in a well-designed way for execution speed. This is well-worth the trade for me. I'd never look back at PHP now. Buy another server and optimize your rails code.
- multitude, on 12/08/2007, -1/+6Use the "spawner" script -- it makes sure that your mongrel processes are running, problem solved. Other than that use something like Nagios to make sure that your application is running, but this goes for any app that runs through Apache, including PHP programs.
RoR has more overhead, but in my opinion it's worth it to work in a language that has a more OOP feel to it. PHP has OOP hacked on to it after it was created, and it suffers from this design. - smoothoperatah, on 12/08/2007, -0/+5yeah i've read the same thing's and im an RoR guy and not a PHP guy. You just have to know how best to set up your queries and database handling. And it's usally NOT the way they tell you to do it in the tutorials and books. you gotta dig around, but there's lots of optimzation practices that remove most of the so-called hardware overhead from RoR.
- inactive, on 12/08/2007, -1/+6Dugg for multiple colons.
- DaveOrZach, on 12/08/2007, -2/+6For those of you running Leopard, run the following in Terminal to update to rails 2.0
sudo gem update --system
sudo gem update - s0lidmetal, on 12/08/2007, -1/+5Agree, CodeIgnitor is my favorite.
- superkickstart, on 12/08/2007, -1/+5Is it easy to learn RoR? i have been using php about five years now and for framework i have used symfony http://www.symfony-project.org/ which i think is quite similiar with RoR
- kingofpenguins, on 12/08/2007, -0/+4Everyone who uses ruby.
- bottiger, on 12/08/2007, -0/+4I you already have been working with web frameworks like symfony it shouldn't be a problem. The biggest difficulty in the beginning is to learn "what is ruby and what is rails -- and which IRC-channel should I ask for problems in"
- fweeky, on 12/08/2007, -0/+4Rails isn't one of the more effecient Ruby frameworks; if you're wanting to compare with straight-up PHP, you're probably better off looking at something like Rack , or if you want to use a bigger readymade framework and care about performance maybe consider something like Merb or maybe Nitro .
You might also write your own. Everyone should do it at least once :) - silicondon, on 12/08/2007, -0/+4STFU noob
- kingkilr, on 12/08/2007, -0/+4Cool to see a new release, I use python and django(which is similar to Rails, it has a few things I like better), I would recommend it to anyone.
- sintaxi, on 12/08/2007, -0/+3its not the same. php is faster. But the rumors are the ruby 1.9 is going to kick the crap out of php. It may even be faster than python.
- riah, on 12/08/2007, -0/+3I started out with PHP, later did a RoR app, worked with some folks on a PHP framework app, later some other folks on a Java framework app. The Java framework experience was probably the worst. Rails experience was the best for me even though I was unexperienced with Ruby. The way the piecess of the app fit together and the whole creation process, not to forget the Ruby language, was so elegant. It sounds cliche now, but don't take my word for it. Learning new languages is beneficial to your overall coding abilities anyway, you'll rethink the way you used to do things. I'm still the most comfortable with PHP, though.
- OneZeroZeroOne, on 12/08/2007, -0/+3Have to agree with you here.
PHP and Ruby are both interpreted scripting languages. Under the hood, the interpreter is C in both.
There's aren't any features in Ruby that make it inherently slow. C++ and Java used to get knocked because they were slow. Once they reached a certain level of popularity, most of the performance bottlenecks were optimized. As long as Ruby continues to gain popularity, the community will continue to make it more efficient. In the meantime, you're absolutely correct about developer vs server costs. - mcrumley, on 12/10/2007, -0/+3PHP was faster in almost every case in the shootout you linked to. Memory was more evenly split with Ruby being generally more efficient. Ruby 1.9 could change that, but right now PHP has the speed advantage. But if efficiency is a problem why use an interpreted language? C# and Java are many times faster than PHP or Ruby.
- HigherLogic, on 12/08/2007, -0/+3Cake is absolutely horrible. Give CI a shot and it will change your mind about PHP frameworks. I'm with the above two on CI, by far the best framework out there.
- cheald, on 12/08/2007, -0/+3RMagick doesn't work for you?
- curtistheory, on 12/08/2007, -1/+4I've been looking forward to this for awhile!
- Anteros, on 12/08/2007, -0/+3Ever heard of a little site called facebook?
- mikef98765, on 12/08/2007, -3/+6Rails might be slower than GOOD php, but most of the php developers i know aren't "good". If you can write efficient code then PHP is probably faster, but if you aren't too good at that use rails and use their optimizations. And if your site becomes big enough for performance to matter, hire someone to optimize it.
- molecule, on 12/08/2007, -1/+4Rails 2.0 is supposed to perform much better than previous Rails releases, so current performance comparisons between Rails and PHP are deprecated.
- esquilax, on 12/08/2007, -2/+4chrisfel is talking about exploiting the news cycle for better promotion of your stuff. Product launches actually typically are on Tuesdays, while bad news from the Bush administration is usually announced at 5:30PM on a Friday when most people who would be covering it have gone home for the weekend.
- oneblackcitizen, on 12/08/2007, -0/+2I would like to see a comparison of plain PHP to plain Ruby... My guess is it would be about the same, but who knows?
- seanmc303, on 12/09/2007, -2/+4Either many PHP diggers have serious ROR envy or they just don't know how to give some props to another competitor in the open source web development world. I'll digg PHP 6 or what ever PHP framework that has a major release whenever it comes out. Like it or not, Rails has and continues to set the bar for MVC frameworks out there.
- vade79, on 12/09/2007, -3/+5"prettier", "it's elegant". Such subjective ***** I always hear about Ruby...personally I think it looks like ass. Can you quantify what is pretty about it? here's one that isn't pretty; changing arbitrary naming conventions used in most other languages for no reason is an instant turn-off to me.
Personally, I'm not big a python fan, but I would label it the "pretty" one...see? subjective and means nothing. - multitude, on 12/08/2007, -0/+2If you can program in other languages, Ruby + Rails shouldn't be bad. I started to feel comfortable with the platform after about a month, and I came from developing Perl CGI.
- blazes816, on 12/08/2007, -0/+2It's not Rails 2.0 because DHH is trying to be hip, it's a version number. Calm down.
- Bamborzled, on 12/08/2007, -0/+2Which version of Drupal is it?
- rodrigo74, on 12/08/2007, -0/+2If Ruby is your weak link, I _strongly_ recommend you "Ruby for Rails", a book that will give you a lot of Ruby skills. Check it out at Amazon.
-
Show 51 - 100 of 103 discussions




What is Digg?
Browsing Digg on your phone just got easier with our enhancements to the