Forum: Ruby on Rails ruby script/generate scaffold Product Admin hangs

E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 Anne G (Guest)
on 2006-01-26 02:10
(Received via mailing list)
Hi

I am running Mac OX tiger with the installed ruby 1.8.2, and
mysql5 (I checked that it was running in preference). I
tried to run the various fixes recommended in agileweb. I am
stuck on page 57, script/generate scaffold...

> Could you paste in your database.yml file, from the
> "config" folder inside your Rails app?  If you have any
> passwords entered there, you should change them to
> nonsense before sending.

development:
  adapter: mysql
  database: depot_development
  host: localhost
  username: root
  password: $564^%#

test:
  adapter: mysql
  database: depot_test
  host: localhost
  username: root
  password: 0#@^463

production:
  adapter: mysql
  database: depot_production
  host: localhost
  username: prod
  password: wibble

Is there a way to check that I have indeed all the pieces
fixed that need to be fixed? the #46 fix, or how do I test
this mysql gem?

thank you for your help,

anne
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 Anne G (Guest)
on 2006-01-26 18:43
(Received via mailing list)
I replaced the default list.rhtml with the copy/paste of the
text of page 67-68 from the rails-code.tgz and added the
text with copy/paste for page 69 scaffold.css.

I get an error message which starts with
compile error
script/../config/../app/views/admin/list.rhtml:1: syntax
error
_erbout = ''; _erbout.concat "<h1>Product
Listing</h1>\r\r<table cellpadding=\"5\"
cellspacing=\"0\">\r";
odd_or_even = 0
for product in @products
  odd_or_even = 1 - odd_or_even
; _erbout.concat "\r  <tr valign=\"top\" class=\"ListLine";
_erbout.concat(( odd_or_even ).to_s); _erbout.concat
"\">\r\r    <td>\r      <img width=\"60\" height=\"70\"
src=\""; _erbout.concat(( product.image_url ).to_s);
_erbout.concat "\"/>\r    </td>\r\r    <td width=\"60%\">\r
<span class=\"ListTitle\">"; _erbout.concat((
h(product.title) ).to_s); _erbout.concat "</span><br />\r
"; _erbout.concat(( h(truncate(product.description, 80))
).to_s); _erbout.concat "\r    </td>\r\r    <td
align=\"right\">\r      "; _erbout.concat((
product.date_available.strftime("%y-%m-%d") ).to_s);
_erbout.concat "<br/>\r      <strong>$"; _erbout.concat((
sprintf("%0.2f", product.price) ).to_s); _erbout.concat
"</strong>\r    </td>\r\r    <td class=\"ListActions\">\r
"; _erbout.concat(( link_to 'Show', :action => 'show', :id
=> pro

As far as I can tell, the downloaded code from depot4 folder
is the same as in the book. How do I debug a syntax error
like this?

anne
D90ef6808433e63203e15a5c2dadb0bb?d=identicon&s=25 Ben Reubenstien (Guest)
on 2006-01-26 19:55
(Received via mailing list)
Without seeing the rhtml I can't offer a definitive reason.  When I get
syntax errors like this I usually back out whatever I have added to my
RHTML, and add it back incrementally to spot the error.

~ Ben
9a40def42f37ff6e3120d625656a0300?d=identicon&s=25 Marc Croom (Guest)
on 2006-01-26 19:58
(Received via mailing list)
Check that you haven't put a <%= when you meant <%
That's sometimes been the cause of similar errors for me.
25e11a00a89683f7e01e425a1a6e305c?d=identicon&s=25 Wilson Bilkovich (Guest)
on 2006-01-26 21:53
(Received via mailing list)
On 1/26/06, Anne G <anne@wjh.harvard.edu> wrote:
> cellspacing=\"0\">\r";
> "; _erbout.concat(( h(truncate(product.description, 80))
> is the same as in the book. How do I debug a syntax error
> like this?
>

Can you paste in the code?  Usually the "line 1" error means that
you've got a <% or <%= opening tag that isn't closed.  Unfortunately,
these "totally couldn't handle it" error messages are the hardest to
track down.  Luckily, they usually end up being something really
simple.  You can find them with an editor that has serious syntax
highlighting (like vim or TextMate).
If you're using something else, you can chop it up into pieces and run
it a bit at a time.  Add one block of code at a time, until you find
the error.
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 Anne G (Guest)
on 2006-01-27 01:58
(Received via mailing list)
this is the text copy pasted from the list.rhtml file from
the book's rails-code.tgz from folder depot4: list.rhtml
should be as listed page 68.

text wrangler does put some colors, I did not see any
mismatch. I start geting an error as soon as I put the
first lines with <% ... %> that seems to define some macro,
don't know why it would triger an error.

<h1>Product Listing</h1>

<table cellpadding="5" cellspacing="0">
<%
odd_or_even = 0
for product in @products
  odd_or_even = 1 - odd_or_even
%>
  <tr valign="top" class="ListLine<%= odd_or_even %>">

    <td>
      <img width="60" height="70" src="<%= product.image_url
%>"/>
    </td>

    <td width="60%">
      <span class="ListTitle"><%= h(product.title)
%></span><br />
      <%= h(truncate(product.description, 80)) %>
    </td>

    <td align="right">
      <%= product.date_available.strftime("%y-%m-%d")
%><br/>
      <strong>$<%= sprintf("%0.2f", product.price)
%></strong>
    </td>

    <td class="ListActions">
      <%= link_to 'Show', :action => 'show', :id => product
%><br/>
      <%= link_to 'Edit', :action => 'edit', :id => product
%><br/>
      <%= link_to 'Destroy', { :action => 'destroy', :id =>
product },
                             :confirm => "Are you sure?" %>
    </td>
  </tr>
<% end %>
</table>

<%=  if @product_pages.current.previous
       link_to("Previous page", { :page =>
@product_pages.current.previous })
     end
%>

<%= if @product_pages.current.next
      link_to("Next page", { :page =>
@product_pages.current.next })
    end
%>

<br />

<%= link_to 'New product', :action => 'new' %>
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 Anne G (Guest)
on 2006-01-27 02:43
(Received via mailing list)
Of course, right after I posted this info, I realized that
there are two languages intermixed, the % language and the
table language. And the first few lines start a for loop
which is closed just before table is closed.

Once I understood that, I was able to modify the list file
little by little. It was cool to watch the changes happen.
The book does not bother explaining anything, so at least
with this method, you can guess what is going on, and look
it up if it is of interest.

I added the lines little by little, taking away lines also
until the list file was the same as far as I could tell as
the book's file I was copying from, and no syntax error. ---
the pictures did not load, oh well ~/Desktop/image.jpg ---

I recopied the original text from the code download into
the list file, and the syntax error came back.

I will try again tomorrow. Thank you for your advice

anne
D90ef6808433e63203e15a5c2dadb0bb?d=identicon&s=25 Ben Reubenstien (Guest)
on 2006-01-27 03:07
(Received via mailing list)
Hi Anne ~

Images need to be in the rails_root/public/images folder.  It looks like
you
were trying to refer to your desktop.

~ Ben
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 Anne G (Guest)
on 2006-01-27 13:52
(Received via mailing list)
Very strange, this morning, the error was there. I went
backward, taking code out chunk by chunk, but some error was
there all the way.  until I went to a blank page.

I restarted with the download file, and now I don't get any
error. I can't get the error even with the old files I
believe gave the error.

I tried editing the path of the image to image that are
already in the images folder in public,
image url
/images/sk_auto_small.jpg
/public/images/sk_auto_small.jpg
...
nothing works.
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 Anne G (Guest)
on 2006-02-02 17:52
(Received via mailing list)
HI

Rails normally has an rhtml file on the server which is
interpreted. If the rhtml has a load image command,
it loads the image and presents it to the user.

Is there a way to have Rails load all the images that are
going to be used ahead of time? How would the code look
different?

--------------------------------------------
usually the user clicks on submit, which is really a link
which is interpreted as a request by the controller.

Is there a way to have Rails respond to a key press
by storing the content of the key press and moving on to
load the next image

--------------------------------------------
As I understand it, the timing is mostly controlled by the
user clicking on a link. Until then the server just sits
there waiting for someone to request a link

How can I use Ajax to control the timing of the presentation
independently of a link request?

thanks for your help

anne
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 Anne G (Guest)
on 2006-02-03 12:38
(Received via mailing list)
Loading pictures up front:

I found the following: "a plethora of solutions to the
preloading image problem in JavaScript are available."
http://www.ilovejackdaniels.com/css/preloading-ima...

So that is a problem that people are thinking about, and
there are ways to do it. I know that rails gives access to
javascript through helper functions, so I am wondering if
the ability to load pages all at once, or images all at once
is available in rails.

I hear that the Times has set it up so all the articles load
up at once, so reading the paper is very fast, the articles
are already there.

-----------------------------------------------------------

for key presses, it might be more difficult, people seem
more focused on the mouse, on mouse roll over... but if they
give mouse interactivity, they give keyboard interactivity.

---------------------------------------------------------

It seems to me that as web application are taking over
behaviors of computer applications, they will need to do all
the things a computer application can do, but we may be at
the beginning of that era. Flash can do all I want to do,
and it is loaded into and runs from a browser, but other
tools like Rails may not be able to do such things yet?

---------------------------------
I can always find my post on the web archive, but I don't
usually find them in the gmane rails archive. Yet they are
mirrors of each other, no?

thanks for your help
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 Anne G (Guest)
on 2006-02-03 12:53
(Received via mailing list)
feed://rss.gmane.org/gmane.comp.lang.ruby.rails

Javascript to preload images for faster loading on later
pages:

<script language = JavaScript>
if (document.images)
{
img1 = new Image();
img2 = new Image();
img1.src = "Image-Name-1.gif";
img2.src = "Image-Name-2.gif"
}
</script>

Use of the image Image-Name-1.gif in subsequent pages will
be loaded from chache.

that should do the trick, load all the images at the start.
But where do I put this javascript code in a rails project?

I want to keep track of a person with session, and keep
changing the picture as he proceeds with task...
Ad7805c9fcc1f13efc6ed11251a6c4d2?d=identicon&s=25 Alex Young (Guest)
on 2006-02-03 13:53
(Received via mailing list)
Anne G wrote:
> is available in rails.
>
It's available the same way it's always been available - through
judicious use of the right bits of HTML, Javascript and CSS.  There
aren't many bits of Rails that specifically help browser pre-caching, or
hidden div loading, but then there's nothing to get in the way either...

> I hear that the Times has set it up so all the articles load
> up at once, so reading the paper is very fast, the articles
> are already there.
Not that I can see...  Have you got a reference for that?

> for key presses, it might be more difficult, people seem
> more focused on the mouse, on mouse roll over... but if they
> give mouse interactivity, they give keyboard interactivity.
>
Again, this is an HTML/Javascript thing, not Rails-specific.  There
might be some functionality in RJS templates to help out, but I can't
think of any off the top of my head.  The accesskey attribute on form
elements and links might be enough to give you the keypress
functionality you want.

> It seems to me that as web application are taking over
> behaviors of computer applications, they will need to do all
> the things a computer application can do, but we may be at
> the beginning of that era. Flash can do all I want to do,
> and it is loaded into and runs from a browser, but other
> tools like Rails may not be able to do such things yet?
There's nothing really technologically new Rails brings to the table.
It just ties everything together in a *really* tidy package.
Ad7805c9fcc1f13efc6ed11251a6c4d2?d=identicon&s=25 Alex Young (Guest)
on 2006-02-03 13:56
(Received via mailing list)
Anne G wrote:
> Use of the image Image-Name-1.gif in subsequent pages will
> be loaded from chache.
>
> that should do the trick, load all the images at the start.
> But where do I put this javascript code in a rails project?
Put that code in a template that will get loaded by the browser before
the images are needed.  Maybe in the head of application.rhtml, if it's
site-wide.
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 anne g (Guest)
on 2006-02-03 15:42
(Received via mailing list)
Thank you Alex for your help on this

anne
205bc8d44e9bc5c68d77dd412abcb3ce?d=identicon&s=25 Dan Shafer (Guest)
on 2006-02-04 21:14
(Received via mailing list)
On another programming list on which I'm active, I've (of course)
mentioned my newfound interest in and focus on Rails. One of the long-
time members, a pretty thoughtful guy, has emailed me privately and
asked me if I could point him to any Rails apps that were handling
huge amounts of traffic. I've had the usual conversations with him
about what scalability really means, how few sites need to handle
huge amounts of traffic, how Rails is just one component of the
landscape, etc.

Still, he wants to know if I can point him to any large-scale apps
done in Rails. Is there an answer to this question? Or is it just one
of those diversionary issues raised by people who are looking for
some reason not to spend the time to evaluate a new technology deeply
enough to draw their own conclusions?

Thanks.

(I did look at http://wiki.rubyonrails.org/rails/pages/RealWorldUsage
but it's impossible, of course, to tell which of those sites might be
handling huge traffic volumes.)
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 Anne G (Guest)
on 2006-02-04 21:36
(Received via mailing list)
I have a database exp
in database.yml I have in the development section

 adapter: mysql
  database: exp
  username: root
  password: ***
  host: localhost

That should allow for connection to the mysql database exp.

I created a table stimulis, with 45 records of
three columns
id   image_url  name
select * from stimulis shows them all in mysql

1. I generated a model file stimuli.rb

class Stimuli < ActiveRecord::Base
end

this somehow establishes the connection with the table
stimulis

2. I have a controller and an action hello

class RunexpController < ApplicationController
  def hello
     @stimuliAr = Stimuli.find_all
   end
end

3. I have a viewing html
<body>
 <% @stimuliAr.each do |stim| %>
  <%= link_to stim.image_url, :action => "show", :id => stim.id %>
  <% end %>
</body>

I don't have a show page yet, but that should not be a
problem.

when I try to view
http://localhost:3000/runexp/hello
in railrad

I get an error message
access denied for user 'root'@'localhost' (using password
no)
which is strange because mysql is setup with a password, and
I gave it in the config file, database.yml.

I am probably missing a piece which is normally setup by
scafold, is that so? what do I need to do?

Am I on the right track?

thanks

Anne
4353600bbb6b6e0950e62f7f44e49dd5?d=identicon&s=25 Steven Smith (Guest)
on 2006-02-04 21:39
(Received via mailing list)
A couple of the more well known applications would be 43 Things
(http://www.43things.com/) with somewhere between 500K and 1MM
requests per day and Basecamp (http://www.basecamphq.com/) with over
100,000 users.  Others on the list can probably give you more
specific examples for these two applications as well as others.

Steven Smith
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 Anne G (Guest)
on 2006-02-04 23:38
(Received via mailing list)
1. I put a space in front of the password in database.yml,
after "password:"
2. I rebooted the computer.

It now seems to work. I am able to access all the
information.

How can I generalise to several tables. I assume I
need one model per table?

How do I write to a table?

What do I need to understand about relational tables?

thanks for a little help, this is good learning, but it is
so slow finding this info, most tutorials I looked at use
scaffold

anne

---------------------------------------------------

1. I generated a model file stimuli.rb

class Stimuli < ActiveRecord::Base
end

2. I have a controller and an action hello

class RunexpController < ApplicationController
  def hello
     @stimuliAr = Stimuli.find_all
   end
end

3. I have a viewing html

<body>
 <%= link_to @stimuliAr[0].image_url, :action => "show", :id
=> @stimuliAr[0].id %>
 </body>
Ff82af3238a57fbd1212832ec1a19f28?d=identicon&s=25 Dylan Stamat (Guest)
on 2006-02-04 23:39
(Received via mailing list)
Hey Dan !

I really dig this interview:
http://www.oreillynet.com/pub/wlg/8274?wlg=yes

Also, Ezra's migration story is excellent:
http://brainspl.at/articles/2005/11/03/from-start-...

There are some others, but these two were enough to sell my employers on
using RoR instead of the J2ee or PHP solution they were about to use :)
==
Dylan
6edd67c92a1dab5eb23fed79f3c18564?d=identicon&s=25 David Heinemeier Hansson (Guest)
on 2006-02-05 02:15
(Received via mailing list)
> A couple of the more well known applications would be 43 Things
> (http://www.43things.com/) with somewhere between 500K and 1MM
> requests per day and Basecamp (http://www.basecamphq.com/) with over
> 100,000 users.  Others on the list can probably give you more
> specific examples for these two applications as well as others.

I believe 43things/people/places.com has been doing 1MM+ requests for
quite a while. The 37signals suite is doing more than 1.5MM+ requests
these days as well.

But these examples are not terribly interesting simply for the fact
that scaling Rails is largely uninteresting. It's a solved LAMP
problem.
--
David Heinemeier Hansson
http://www.loudthinking.com -- Broadcasting Brain
http://www.basecamphq.com   -- Online project management
http://www.backpackit.com   -- Personal information manager
http://www.rubyonrails.com  -- Web-application framework
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 Anne G (Guest)
on 2006-02-05 20:25
(Received via mailing list)
I have a controller in which I define @responseAr as a new
line from responses table

  def hello
   @stimuliAr = Stimuli.find_all
   @responseAr = Response.new
   end

   def knowname
    a_response = Response.create(
   :session_id  => 1,
   :stimuli_id  => 0,
   :keypress   => 1,
   :name       =>  responseAr.name)
   redirect_to :action => "hello"
   end

in my hello.rhtml I have a form to collect a name to be
store

  <%= start_form_tag(:action => "knowname") %>
      Name:
    <%= text_field("responseAr", "name") %>
    <%= submit_tag("Know Name") %>
    <% end_form_tag %>

I can write to the database if I type
  :name => "testname")
instead of
 :name => @responseAr.name)
or
:name => responseAr.name)

How do I access responseAr.name which the form has saved to
save it to the table?
thank you for your help
8ed6d55dddf47e0974bac833f08e4390?d=identicon&s=25 Ian Harding (Guest)
on 2006-02-05 23:02
(Received via mailing list)
Hi!

You need the Agile Web Development with Ruby on Rails book.  And
probably the "Pickaxe" book.

www.pragmaticprogrammers.com
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 Anne G (Guest)
on 2006-02-05 23:14
(Received via mailing list)
I found something that works, but I don't understand it

in my view page
    <%= text_field("responseAr", "name", "size" => "20") %>

in my controller method
    a_response = Response.create(
   :session_id  => 1,
   :stimuli_id  => 0,
   :keypress   => 1,
   :name       =>  params[:responseAr]["name"])

It works, but I don't understand it, what is pararams,
the book says :variable, :attribute
the default content is taken from
@responseAr.name
but why is the result not put there? how am I
supposed to know it is in params? confused.

The text does not show right away in the text box, why not?

thanks for your help
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 anne g (Guest)
on 2006-02-05 23:32
(Received via mailing list)
Ian Harding <harding.ian@...> writes:

>
> Hi!
>
> You need the Agile Web Development with Ruby on Rails book.  And
> probably the "Pickaxe" book.

Yes, it does sound like that is my problem, isn't it, but I have both,
still it is all guess work. The info just isn't there is in a way easy
to
grasp. What the book talks about is so much more complex than
what I am trying to do that I just don't find the info/examples.
5ce55767684e0cd1727db2b8b8975640?d=identicon&s=25 Steve Longdo (Guest)
on 2006-02-06 01:12
(Received via mailing list)
Are you sure that you are running Rails in development mode?  You could
also
try setting up a different user for Rails to access MySQL.  Try the
following.

>From mysql:
create databasename;
grant all on databasename.* to 'rails_user'@'localhost' identified by
'password';
flush privileges;

In your database.yml:
development:
  adapter: mysql
  database: databasename
  username: rails_user
  password: password
  socket: /tmp/mysql.sock
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 anne g (Guest)
on 2006-02-06 01:54
(Received via mailing list)
Here is what I learned after two days struggling with this:

To read from a table stimulis, I can run   @stimuliAr = Stimuli.find_all
in the controller
and I can now access any of the rows with something like
@stimuliAr[0].image_url
where image_url is one of my fields.

then to capture a name from form and write to a table

I created a new row in the controller
@responseAr = Response.new

 <%= start_form_tag(:action => "sortresponse") %>
      Name:
    <%= text_field("responseAr", "name", "size" => "20") %>
    <%= submit_tag("Know Name") %>
    <% end_form_tag %>

text field would use @responseAr.name I believe if it was not empty to
put
something in the box.

the output of the form is in params. To look at params, run
render_text @params.inspect
in the controller.
In my case I got something like
{â??commitâ?=>â?Know Nameâ?,
�action�=>�sortresponse�,
�controller�=>�runexp�,
â??responseArâ?=>{â??nameâ?=>â?dudâ?}}

so the form returns the label on the submit button (you can have
several different submit buttons)
which includes the data in params[:responseAr]["name"]

to write this info to database, I wrote
 a_response = Response.create(
   :session_id  => 1,
   :stimuli_id  => 0,
   :keypress   => 1,
   :name       =>  params[:responseAr]["name"])

I am not sure the a_response = is necessary.
this is how I wrote to the database.

This may not be the cleanest way but that is what I learned with
two days of work. I don't know where to find that kind of reallly
basic information. I hope this post will help someone else.

What I need to do now is  figure out session. Could someone give
me an idea of how complicated session is? What are the steps I need
to figure out. The book tutorial is too complex for me, and
I don't understand the reference section on session right now.

I don't want a login for right now, so the first time the page is
accessed, I need to create a fake id I guess which will identify
the computer.
Ad7805c9fcc1f13efc6ed11251a6c4d2?d=identicon&s=25 Alex Young (Guest)
on 2006-02-06 11:20
(Received via mailing list)
David Heinemeier Hansson wrote:
> But these examples are not terribly interesting simply for the fact
> that scaling Rails is largely uninteresting. It's a solved LAMP
> problem.

But the fact that the solution applies to Rails isn't necessarily
something people will assume, so that data point in itself is
interesting.
516b2dd693ce525d3f401b2ee1bef694?d=identicon&s=25 Jim Nachlin (Guest)
on 2006-02-06 17:04
(Received via mailing list)
Dylan Stamat wrote:
> Hey Dan !
>
> I really dig this interview:
> http://www.oreillynet.com/pub/wlg/8274?wlg=yes

Interesting, though not much on the implementation details.

>
> Also, Ezra's migration story is excellent:
> http://brainspl.at/articles/2005/11/03/from-start-...

Again interesting, though it states that a lot of what's being served is
static content.  "We are getting around 60,000+ hits a day and thanks
rails page and fragment caching. This allows for content to be
regenerated once after it is updated and then written to a static .html
page that the webserver is able to serve at 1500+ requests/second. Then
the next time an update is made to the content of any page that is
cached, the cached file is regenerated as .html and served as a static
page until the next update."

That might not work if the content is broader than it is deep, that is,
if you're serving mostly user-specific pages or fragments of pages.

The "Agile Web Development with Rails" book gives these examples:
Basecamp by 37signals does 400,000 dynamic requests / day.  The setup is
two servers (dual 2.4ghx xeons w/2gb of RAM each), apache1.3, fcgi.
rapidreporting.com tested it at 3000 req/sec on a test application, and
the real one (production)  does about 300 req/sec.  They use
lighttpd/fcgi.

A bit more info's in that book.

Regards,
Jim
E7b82038e59a7a2ef043542c873e124b?d=identicon&s=25 James Nachlin (Guest)
on 2006-02-06 17:16
(Received via mailing list)
David Heinemeier Hansson wrote:
[...]
>
> But these examples are not terribly interesting simply for the fact
> that scaling Rails is largely uninteresting. It's a solved LAMP
> problem.

Yes and no.  To oversimplify, if you need to be able to handle peaks of,
say, 500 requests/second, and your Rails (or tomcat, or whatever) setup
will handle 100, then 5 servers should do it.  If your Rails app will
only handle 5 requests/second, then you may be in trouble.

So application performance can't be ignored, and more specifically,
solving the puzzle of Rails configuration for high performance is not
trivial.
516b2dd693ce525d3f401b2ee1bef694?d=identicon&s=25 Jim Nachlin (Guest)
on 2006-02-06 17:22
(Received via mailing list)
The "Agile Web Development with Rails" book gives these examples:

Basecamp:
2 x 2.4ghz Xeons w/2gb RAM
15 fcgi processes and 50-100 apache1.3 processes
400,000 dynamic requests/day

rapidreporting.com:
3000 req/sec on a test app across their 10 machine cluster
300 req/sec on their production environment
lighttpd and 10 fastCGIs.

More details in the book.

Regards,
Jim
59de94a56fd2c198f33d9515d1c05961?d=identicon&s=25 Tom Mornini (Guest)
on 2006-02-06 18:14
(Received via mailing list)
On Feb 6, 2006, at 8:13 AM, James Nachlin wrote:

> in trouble.
>
> So application performance can't be ignored, and more specifically,
> solving the puzzle of Rails configuration for high performance is
> not trivial.

What's non-trivial?

It's as easy, and thanks to lighhtpd (no, not part of Rails, but I
thank Rails for introducing me to it!) easier than mod_perl, and the
same as anything else running FCGI...

-- Tom Mornini
6edd67c92a1dab5eb23fed79f3c18564?d=identicon&s=25 David Heinemeier Hansson (Guest)
on 2006-02-06 18:21
(Received via mailing list)
> solving the puzzle of Rails configuration for high performance is not
> trivial.

Oh, scaling is never "easy". It's just that its a known,
well-described problem. We know what the elements and techniques are.
And they're "boring" in Rails because they're roughly the same as with
any other LAMP stack.

Now performance on a particular project can always be a bitch, but
it's rarely so much about Rails as its about the business logic. And
of course, performance is different than scaling. You might have
terrible performance, like 5 req/sec, but still be able to throw tons
of hardware after it and still scale. And depending on your business
model, that might well still be immensely profitable. The cost per
request just needs to be less than the value of it.
--
David Heinemeier Hansson
http://www.loudthinking.com -- Broadcasting Brain
http://www.basecamphq.com   -- Online project management
http://www.backpackit.com   -- Personal information manager
http://www.rubyonrails.com  -- Web-application framework
132a94ca65959bda6c74fae54bff2425?d=identicon&s=25 Ezra Zygmuntowicz (Guest)
on 2006-02-06 19:23
(Received via mailing list)
On Feb 6, 2006, at 8:00 AM, Jim Nachlin wrote:

>
> is, if you're serving mostly user-specific pages or fragments of
>
> Regards,
> Jim


Jim-

	I wrote that article in September of 05 when we launched the new
site. And yes most stuff was cached then. Since then our traffic has
increased quite a bit. Yesterday we served about 50,000+ cached page
views and about 45,000+ dynamic page views. This is because we have
added a bunch of functionality to the application and a lot of it
cannot be page cached.

	But the whole site runs off of one dual xserve and we have tons of
room to grow still. My estimate is that we will be able to keep up
with 400-500k page views/day before we will need any new hardware.
Some of this performance increase is because the initial launch of
the site was on rails 0.12 - 0.13, I don't remember exactly which
one. But running under rails 1.0.0 is much faster and the performance
keeps getting better.

	Also, most very high traffic sites will make good use of caching
everywhere they can. Its mostly about finding the balance between the
functionality you need per page and your caching options available
for said page.

	I have no reservations that rails can handle as big of a site as you
want. You just need to make the right decisions about your apps
design and get the right hardware for the amount of traffic you
expect to serve.

Cheers-
-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
http://yakimaherald.com
509-577-7732
ezra@yakima-herald.com
516b2dd693ce525d3f401b2ee1bef694?d=identicon&s=25 Jim Nachlin (Guest)
on 2006-02-06 19:54
(Received via mailing list)
Tom Mornini wrote:
[...]
>> So application performance can't be ignored, and more specifically,
>> solving the puzzle of Rails configuration for high performance is  not
>> trivial.
>
>
> What's non-trivial?
>
> It's as easy, and thanks to lighhtpd (no, not part of Rails, but I
> thank Rails for introducing me to it!) easier than mod_perl, and the
> same as anything else running FCGI...

This is a serious question.  Supposing that lighttpd is not suitable to
your application, or you can't use it for some reason [*], then you can
use Apache 1.3 or 2, as I have been trying to do.

Setting up fastcgi using "external", I find there are many times when
Rails does not give an error message with any information, just a 500 or
a blank response.  If dispatch.fcgi dies when started as an external
server, it dies w/o error.  There is little documentation on how to do
this.  So, it was a struggle for me.

Eventually, I did get it working [**] thanks to the people on this list,
but there are still serious issues.

This is not to put any blame on the Rails team.  It is just a newish
system.  The fcgi documentation is sparse as well, and error reporting
there is not great.  So, non-trivial, overall.

Regards,
Jim


*
http://article.gmane.org/gmane.comp.web.lighttpd/3287
**
INITIAL RUBY ON RAILS BENCHTEST

This is on a laptop running linux 2.6, 512MB RAM, 1.7 GHz pentium M.
These figures are for relative comparison only, and do not reflect how
these systems would run on a well-tuned server.  The person who set
these up has several years using the Apache httpd on a professional,
high volume web site, and has no experience (<1 month) with lighttpd.


STATIC PAGE FOR COMPARISON:
$ ab -c10 -n1000 -k http://ruby.local:8000/index.html
Apache/2.0.53, fcgi:   564.99 [#/sec] (mean)
Apache/1.3.34, fcgi:   1236.24 [#/sec] (mean)
lighttpd 1.4.9, fcgi:  3270.16 [#/sec] (mean)

DUMMY RAILS CONTROLLER:
$ script/generate controller foo hello
$ ab -c10 -n1000 -k http://ruby.local:8000/foo/hello
Apache/2.0.53, fcgi:   9.65 [#/sec] (mean)   <---- using "dynamic" fcgi
method
                        10.13 [#/sec] (mean)  <---- using "static" with
-processes 2
                        9.98 [#/sec] (mean)   <---- using "static" with
-processes 4
                        136.24 [#/sec] (mean) <---- using "external"
with tcp sock **
Apache/1.3.34, fcgi:   *
Apache/2.0.53, cgi:    0.79 [#/sec] (mean)
lighttpd 1.4.9, fcgi:  195.70 [#/sec] (mean) <---- using "external" with
tcp sock ***

$ ab -c100 -n10000 -k http://ruby.local:8000/foo/hello
Apache/2.0.53, fcgi:   109.79 [#/sec]        <---- using "external" with
tcp sock **



NOTES
*  Can't get it working.  Fails w/ only a "500" from server, no further
error msg.
** This method seems to support only one external fcgi server under
Apache, essentially giving you a single-threaded server.
spin script:
#!/bin/sh
/home/jim/rubystuff/testapp/script/process/spinner \
   -c '/home/jim/rubystuff/testapp/script/process/spawner -p 19999 -i 1
' \
   -d
*** hint: delete the /tmp/ruby-sess* files owned by root
E7b82038e59a7a2ef043542c873e124b?d=identicon&s=25 James Nachlin (Guest)
on 2006-02-06 19:57
(Received via mailing list)
Ezra Zygmuntowicz wrote:
[...]
> room to grow still. My estimate is that we will be able to keep up  with
>     I have no reservations that rails can handle as big of a site as
> you  want. You just need to make the right decisions about your apps
> design and get the right hardware for the amount of traffic you  expect
> to serve.
[...]

Hi Ezra,

This is very good to hear, but so far I can't reproduce these results or
anything near them using

I need to use Apache.  So far it seems that with fcgi external servers
Rails will run single-threaded, and with "static" or "dynamic" fcgi,
performance is <10 req/sec. on my test box.

I know that people have made this work, and that Rails will scale, it is
just a matter of figuring out how, which I have not done yet.

Jim
59de94a56fd2c198f33d9515d1c05961?d=identicon&s=25 Tom Mornini (Guest)
on 2006-02-06 20:59
(Received via mailing list)
<10/second sounds like you're CGI, not FCGI.

--
-- Tom Mornini
E7b82038e59a7a2ef043542c873e124b?d=identicon&s=25 James Nachlin (Guest)
on 2006-02-06 21:08
(Received via mailing list)
Tom Mornini wrote:
> <10/second sounds like you're CGI, not FCGI.
>
> --  -- Tom Mornini
>

No.  CGI is <1/sec.  If anyone's getting better performance with FCGI
dynamic or static on Apache2, I'd like to hear how.  Glad to share my
httpd.conf and anything else.

Sincerely,
Jim Nachlin
132a94ca65959bda6c74fae54bff2425?d=identicon&s=25 Ezra Zygmuntowicz (Guest)
on 2006-02-06 21:33
(Received via mailing list)
On Feb 6, 2006, at 10:56 AM, James Nachlin wrote:

>> application and a lot of it  cannot be page cached.
>> options available  for said page.
>
> I need to use Apache.  So far it seems that with fcgi external
> servers Rails will run single-threaded, and with "static" or
> "dynamic" fcgi, performance is <10 req/sec. on my test box.
>
> I know that people have made this work, and that Rails will scale,
> it is just a matter of figuring out how, which I have not done yet.
>
> Jim

Jim-

	I first launched the newspaper site under apache1.3.x/fcgi and soon
realized how it wasn't performing very well at all for dynamic pages.
And apache/fcgi is notorious for those random 500 error messages that
are intermittent. So after using apache/fcgi for the site for one
week I decided to use lighttpd instead. The difference was black and
white. Apache is a great all around webserver and can do a great job
for some rails apps. But I have found that lighttpd was so much
faster and so much more stable for me that the only time I use apache
with my rails projects now is as a front end proxy to lighty on a
higher port. Even with the overhead of apache->lighty->rails->lighty-
 >apache, this set up was faster then standalone apache/fcgi.

	I understand that people are very used to apache servers and may be
reluctant to switch to lighty. But this will be a serious impediment
to your production environment until the new mod_proxy_fcgi comes out
for apache. i am hoping that that new apache module will solve these
problems. But for right now, lighty is IMHO the better choice for
most rails applications.

	Feel free to contact me off list. I would be happy to share
configuration files with you if you need.

Cheers-
-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
http://yakimaherald.com
509-577-7732
ezra@yakima-herald.com
516b2dd693ce525d3f401b2ee1bef694?d=identicon&s=25 Jim Nachlin (Guest)
on 2006-02-06 21:36
(Received via mailing list)
I must now recant some of my previou statements.  There was an error in
my httpd.conf such that the "-initial-env RAILS_ENV=test" was not
getting passed.  This means that the benchtest was running in
development mode under apache2.

I am now getting >100 req/sec in test or production mode, using the
dynamic fcgi method and unix sockets!

Regards,
Jim
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 Anne G (Guest)
on 2006-02-07 16:33
(Received via mailing list)
I wanted session to store the key to the stimulis table row
being viewed in the Subjects table.

Trying to mimick the cart example in the book, I started
with the line

session[:runexp] ||= Subject.new

where subjects is a table, subject.rb a model...
that line causes an error

It turns out
session[:runexp] ||= Subject.id

does not give an error, so for now, I will just store single
values in session.

But what do I need to do so this session is stored
in a database? Right now, I think it is stored in memory.

thank you for your help.

anne
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 Anne G (Guest)
on 2006-02-07 16:46
(Received via mailing list)
I saw this information


To use ActiveRecord as a session storage mechanism, you will
need a table in your database named sessions:

 CREATE TABLE sessions (
  id INT UNSIGNED NOT NULL AUTO_INCREMENT,
  sessid  CHAR(32),
  data    TEXT,
  PRIMARY KEY(id),
  INDEX(sessid)
);
http://wiki.rubyonrails.com/rails/pages/HowtoChang...

but I don't know what I am supposed to do with it? how do I
use it with the session method?

anne
Ad7805c9fcc1f13efc6ed11251a6c4d2?d=identicon&s=25 Alex Young (Guest)
on 2006-02-07 16:49
(Received via mailing list)
Anne G wrote:
> I wanted session to store the key to the stimulis table row
> being viewed in the Subjects table.
Ok...

> session[:runexp] ||= Subject.new
>
> where subjects is a table, subject.rb a model...
> that line causes an error
What's the error?  It looks OK to me.

> It turns out
> session[:runexp] ||= Subject.id
I very much doubt that's doing what you think it is, or what you want.
It's not doing anything to do with the database, for a start.

> does not give an error, so for now, I will just store single
> values in session.
>
> But what do I need to do so this session is stored
> in a database? Right now, I think it is stored in memory.
Uncomment this line in config/environment.rb:
   # config.action_controller.session_store = :active_record_store
and run rake create_sessions_table in the root directory of your app.

Now for the next question:  why do you want to store the session in the
database?  I think you might be trying to do something else, and might
have the terminology mixed up.  Apologies if that's not the case, but
worrying about where the session is stored is usually something that
gets dealt with later in the development cycle.

Feel free to email me off-list if you want.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.