{ Josh Rendek }

<3 Go & Kubernetes

Random Rumblings

Jul 11, 2009 - 1 minutes

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 “Join Strike Air Fighter Vehicle C++ Coding Standards”

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 job, you need to put RAILS_ENV=env /path/to/ruby etc…. in the command line for it to work (at least on CentOS)

Free Server Monitoring

Apr 14, 2009 - 1 minutes

Do you want free server monitoring with only one simple script to run via cron Tired of all the hassle of settings up other systems….

I’m launching a new website soon that does all this, if you would like to be invited to try it out shoot me an email at josh [ at ] bluescripts [dot] net

Since I have a cluster of 3 mongrels running behind lighttpd the usualy request.env[‘REMOTE_ADDR’] wasn’t working …

what ended up working was request.env[‘HTTP_X_FORWARDED_FOR’] to get the users IP

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 Clusters running an online food ordering system I wrote (MySQL + Rails)

Other than that there was nothing special. I’ve done no kernel tweaking or any other performance optimizations with Lighttpd or any other part of the system.

Result Data / Proxy Type / Result

Hash 21.41 Round-Robin 39.73 First 40.07

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).

Hash 467.20772 Round-Robin 251.725273 First 249.578092

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.

Hash 59.74 Round-Robin 110.84 First 111.79

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’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.

Hash 22795 Round-Robin 17132 First 11936

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.

Hash 1.15 Round-Robin 3.15 First 3.28

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 very miniscule increase in server load.

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’m assuming).

If you’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 HUGE differences I did notice was when running ab -n 1000 -c 10 the load would shoot up to 5, while Lighttpd’s would barely hit .89. I didn’t bother attempting ab -n 10000 -c 250 with apache since I didn’t want the box to melt/halt/be-killed-by-apache. If load isn’t an issue and you’re a die-hard Apache fan, stick with Phusion, but my tests put it way behind Lighttpd+Mongrel in comparison.

  1
  2If anyone has any suggestions for other analytic's to test let me know! I'd love to do some more research regarding this and post my findings since there seems to be a lack of them on google.
  3
  4<strong>Proxy: Hash Raw Data</strong>
  5
  6<pre>
  7Server Port:            80
  8
  9Document Path:          /
 10Document Length:        2495 bytes
 11
 12Concurrency Level:      250
 13Time taken for tests:   467.20772 seconds
 14Complete requests:      10000
 15Failed requests:        0
 16Write errors:           0
 17Total transferred:      28570261 bytes
 18HTML transferred:       24950000 bytes
 19Requests per second:    21.41 [#/sec] (mean)
 20Time per request:       11675.520 [ms] (mean)
 21Time per request:       46.702 [ms] (mean, across all concurrent requests)
 22Transfer rate:          59.74 [Kbytes/sec] received
 23
 24Connection Times (ms)
 25              min  mean[+/-sd] median   max
 26Connect:        0    0   3.2      0      35
 27Processing:    72 11547 1056.2  11694   22795
 28Waiting:       72 11547 1056.2  11694   22795
 29Total:         72 11548 1055.2  11694   22795
 30
 31Percentage of the requests served within a certain time (ms)
 32  50%  11694
 33  66%  11717
 34  75%  11739
 35  80%  11794
 36  90%  11887
 37  95%  11907
 38  98%  11928
 39  99%  11942
 40 100%  22795 (longest request)
 41</pre>
 42
 43<strong>Proxy Type: Round Robin Raw Data</strong>
 44<pre>
 45Server Port:            80
 46
 47Document Path:          /
 48Document Length:        2495 bytes
 49
 50Concurrency Level:      250
 51Time taken for tests:   251.725273 seconds
 52Complete requests:      10000
 53Failed requests:        0
 54Write errors:           0
 55Total transferred:      28570213 bytes
 56HTML transferred:       24950000 bytes
 57Requests per second:    39.73 [#/sec] (mean)
 58Time per request:       6293.132 [ms] (mean)
 59Time per request:       25.173 [ms] (mean, across all concurrent requests)
 60Transfer rate:          110.84 [Kbytes/sec] received
 61
 62Connection Times (ms)
 63              min  mean[+/-sd] median   max
 64Connect:        0    0   3.2      0      37
 65Processing:   103 6192 2439.0   6653   17132
 66Waiting:      103 6192 2439.0   6653   17132
 67Total:        103 6192 2438.5   6653   17132
 68
 69Percentage of the requests served within a certain time (ms)
 70  50%   6653
 71  66%   7665
 72  75%   8169
 73  80%   8495
 74  90%   9038
 75  95%  10066
 76  98%  10377
 77  99%  10468
 78 100%  17132 (longest request)
 79</pre>
 80
 81<strong>Proxy Type: First Raw Data</strong>
 82<pre>
 83--- Proxy: First 3.28 ---
 84Server Port:            80
 85
 86Document Path:          /
 87Document Length:        2495 bytes
 88
 89Concurrency Level:      250
 90Time taken for tests:   249.578092 seconds
 91Complete requests:      10000
 92Failed requests:        0
 93Write errors:           0
 94Total transferred:      28570190 bytes
 95HTML transferred:       24950000 bytes
 96Requests per second:    40.07 [#/sec] (mean)
 97Time per request:       6239.453 [ms] (mean)
 98Time per request:       24.958 [ms] (mean, across all concurrent requests)
 99Transfer rate:          111.79 [Kbytes/sec] received
100
101Connection Times (ms)
102              min  mean[+/-sd] median   max
103Connect:        0    0   3.3      0      37
104Processing:   307 6169 621.6   6256   11936
105Waiting:      306 6168 621.7   6256   11936
106Total:        307 6169 620.0   6256   11936
107
108Percentage of the requests served within a certain time (ms)
109  50%   6256
110  66%   6450
111  75%   6550
112  80%   6598
113  90%   6734
114  95%   6795
115  98%   6858
116  99%   6897
117 100%  11936 (longest request)
118</pre>

Random Ruby Rumblings

Mar 3, 2009 - 1 minutes

I’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(",") 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=“order[field_name]” name=“order[field_name_2]”

GOOD Code to do this: <% for c in @customize_this %> <%= form.check_box :"#{c}" %> <% end %>

However I had originally gotten name=“order[c]” name=“order[c]” - basically the same thing for all items in the list… The BAD code was this: <% for c in @customize_this %> <%= form.check_box :c %> <% end %>

Best place to read more about it: http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html

Case 1, links: Good: <%= link_to “#{item.name}”, :action => “customize”, :id => item.id %> Bad: <%= link_to “#{item.name}”, :action => “customize/#{item.id}” %>

Ruby & Ruby on Rails

Mar 2, 2009 - 1 minutes

I’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’: no such file to load – zlib (LoadError)

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.

Firefox Tunnel + MAC & Panera's Fail

Feb 22, 2009 - 1 minutes

ssh -ND 9999 [email protected]

Open firefox, network preferences under the Advanced tab, SOCKS proxy and set host to 127.0.0.1 and port 9999 close preferences and you’re all set to go.

– Addendum:

I was actually at Panera’s doing some work while I ate breakfast with a friend when I did this… I had planned on staying longer but apparently Panera’s doesn’t like customers buying lunch… I had planned on staying an additional bit past 12 to eat some lunch there but was promptly disconnected from the internet after 30 minutes of use (between 11:30AM and 1:30PM they block you after 30 minutes of WiFi).

Panera’s you’ve lost my business.

New Project! NoteCardApp.com

Feb 17, 2009 - 1 minutes

I made this over the weekend. For now it lets you register, create note cards, flip through them and mark whether you know them or not. I figured this would help out a few people and note cards / flash cards are always a good way to study.

Head on over and check it out! http://notecardapp.com/