<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BlueScripts &#187; rails</title>
	<atom:link href="http://bluescripts.net/tag/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://bluescripts.net</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 07 Jul 2010 16:42:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Simple alias for .bash_rc and script/generate</title>
		<link>http://bluescripts.net/2010/05/simple-alias-for-bash_rc-and-scriptgenerate/</link>
		<comments>http://bluescripts.net/2010/05/simple-alias-for-bash_rc-and-scriptgenerate/#comments</comments>
		<pubDate>Sat, 29 May 2010 07:40:39 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://bluescripts.net/2010/05/simple-alias-for-bash_rc-and-scriptgenerate/</guid>
		<description><![CDATA[Just add this to your bash_rc &#8230; quick easy way to access script/generate alias rg='script/generate']]></description>
			<content:encoded><![CDATA[<p>Just add this to your bash_rc &#8230; quick easy way to access script/generate</p>
<pre>alias rg='script/generate'</pre>
]]></content:encoded>
			<wfw:commentRss>http://bluescripts.net/2010/05/simple-alias-for-bash_rc-and-scriptgenerate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random Rumblings</title>
		<link>http://bluescripts.net/2009/07/random-rumblings/</link>
		<comments>http://bluescripts.net/2009/07/random-rumblings/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 04:59:21 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://bluescripts.net/2009/07/random-rumblings/</guid>
		<description><![CDATA[Was reading through my mailing lists and found this one in the Drizzle mailing list when talking about code styling for c++, pretty interesting read &#8220;Join Strike Air Fighter Vehicle C++ Coding Standards&#8221; http://www.research.att.com/~bs/JSF-AV-rules.pdf Another random musing when I was working on a rails project: Even if your using the default environment for a cron [...]]]></description>
			<content:encoded><![CDATA[<p>Was reading through my mailing lists and found this one in the Drizzle mailing list when talking about code styling for c++, pretty interesting read &#8220;Join Strike Air Fighter Vehicle C++ Coding Standards&#8221;</p>
<p><a href="http://www.research.att.com/~bs/JSF-AV-rules.pdf">http://www.research.att.com/~bs/JSF-AV-rules.pdf</a></p>
<p>Another random musing when I was working on a rails project:<br />
Even if your using the default environment for a cron job, you need to put RAILS_ENV=env /path/to/ruby etc&#8230;. in the command line for it to work (at least on CentOS)</p>
]]></content:encoded>
			<wfw:commentRss>http://bluescripts.net/2009/07/random-rumblings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails remote IP address from behind a proxy</title>
		<link>http://bluescripts.net/2009/03/rails-remote-ip-address-from-behind-a-proxy/</link>
		<comments>http://bluescripts.net/2009/03/rails-remote-ip-address-from-behind-a-proxy/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 19:54:54 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://bluescripts.net/2009/03/rails-remote-ip-address-from-behind-a-proxy/</guid>
		<description><![CDATA[Since I have a cluster of 3 mongrels running behind lighttpd the usualy request.env['REMOTE_ADDR'] wasn&#8217;t working &#8230; what ended up working was request.env['HTTP_X_FORWARDED_FOR'] to get the users IP]]></description>
			<content:encoded><![CDATA[<p>Since I have a cluster of 3 mongrels running behind lighttpd the usualy request.env['REMOTE_ADDR'] wasn&#8217;t working &#8230;</p>
<p>what ended up working was request.env['HTTP_X_FORWARDED_FOR'] to get the users IP</p>
]]></content:encoded>
			<wfw:commentRss>http://bluescripts.net/2009/03/rails-remote-ip-address-from-behind-a-proxy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Lighttpd, Mongrel, Ruby on Rails, and Lighttpd Proxy backend Performance Comparison</title>
		<link>http://bluescripts.net/2009/03/lighttpd-mongrel-ruby-on-rails-and-lighttpd-proxy-backend-performance-comparison/</link>
		<comments>http://bluescripts.net/2009/03/lighttpd-mongrel-ruby-on-rails-and-lighttpd-proxy-backend-performance-comparison/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 01:37:27 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[research]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[apache passenger]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[mod_rails]]></category>
		<category><![CDATA[mongrel]]></category>
		<category><![CDATA[performance lighttpd]]></category>
		<category><![CDATA[phusion]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://bluescripts.net/?p=188</guid>
		<description><![CDATA[First I was kind of surprised at the lack of performance comparisons people have made between the different lighttpd proxies with a rails/mongrel cluster backend and which ones would be best. Lets start off the the specs of the box: Intel Atom 330 CPU Standard 7,200RPM HDD CentOS 5.2 2GB Ram Lighttpd with 3 Mongrel [...]]]></description>
			<content:encoded><![CDATA[<p>First I was kind of surprised at the lack of performance comparisons people have made between the different lighttpd proxies with a rails/mongrel cluster backend and which ones would be best.</p>
<p>Lets start off the the specs of the box:<br />
Intel Atom 330 CPU<br />
Standard 7,200RPM HDD<br />
CentOS 5.2<br />
2GB Ram<br />
Lighttpd with 3 Mongrel Clusters running an online food ordering system I wrote (MySQL + Rails)</p>
<p>Other than that there was nothing special. I&#8217;ve done no kernel tweaking or any other performance optimizations with Lighttpd or any other part of the system.</p>
<p>Result Data	/ Proxy Type /	Result</p>
<h2>Requests Per Second</h2>
<p><a href="http://bluescripts.net/wp-content/uploads/2009/03/requests-per-second.png"><img class="alignnone size-full wp-image-189" title="requests-per-second lighttpd rails mongrel cluster" src="http://bluescripts.net/wp-content/uploads/2009/03/requests-per-second.png" alt="requests-per-second lighttpd rails mongrel cluster" width="451" height="271" /></a></p>
<p>Hash	       21.41<br />
Round-Robin	39.73<br />
First	40.07</p>
<p>Hash is the loser in the proxy test over all. The requests per second capabilities of it were nearly half of what Round-Robin and First were able to achieve with the 3 node mongrel cluster running in the background. This is to be expected though since the Hash algorithm (so far as I understand it) will send the same url requests to the same proxy to help caching, whereas round-robin and first proxy methods balance it over the 3 nodes (or however many you have running).</p>
<h2>Total Time Taken</h2>
<p><a href="http://bluescripts.net/wp-content/uploads/2009/03/time-taken.png"><img class="alignnone size-full wp-image-190" title="time-taken" src="http://bluescripts.net/wp-content/uploads/2009/03/time-taken.png" alt="time-taken" width="451" height="271" /></a></p>
<p>Hash 	467.20772<br />
Round-Robin	251.725273<br />
First	249.578092</p>
<p>Round-Robin are nearly neck and neck with the total time taken to return 10,000 hits with 250 concurrency, while the hash algorithm still lags far behind.</p>
<h2>Transfer Rate</h2>
<p><a href="http://bluescripts.net/wp-content/uploads/2009/03/transfer-rate.png"><img class="alignnone size-full wp-image-191" title="transfer-rate" src="http://bluescripts.net/wp-content/uploads/2009/03/transfer-rate.png" alt="transfer-rate" width="451" height="271" /></a></p>
<p>Hash 	59.74<br />
Round-Robin	110.84<br />
First	111.79</p>
<p>Since only one mongrel cluster is able to serve all the requests in Hash, where as 3 are able to in the Round Robin and First tests, the transfer rate is much higher. I&#8217;m sure this could have been improved even further had I put all static files like style sheets and images on a separate instance so Mongrel could just worry about the rails files instead of rails + static, but since this site only has about 5 or so images, I did not think it necessary.</p>
<h2>Longest Request</h2>
<p><a href="http://bluescripts.net/wp-content/uploads/2009/03/longest-request.png"><img class="alignnone size-full wp-image-192" title="longest-request" src="http://bluescripts.net/wp-content/uploads/2009/03/longest-request.png" alt="longest-request" width="451" height="271" /></a></p>
<p>Hash 	22795<br />
Round-Robin	17132<br />
First	11936</p>
<p>This is the result data where First comes through, beating Round Robin by a good portion (~6 seconds) and proving to be the quickest to serve up the website.</p>
<h2>Load Averages</h2>
<p><a href="http://bluescripts.net/wp-content/uploads/2009/03/load-avg.png"><img class="alignnone size-full wp-image-193" title="load-avg" src="http://bluescripts.net/wp-content/uploads/2009/03/load-avg.png" alt="load-avg" width="451" height="271" /></a></p>
<p>Hash 	1.15<br />
Round-Robin	3.15<br />
First	3.28</p>
<p>Since Hash is only using one mongrel cluster instance, instead of the 3, the CPU load was much lower. However, Round Robin and First were very close, but I believe that when comparing the request times for First and Round Robin, First is worth the <em>very</em> miniscule increase in server load.</p>
<h3>Notes on Apache + Passenger + Mod_Rails + Phusion mumbo jumbo</h3>
<p>I&#8217;m not going to claim to be an Apache expert, but one thing I&#8217;m positive about is Apache&#8217;s slowness&#8230;. with everything. I go nuts when pages don&#8217;t load fast because of server software and when I tried out Phusion Passenger / Mod Rails and apache (whatever you want to call it)&#8230; even with Enterprise ruby installed, it was still incredibly slow (noticable to me while just randomly hitting refresh).</p>
<p>While Phusion makes deploying rails apps a bit simpler / easier to add new apps, in the long run I view it as detrimental should your application ever grow. The reason I chose to work with mongrel and Lighttpd (although Nginx is another viable option) is because I looked at sites like GitHub and EngineYard (a large rails host) and checked a few of their web server headers and found them to be running Nginx (with a Mongrel backend I&#8217;m assuming).</p>
<p>If you&#8217;re worried about memory I did not notice much of a difference between what my application used while in Phusion vs Mongrel, but one of the <span style="text-decoration: underline;"><strong>HUGE</strong></span> differences I did notice was when running `ab -n 1000 -c 10` the load would shoot up to 5, while Lighttpd&#8217;s would barely hit .89. I didn&#8217;t bother attempting `ab -n 10000 -c 250` with apache since I didn&#8217;t want the box to melt/halt/be-killed-by-apache. If load isn&#8217;t an issue and you&#8217;re a die-hard Apache fan, stick with Phusion, but my tests put it <em>way</em> behind Lighttpd+Mongrel in comparison.</p>
<p>~~~~~~~~~~~~~~~~~~~~</p>
<p>If anyone has any suggestions for other analytic&#8217;s to test let me know! I&#8217;d love to do some more research regarding this and post my findings since there seems to be a lack of them on google.</p>
<p><strong>Proxy: Hash Raw Data</strong></p>
<pre>
Server Port:            80

Document Path:          /
Document Length:        2495 bytes

Concurrency Level:      250
Time taken for tests:   467.20772 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      28570261 bytes
HTML transferred:       24950000 bytes
Requests per second:    21.41 [#/sec] (mean)
Time per request:       11675.520 [ms] (mean)
Time per request:       46.702 [ms] (mean, across all concurrent requests)
Transfer rate:          59.74 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   3.2      0      35
Processing:    72 11547 1056.2  11694   22795
Waiting:       72 11547 1056.2  11694   22795
Total:         72 11548 1055.2  11694   22795

Percentage of the requests served within a certain time (ms)
  50%  11694
  66%  11717
  75%  11739
  80%  11794
  90%  11887
  95%  11907
  98%  11928
  99%  11942
 100%  22795 (longest request)
</pre>
<p><strong>Proxy Type: Round Robin Raw Data</strong></p>
<pre>
Server Port:            80

Document Path:          /
Document Length:        2495 bytes

Concurrency Level:      250
Time taken for tests:   251.725273 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      28570213 bytes
HTML transferred:       24950000 bytes
Requests per second:    39.73 [#/sec] (mean)
Time per request:       6293.132 [ms] (mean)
Time per request:       25.173 [ms] (mean, across all concurrent requests)
Transfer rate:          110.84 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   3.2      0      37
Processing:   103 6192 2439.0   6653   17132
Waiting:      103 6192 2439.0   6653   17132
Total:        103 6192 2438.5   6653   17132

Percentage of the requests served within a certain time (ms)
  50%   6653
  66%   7665
  75%   8169
  80%   8495
  90%   9038
  95%  10066
  98%  10377
  99%  10468
 100%  17132 (longest request)
</pre>
<p><strong>Proxy Type: First Raw Data</strong></p>
<pre>
--- Proxy: First 3.28 ---
Server Port:            80

Document Path:          /
Document Length:        2495 bytes

Concurrency Level:      250
Time taken for tests:   249.578092 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      28570190 bytes
HTML transferred:       24950000 bytes
Requests per second:    40.07 [#/sec] (mean)
Time per request:       6239.453 [ms] (mean)
Time per request:       24.958 [ms] (mean, across all concurrent requests)
Transfer rate:          111.79 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   3.3      0      37
Processing:   307 6169 621.6   6256   11936
Waiting:      306 6168 621.7   6256   11936
Total:        307 6169 620.0   6256   11936

Percentage of the requests served within a certain time (ms)
  50%   6256
  66%   6450
  75%   6550
  80%   6598
  90%   6734
  95%   6795
  98%   6858
  99%   6897
 100%  11936 (longest request)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://bluescripts.net/2009/03/lighttpd-mongrel-ruby-on-rails-and-lighttpd-proxy-backend-performance-comparison/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Random Ruby Rumblings</title>
		<link>http://bluescripts.net/2009/03/random-ruby-rumblings/</link>
		<comments>http://bluescripts.net/2009/03/random-ruby-rumblings/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 02:02:16 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://bluescripts.net/2009/03/random-ruby-rumblings/</guid>
		<description><![CDATA[I&#8217;m going to keep updating this post as I make some more findings about Rails that I think are pretty good assumptions a newbie should learn about: Case 2, forms: I made an array using split(&#8220;,&#8221;) in the controller, then in the view I was looping through and could puts them out fine, however the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to keep updating this post as I make some more findings about Rails that I think are pretty good assumptions a newbie should learn about:</p>
<p><strong>Case 2, forms: </strong><br />
I made an array using split(&#8220;,&#8221;) in the controller, then in the view I was looping through and could puts them out fine, however the ultimate goal was to use them in a form. Basically I needed it to be name=&#8221;order[field_name]&#8221; name=&#8221;order[field_name_2]&#8221;</p>
<p>GOOD Code to do this:<br />
<% for c in @customize_this %><br />
		<%= form.check_box :"#{c}" %><br />
<% end %></p>
<p>However I had originally gotten name=&#8221;order[c]&#8221; name=&#8221;order[c]&#8221; &#8211; basically the same thing for all items in the list&#8230;<br />
The BAD code was this:<br />
<% for c in @customize_this %><br />
		<%= form.check_box :c %><br />
<% end %></p>
<p>Best place to read more about it: <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html">http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html</a></p>
<p><strong>Case 1, links:</strong><br />
Good: <b><%= link_to "#{item.name}", :action => &#8220;customize&#8221;, :id => item.id %></b><br />
Bad: 			<b><%= link_to "#{item.name}", :action => &#8220;customize/#{item.id}&#8221; %></b></p>
]]></content:encoded>
			<wfw:commentRss>http://bluescripts.net/2009/03/random-ruby-rumblings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby &amp; Ruby on Rails</title>
		<link>http://bluescripts.net/2009/03/ruby-ruby-on-rails/</link>
		<comments>http://bluescripts.net/2009/03/ruby-ruby-on-rails/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 03:04:41 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://bluescripts.net/2009/03/ruby-ruby-on-rails/</guid>
		<description><![CDATA[I&#8217;ve decided to finally tackle learning rails by developing my next project in it. However I was setting up Ruby/Rails when trying to run gem install rails returned this error: /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require&#8217;: no such file to load &#8212; zlib (LoadError) After I ran yum install zlib* and hit yes to the devel libraries, went back [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve decided to finally tackle learning rails by developing my next project in it.</p>
<p>However I was setting up Ruby/Rails when trying to run gem install rails returned this error:</p>
<p>/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in<br />
`gem_original_require&#8217;: no such file to load &#8212; zlib (LoadError)</p>
<p>After I ran yum install zlib* and hit yes to the devel libraries, went back to ruby source, did make clean, ./configure, make, make install then switched to the ruby gem source and ran ruby setup.rb and then gem install rails worked fine.</p>
]]></content:encoded>
			<wfw:commentRss>http://bluescripts.net/2009/03/ruby-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
