Recently I have been developing a website using Rails. I come from a PHP
background, a very experienced one to say the least, and have been
developing for quite some time now. In PHP I have a framework quite like
Rails, although at the time of writing it I had no clue Rails even
existed. It shares the same basic concept of routing and a strong
database back-end. Here is a comparison of two sites I have developed,
the second one (Rails one) still under construction:
http://countermail.com/index.php?mod=core - PHP
http://www.joshgilman.com/articles/index - Rails
I use standard 4MB/s cable connection via a wireless router and the PHP
website takes about 1-2 seconds to load whereas the Rails website takes
a good 6-7 seconds to load. This speed is really killing me, and I'm not
sure it's entirely Rails fault but rather part of my host's fault. My
question is what's a good host to have a Rails application on? Is this
the normal speed I should expect from a rails application? I would love
to continue with this application but with speeds like this I am already
considering switching over to PHP.
If anyone can make some suggestions to help me out here I would be very
greatful. Thank you.
Cheers,
Josh
--
Posted via http://www.ruby-forum.com/.
On Jan 31, 1:41 pm, Josh Gilman <rails-mailing-l...@andreas-s.net>
wrote:
> Hello guys.
>
> Recently I have been developing a website using Rails. I come from a PHP
> background, a very experienced one to say the least, and have been
> developing for quite some time now. In PHP I have a framework quite like
> Rails, although at the time of writing it I had no clue Rails even
> existed. It shares the same basic concept of routing and a strong
> database back-end. Here is a comparison of two sites I have developed,
> the second one (Rails one) still under construction:
>
> http://countermail.com/index.php?mod=core- PHPhttp://www.joshgilman.com/articles/index- Rails
Some standard questions:
Are you running production or development mode?
How is the app deployed (Webrick, Mongrel, FastCGI, CGI)?
I'm running in development and I believe it's deployed in FastCGI, but
I'm not sure, my host does not explicitely say.
So you realize that development is exponentially slower than production
mode? For one thing, all files are re-loaded at every single request
(handy in dev mode so you don't have to restart anything, but _slow_).
There's no caching. There's a lot more logging which slows things down.
And other, slower differences I'm sure I'm forgetting.
Switch to production mode and you should see a very large improvement.
In development all your models and controllers are reloaded on each
request, and in production the are read on bootup of the server and then
no more.
You should expect slowness in development mode due the large number of
files in a rails aplication. But in production the speed should be
comparable to PHP.
How can you ensure it's in production? I changed config/environment.rb
and uncommented:
ENV['RAILS_ENV'] ||= 'production'
I notice a little bit of difference, still a little slow though for only
loading a few articles. Right now I am running off of NetFirms which is
pretty crappy, can someone make any suggestions for a host geared
towards Rails applications? That's not overly priced, I am very limited
on money right now.
http://railsmachine.com/
http://textdrive.com
--
View this message in context: http://www.nabble.com/-Rails--The-speed-of-Rails-tf3145992.html#a8723172
Sent from the RubyOnRails Users mailing list archive at Nabble.com.
railsmachine is too expensive and I heard textdrive sucked beyond
belief. I have been doing my own research and it doesn't seem like there
is any real good ones out there that are not for enterprise applications
and charge you enterprise prices.
Now here's my question. They offer two plans, one for $60 a month but no
support for lighttpd/mongrel servers and then one for $108 a month with
support for lighttpd/mongrel servers. Is it worth it to go all the way
to $108 for the servers for pay $60 and go with fastcgi?
hth,
Bill
The real question is this: Are you a dev who's test-driving rails to see how
it works ($5 developer plan) or are you pushing something live tomorrow that
has to serve hundreds of thousands of pages a day without breaking a sweat?
Rails hosting is not as commoditized as PHP and Perl (or any Windows)
hosting are. Deploying a Rails app requires more from your host and more
from you. If you are in development mode, it might be worth your while to
get a bit of dev space on one of the less expensive hosts to try different
deployments.
Hope this helps.
--
View this message in context: http://www.nabble.com/-Rails--The-speed-of-Rails-tf3145992.html#a8724156
Kind regards,
Nick
On Jan 31, 5:54 am, Josh Gilman <rails-mailing-l...@andreas-s.net>
wrote:
> Alex Wayne wrote:
> > Josh Gilman wrote:
> >> unknown wrote:
I personally have had good experiences with ServInt for VPS hosting,
their plans start a little under $50 for a fully-managed server. Set
it up with LiteSpeed's free server which has built in support for RoR
and you have a fairly easy to setup, easy to maintain server
configuration that still gives you cPanel if you should need such a
thing.
--
JP
On Jan 31, 12:04 am, Josh Gilman <rails-mailing-l...@andreas-s.net>
wrote:
> railsmachine is too expensive and I heard textdrive sucked beyond
Even development mode shouldn't be that slow, unless you just have a
lot of queries on that page. If so, running on mongrel/fastcgi in
production won't help much.
--
Rick Olson
http://weblog.techno-weenie.net
http://mephistoblog.com
I would suggest http://www.railshosting.org/#free_rails_hosting to get
a decent free account while you are testing the waters
What I am really looking for is a host to use once I have the
application finished, I can run and test the application on my computer,
so that's not a problem. I need a reliable host that I don't need to
worry about switching from whenever I do start getting bigger traffic.
I'm with Rick here; there's probably a better way to do whatever it is
you're trying to do.
Is the site this slow during development as well? All of it, or just a
single action?
Isak
On my computer running on a Webrick server it's lightning fast. There is
no lag and it runs perfectly fine. I'm am not sending many queries. The
most cluttered page would probably be the display article page where I
query for the article information and then query for all the comments
that belong to that article, but those are the only 2 queries that I am
sending. I don't understand why that would be so laggy, my basic code
looks like:
@article = Article.find(params[:id])
# Display article information #
render(:partial, :article_comments, @article.comment)
# Display the comments
Note the above was written by hand so I'm sure it contains mistakes but
you get the general idea.
I'm sure you've thought of it, but the only time I've had a slow system
(without heavy traffic), is improper use of the joins, or not using
eager loading.
For Example,
Myobject.find(:all,:include=>'childtable')
One of the big things, is that rails makes it easy to do something this
<%=Myobject.childtable.full_name-%>
Doing that 500 times in a view, will make 500 database calls unles you
use eager loading.
You could try dreamhost.com - with a coupon you might just spend $10 for
the first year. Search google from dreamhost coupon. There is a
dreamhost wiki with Rails deployment tips.
Stephan
What does:
Myobject.childtable.each {}
Do? I thought it would just query the database once, grab all the
results, and loop through them.
Right, but that's not exactly what the parent meant. Consider...
model... Person has_one Address
controller.... @people = Person.find(:all)
view....
<% @people.each do |person| %>
<%= person.name %> lives in <%= person.address.city %>
<% end %>
If you've got 500 people, you're going ot have 501 database queries. One
to get all the people, and one to get each person's address.
Change the controller to... @people = Person.find(:all,
:include => [:address])
And now Rails does a join query so you only have one database query.
-philip
Ok, let's presume it was deployed as FCGI or Mongrel. What do the logs look
like for a slow page? That would at least provide a hint about whether the
database was the bottleneck.
Finally, how about creating a dirt-simple action:
def dirt_simple
@post = Post.find :first
end
and a dirt simple view
<%= @post[:id] %>
How fast is that? If it's not fast, then you can take your focus off the
database and point it back to your server config.
Here's the deal. It's fast on the local machine under WEBrick. Ok, that's
understandable -- long-running process, no network overhead, but wait! The
database on the local machine should be *slower*. So, as I continue attempt
inference from this thread, it tells me that the performance problem is in
the server on the remote host or the host itself.
My first guess was that the deployment was straight CGI and that's what was
causing the holdup. If I'm not right, it'll show up in the logs.
--steve
--
View this message in context: http://www.nabble.com/-Rails--The-speed-of-Rails-tf3145992.html#a8742978
I share the same feelings, I'm thinking it's NetFirms being cheap and
running it on CGI, hence why I was asking for a better host. Sample logs
look like:
Processing ArticlesController#show (for **.**.***.*** at 2007-01-31
21:57:03) [GET]
Parameters: {"action"=>"show", "id"=>"1", "controller"=>"articles"}
Rendering within layouts/articles
Rendering articles/show
Completed in 0.18064 (5 reqs/sec) | Rendering: 0.02450 (13%) | DB:
0.11660 (64%) | 200 OK [http://www.joshgilman.com/articles/show/1]
I blocked my IP out of course.
I'm not affiliated, though I have been a customer for over a year.
Petr Janda-2 wrote:
>
>
> I share the same feelings, I'm thinking it's NetFirms being cheap and
> running it on CGI, hence why I was asking for a better host. Sample logs
> look like:
>
>
> Processing ArticlesController#show (for **.**.***.*** at 2007-01-31
> 21:57:03) [GET]
> Parameters: {"action"=>"show", "id"=>"1", "controller"=>"articles"}
> Rendering within layouts/articles
> Rendering articles/show
> Completed in 0.18064 (5 reqs/sec) | Rendering: 0.02450 (13%) | DB:
> 0.11660 (64%) | 200 OK [http://www.joshgilman.com/articles/show/1]
>
>
> I blocked my IP out of course.
>
> --
>
--
View this message in context: http://www.nabble.com/-Rails--The-speed-of-Rails-tf3145992.html#a8743961
How do you see its in the database ? 5 requests per second should not be
noticable, if there is only one per hour.
I timed access to the page from my machine at 3.5 seconds compared to
yahoo.com at 0.5 seconds. So something is likely to be wrong.
Could the OP determine just how the Rails machinery is invoked?
Stephan
http://groups.google.com/group/rubyonrails-deployment?hl=en
We are using shared and cheap hosting from RailsPlayground, for some
of our proyects and it works great, the best part is the support.
--
AnĂbal Rojas
http://www.rubycorner.com
http://www.hasmanydevelopers.com
On Jan 30, 8:41 pm, Josh Gilman <rails-mailing-l...@andreas-s.net>
wrote:
> Hello guys.
>
> Recently I have been developing a website using Rails. I come from a PHP
> background, a very experienced one to say the least, and have been
> developing for quite some time now. In PHP I have a framework quite like
> Rails, although at the time of writing it I had no clue Rails even
> existed. It shares the same basic concept of routing and a strong
> database back-end. Here is a comparison of two sites I have developed,
> the second one (Rails one) still under construction:
>
> http://countermail.com/index.php?mod=core- PHPhttp://www.joshgilman.com/articles/index- Rails
>
> I use standard 4MB/s cable connection via a wireless router and the PHP
> website takes about 1-2 seconds to load whereas the Rails website takes
> a good 6-7 seconds to load. This speed is really killing me, and I'm not
> sure it's entirely Rails fault but rather part of my host's fault. My
> question is what's a good host to have a Rails application on? Is this
> the normal speed I should expect from a rails application? I would love
> to continue with this application but with speeds like this I am already
> considering switching over to PHP.
>
> If anyone can make some suggestions to help me out here I would be very
> greatful. Thank you.
>
> Cheers,
> Josh
>
> --
> Posted viahttp://www.ruby-forum.com/.
Completed in 0.18064 (5 reqs/sec) | Rendering: 0.02450 (13%) | DB:
0.11660 (64%) | 200 OK
Notice that DB is 64% of the time.
Still, you're right, 5 req/sec should not be a big deal.
I'd still like to know if it was deployed as a CGI because that's then only
time I've ever seen such gummy behavior.
--
View this message in context: http://www.nabble.com/-Rails--The-speed-of-Rails-tf3145992.html#a8752373