I'm guessing this is because each Apache process has its own Ruby 
interpreter instance:

The following code inside a mod_ruby script does not always increment 
$total displayed in the browser (it actually increments $total 
internally, but each time the page is refreshed, the next Apache process 
is used in seemingly round-robin fashion):

-----
if defined?($total)
     $total = $total + 1
else
     $total = 0
end
puts "total = #{$total}"
-----

Does anyone know the simplest way to deal with this other than using 
persistent storage like database or file?