Home
RVM - System Wide Installs and Capistrano Integration
If you install RVM on server, mostly probably will choose run as System wide, since there is more than one account will use ruby. then the problem is when you use Capistrano deploy your application it will also say: can't find bundle, although you've installed the ruby on your server.
So you need to add below lines to your deploy.rb file.
require "bundler/capistrano"
$:.unshift(File.expand_path("./lib", ENV["rvm_path"]))
require 'rvm/capistrano' set :rvm_ruby_string, 'some-ruby-version' # Defaults to 'default' set :rvm_type, :system or :user set :rvm_bin_path, "xxx"Then when you run command on server you can do like this:
run "cd #{release_path}; bundle install"Doesn't need do like:
run "cd #{release_path}; /full/path/to/bundle install"You also can use: cap shell to test it out if it is possible to run the command on different server. Reference article: http://blog.ninjahideout.com/posts/rvm-system-wide-installs-and-capistrano-integration
18 Feb 2012
EventMachine VS Node.js performance
Test environment:
Macbook pro:
2.3GHz Intel Core i5
8 GB 1333 MHz DDR3
Both sample code is helloworld.
Test 1:
Command used to test
httperf --server=127.0.0.1 --port=3000 --uri=/ --num-conns=1000 --num-calls=1
EventMachine performance:
Total: connections 1000 requests 1000 replies 1000 test-duration 0.161 s
Connection rate: 6229.2 conn/s (0.2 ms/conn, <=1 concurrent connections)
Connection time [ms]: min 0.1 avg 0.2 max 0.4 median 0.5 stddev 0.0
Connection time [ms]: connect 0.1
Connection length [replies/conn]: 1.000
Request rate: 6229.2 req/s (0.2 ms/req)
Request size [B]: 62.0
Reply rate [replies/s]: min 0.0 avg 0.0 max 0.0 stddev 0.0 (0 samples)
Reply time [ms]: response 0.1 transfer 0.0
Reply size [B]: header 40.0 content 12.0 footer 0.0 (total 52.0)
Reply status: 1xx=0 2xx=1000 3xx=0 4xx=0 5xx=0
CPU time [s]: user 0.02 system 0.14 (user 13.4% system 86.3% total 99.6%)
Net I/O: 693.5 KB/s (5.7*10^6 bps)
Node.js performance:
Total: connections 1000 requests 1000 replies 1000 test-duration 0.192 s
Connection rate: 5195.2 conn/s (0.2 ms/conn, <=1 concurrent connections)
Connection time [ms]: min 0.2 avg 0.2 max 0.5 median 0.5 stddev 0.0
Connection time [ms]: connect 0.1
Connection length [replies/conn]: 1.000
Request rate: 5195.2 req/s (0.2 ms/req)
Request size [B]: 62.0
Reply rate [replies/s]: min 0.0 avg 0.0 max 0.0 stddev 0.0 (0 samples)
Reply time [ms]: response 0.1 transfer 0.0
Reply size [B]: header 97.0 content 12.0 footer 2.0 (total 111.0)
Reply status: 1xx=0 2xx=1000 3xx=0 4xx=0 5xx=0
CPU time [s]: user 0.03 system 0.17 (user 13.9% system 86.0% total 99.9%)
Net I/O: 867.6 KB/s (7.1*10^6 bps)
Test 2:
Command used to test
httperf --server=127.0.0.1 --port=3000 --uri=/ --num-conns=1000 --num-calls=100
EventMachine performance:
Total: connections 10000 requests 10000 replies 10000 test-duration 1.031 s
Connection rate: *9701.9* conn/s (0.1 ms/conn, <=1 concurrent connections)
Connection time [ms]: min 0.0 avg 0.1 max 13.9 median 0.5 stddev 0.3
Connection time [ms]: connect 0.0
Connection length [replies/conn]: 1.000
Request rate: 9701.9 req/s (0.1 ms/req)
Request size [B]: 62.0
Reply rate [replies/s]: min 0.0 avg 0.0 max 0.0 stddev 0.0 (0 samples)
Reply time [ms]: response 0.1 transfer 0.0
Reply size [B]: header 40.0 content 12.0 footer 0.0 (total 52.0)
Reply status: 1xx=0 2xx=10000 3xx=0 4xx=0 5xx=0
CPU time [s]: user 0.22 system 0.80 (user 21.3% system 77.6% total 99.0%)
Net I/O: 1080.1 KB/s (8.8*10^6 bps)
Node.js performance:
Total: connections 10000 requests 10000 replies 10000 test-duration 1.606 s
Connection rate: *6227.7* conn/s (0.2 ms/conn, <=1 concurrent connections)
Connection time [ms]: min 0.1 avg 0.2 max 5.8 median 0.5 stddev 0.1
Connection time [ms]: connect 0.0
Connection length [replies/conn]: 1.000
Request rate: 6227.7 req/s (0.2 ms/req)
Request size [B]: 62.0
Reply rate [replies/s]: min 0.0 avg 0.0 max 0.0 stddev 0.0 (0 samples)
Reply time [ms]: response 0.1 transfer 0.0
Reply size [B]: header 97.0 content 12.0 footer 2.0 (total 111.0)
Reply status: 1xx=0 2xx=10000 3xx=0 4xx=0 5xx=0
CPU time [s]: user 0.33 system 1.27 (user 20.6% system 79.1% total 99.6%)
Net I/O: 1040.0 KB/s (8.5*10^6 bps)
Conclusion:
EventMachine's concurrent processing ability is stronger than Node.js 50%.
When request num up, Node.js's connection rate goes down.
11 Feb 2012
Modernizr - Loading javascript and css parallelly
A library could load javascript and css async and parallel. and also and can judge the feature existance of browser.
And this one looks good also.
http://www.andresvidal.com/jsl
1
2
3
4
5
6
7
8
jsl.add("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js", -1);
jsl.add("http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.3/jquery-ui.min.js", 1);
//in this example, this loads in 0 position
jsl.add("http://mysite.com/js/global.js");
//needs jQuery and jQueryUI first
jsl.add("http://mysite.com/js/jqueryscripts.js", 2);
jsl.add("http://mysite.com/js/plugins.js", 3);
jsl.load();
31 Jan 2012
JavaScript number-to-string conversion
JavaScript number-to-string conversion.
a = a+'' // This converts a to string b += '' // This converts b to string 5.41 + '' // Result: the string '5.41' Math.PI + '' // Result: the string '3.141592653589793'Another way:
a = a.toString() // This converts a to string b = b.toString() // This converts b to string (5.41).toString() // Result: the string '5.41' (Math.PI).toString() // Result: the string '3.141592653589793'
31 Jan 2012