How is rails different from PHP from Apache's view?

Hi,

I love rails much better than php.

I do, too.

(I'm not a php expert, though.)

I'm not either.

However, when I use rails with apache, it's painful.

Very.

(I use Dreamhost as my web hosting server, by the way)

Sorry to hear that. I was involved in a project that tried to deploy to DreamHost. I had nothing but problems. And it was very slow. Even SSHing to the command line was like frozen syrup. I would advise searching for a host that is dedicated to Rails deployments, not one that just tacks it on.

I know that I can't compare rails with php because rails is a framework and php is a language. Let's just think that rails is a ruby with some libraries. Then it's comparison between php and ruby, right?

Right, you'd want to compare PHP to Ruby. It's a matter of preference. I like Ruby. I remember when I was making a decision between Python and Ruby, I read an article that offered a very sound piece of advice. It went something like this: both Python and Ruby are great and you can accomplish whatever you need to in them, but they feel different. Try both out and go with the one that "feels better" to you. I did that, and I like the feel of Ruby. I also like the feel of Rails.

Why is rails so difficult to deploy while php is easy? Can we make rails as easy as php for apache, or is it fundamentally impossible?

I don't know any of the details, but Ruby 1.9 is just around the corner. I read somewhere that performance is at least 2.5 times better. I've also read somewhere about a different Ruby VM that will hopefully make it faster. While none of this is reality today, it does bring some hope. Until then, you do have options. I use LiteSpeed. Even though it's not open source, the standard version (32 bit, one CPU) is free. It's pretty snappy. They wrote their own Ruby API and it's supposed to be the fastest way to run Rails apps. They also support PHP, and _claim_ it can be 5 times faster than mod_php. I have not done any benchmarks, so I can't say if their claims are true. This is what I do know from my own personal experience: It's easy and it seems to perform well. I like it. www.litespeedtech.com. [I'm not affiliated with them in any way!]

Before I switched to LiteSpeed, I used Mongrel behind Apache. And while this works fine, there are some aspects of it that I don't like. You have to run a Mongrel process listening on a dedicated port. So if you have a cluster of three Mongrels, they are listening on three ports. When you have a lot of apps on your server, you have to remember which ports are taken. It can become a headache quickly. With LiteSpeed, you can have multiple listeners if you want, or you can have just one (in which case it works basically like Apache and a mod). Also, each of those three Mongrel processes are running a Ruby process and taking up RAM, the amount depends on the size of your application. I've read that a decent sized application can occupy 40M, but again, I don't know if that's true. I've not yet bothered to check as I'm still in development and my server is a sandbox. And to be fair, I don't know exactly how LiteSpeed manages memory. The configuration for LiteSpeed is also a lot easier than Apache/Mongrel as well. I don't have to futz with configuration files. LiteSpeed comes with a template preconfigured for Rails apps, so adding a new app is as easy as a couple of clicks and filling in three values.

Your mileage may vary. I used to think that I liked flexibility. I have come to realize that I actually prefer ease and productivity. That's why I use a Mac, and that's why I like Rails.

This is not a rant but pure curiosity.

Haven't you ever heard the saying that "curiosity killed the cat"? :wink:

Thanks.

Sam

Peace, Phillip

I would advise searching for a host that is dedicated to Rails deployments, not one that just tacks it on.

+1

I don't know any of the details, but Ruby 1.9 is just around the corner. I read somewhere that performance is at least 2.5 times better.

Count on 1.8.6 for near-term production work. 1.9 is still an unknown. The VMs (Rubinius, YARV, and JRuby) may or may not fill your need. I know of at least one company who are using JRuby for production, but it's still bleeding edge.

The speed issue is pretty much moot in all but the most successful cases. OP, raise your hand if you think you are getting close to the limits of what PHP can serve. If your hand is still down, you will probably not need a faster Rails solution than what's currently available.

When you have a lot of apps on your server, you have to remember which ports are taken.

If performance is becoming an issue, you won't be running a lot of apps on the same server. Besides, whatever you are using as a front-end load-balancer, whether Apache, Pound, Pen, ngnix, or something else, will have a config file with all the ports listed.

Also, each of those three Mongrel processes are running a Ruby process and taking up RAM, the amount depends on the size of your application. I've read that a decent sized application can occupy 40M

Memory can be an issue. 40M is not unusual and that's excluding the amount of RAM required for the database server.

My recommendation: Deploy the app, see if it's serving enough pages, then try to optimize.

My point was more toward ease, not performance. I have a server that is not even close to performance limits, but I'm running a number of different things on it. Sure, I can open up the apache config files to see what's on a port, but it's a hassle. For me, it's just so much nicer to not have to even bother with that. Rails makes development easier. LiteSpeed makes deployment easier.

Peace, Phillip