Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Is Ruby slow?

I love Ruby as a language. Its so clean and I love many of the features - code blocks are nice. But when I use it, I have this nagging feeling that it is slow.

When I installed a Ruby on Rails app on my webhost, it was ridiculously slow. If you used regular CGI, there was a 4-5 second time interval between pages loading in the browser. With FastCGI on, it wasn't slow at all.

Now maybe my webhost just didn't have their settings configured very well. Does anyone know if Ruby is slow or if it was just a situational problem that happened to me alone?
«134

Comments

  • MarkMark Vanilla Staff
    Are you talking about Ruby, or Ruby on Rails?
  • I'm not sure. Maybe the language is slow or maybe the framework is bloated. i just know that on my host with regular CGI which runs PHP scripts just fine, it was slow.
  • Rails is designed to be used with FastCGI. PHP isn't. As far as I'm aware it's widely known and accepted that Rails is slow without FastCGI, because the entire Ruby/Rails environment needs to be initalised with every request.
  • edited January 2006
    I see. Now I guess I'm now more person who knows.

    So a Ruby script written by itself wouldn't be slow? Its just the fails factor?
  • MarkMark Vanilla Staff
    huh?
  • edited January 2006
    I would wager that the actual stuff you're doing (http transmission and database access especially) would take way more time than the code interpretation, unless you have a really simple page.
  • So a Ruby script written by itself wouldn't be slow? Its just the fails factor?
    I was meaning the "Rails factor".

    Anyway, reason I ask is because I would like to get away from Rails. I don't like some of the things it forces you into (unless you modify it, which you can do), and I'd like to use Ruby but if it is Ruby itself that is slow compared to say, PHP, then I don't want to use it.

    But if it is Rails that is slow, then its not as much of a problem.
  • edited January 2006
    Can anyone give me a definitive answer? This is pretty important as it is for a company I'm working at.

    Is it Ruby or is it Rails that is slow on CGI? Thanks very much.
  • I would say that you should probably throw this one out to the folks over at the ruby forums (if you haven't done that already), and I'm sure someone could give you a definate answer. To my understanding tho, FastCGI is simply a CGI extension to pipe all similar app process down the same threading instead of starting a new thread for each call. Next time you run your ruby app, watch it via top/task manager to see if something is bugging and running resources into the ground.
  • edited March 2006
    The fastest environment is lighttpd with fastCGI and second is Apache also with fastCGI.

    mod_ruby for Apache won't perform as well under stress.
    CGI is in-between, a bit far from fastCGI though.

    In development mode, RoR IS sloooow because it reloads nearly everything from scratch. That's why you can modify any controller, view or model (except the DB itself) without having to reboot Webrick/Apache/lighttpd (and that's a cool feature as long as you are developing your app).
    In production mode, there are caches everywhere and you can't modify anymore your code (I think so) and it should scale well.

    Just check fastcgi webrick lighttpd under google
    like
    http://wiki.rubyonrails.com/rails/pages/FAQ#webservers
    http://wiki.rubyonrails.com/rails/pages/ProductionEnvironments
    http://wiki.rubyonrails.com/rails/pages/LighttpdWithProcessScripts
    for more information.
  • First of all, Rails is not ment to be used on basic CGI it's required that you use FCGI, and as for it being slow, I just setup Fedora Core 4 with LightTPD and MySQL with FCGI, and it's fast as the speed of light with everything that I'm using. And I'm running a test installation of TYPO on it. The only problem that I see coming is that if we shoot the database full of info and make hundreds of queries at the same time, MySQL could slow down a tad. But I'm not seeing it happening. So RoR is not slow by any means.
  • Typo's a hog - not a good benchmark. I'm building a complete site (articles, users, forums, other content types etc) in RoR and it's as fast as anything else. It's as 'slow' as it is 'secure' - ie. piece of string sorta shizzle. Running it through apache is slow, I've heard Dreamhost is slow, and there are a number of other factors that will likely make it slow. Check the Rails wiki (wiki.rubyonrails.com) for more goss.
  • You guys realize how relatively old FCGI is, right? Its been considered a dead technology for some time now. I'm not sure if Rails is going to change that or not.
  • Who cares if it is old? It works it's secure, it's like Lisp, it's old but it is still widely used. And Typo is an excellent benchmark, if that runs fast on my server it will run well on a professional server. I'm also building my own software, articles, messaging, file server, users, intranet, customer database the shebang and so far it runs perfectly. But if you are worried about FCGI being too old and RoR being too slow, you might be looking at a completely wrong framework then. Move to something else, Django maybe, it runs on normal CGI and is good to boot (tho I absolutely hate the whitespace).
  • edited March 2006
    You've gotta realize that I posted this about a month and a half ago.

    And, no, I don't care for Django, but seriously, the complaint about whitespace in Python is absolutely ridiculous. I've been learning Python recently and I couldn't help but to think "this is what people are complaining about?"

    Here is a function in Python:

    def function (arg1, arg2):
    >>>function contents go here

    This is the same function in Ruby:

    def function (arg1, arg2)
    >>>function contents go here
    end

    (sorry, couldn't show spaces correctly)

    Everyone indents their code. If you aren't, your coding style is unlike that of 99% of people out there. But because Python uses whitespace, your code is cleaner, and you don't even need the unecessary and extra "end" statement like you do in Ruby.

    I think its the silliest complaint in all of programming.
  • Well I don't know if it is silly or not, since it's matter of taste. But personally I like seeing where my definitions start and end, it's three letters versus one empty space, it's not like that after you have written a long definition that you don't have any juice left to type three letters, besides, aesthetically end is far more noticeable and functional than nothing.
  • Oh and had to add, if the oldness of FCGI turns you off, you can always go to SCGI it's fairly new, the newest version was released month or so ago.
  • I was about to mention SCGI =P Not entering the language fanboy debate; I have no knowledge of python, and very little of any other language (bar PHP, and markup code). PS. I guess that makes Ruby good for designer-cum-developers!
  • edited March 2006
    Ruby is an... interesting language.
  • I dabbled in RoR a bit, but I just can't PERSONALLY justify the time it will take to learn a whole new language (Ruby) and then learn how to stick it to the Rails framework. I've seen people who know it use it to VERY quickly do some very cool stuff ... but I've got my head wrapped around PHP enough to be useful with it. Dabbled in Python for a while before PHP (and liked it a lot, it's a great little language I think.) ... and some C/C++ in there (but not enough to be useful and it's long forgotten). PHP works for me. Until I manage to have enough free time to learn Ruby, RoR is useless to me. Anyone who thinks they can program for Rails without learning Ruby first is in for a big surprise to.
This discussion has been closed.