<?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>Zownir Enterprises &#187; WebFaction</title>
	<atom:link href="http://zownir.net/tag/webfaction/feed" rel="self" type="application/rss+xml" />
	<link>http://zownir.net</link>
	<description></description>
	<lastBuildDate>Mon, 10 May 2010 09:02:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Rails Deployment Options</title>
		<link>http://zownir.net/2008/06/19/rails-deployment-options</link>
		<comments>http://zownir.net/2008/06/19/rails-deployment-options#comments</comments>
		<pubDate>Fri, 20 Jun 2008 02:45:00 +0000</pubDate>
		<dc:creator>Ronnie Zownir</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Passenger]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[WebFaction]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[There are quite a number of deployment options for Rails these days. You have a choice on a variety of things and the list of options is ever expanding. What follows is my short list: Ruby Virtual Machine Several Ruby implementations can run Rails. Others cannot. The ability to run Rails is a major achievement [...]]]></description>
			<content:encoded><![CDATA[<p>There are quite a number of deployment options for Rails these days. You have a choice on a variety of things and the list of options is ever expanding. What follows is my <em>short</em> list:</p>
<h3>Ruby Virtual Machine</h3>
<p>Several Ruby implementations can run Rails. Others cannot. The ability to run Rails is a major achievement for alternative Ruby VMs. For detailed comparisons check out Antonio Cangiano’s <a href="http://antoniocangiano.com/">blog</a>. He does the Ruby <a href="http://antoniocangiano.com/2007/12/03/the-great-ruby-shootout/">shootout</a>.</p>
<ul>
<li><a href="http://www.ruby-lang.org/en/downloads/">MRI</a>
<ul>
<li>1.8 standard</li>
<li>Ruby 1.8.6 is the <a href="http://www.rubyonrails.org/down">recommended</a> version to run Rails on</li>
</ul>
</li>
<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/1.9/">YARV</a>
<ul>
<li>1.9 standard</li>
<li>Significantly faster than MRI</li>
<li>Rails is not yet fully compatible with Ruby 1.9</li>
<li>Many gems are not compatible with Ruby 1.9</li>
</ul>
</li>
<li><a href="http://www.jruby.org/">JRuby</a>
<ul>
<li>Java implementation of Ruby</li>
<li>Runs Rails</li>
</ul>
</li>
<li><a href="http://rubini.us/">Rubinius</a>
<ul>
<li>“Ruby in Ruby”</li>
<li>Runs Rails</li>
</ul>
</li>
<li><a href="http://www.rubyenterpriseedition.com/">Ruby Enterprise Edition</a>
<ul>
<li>From the creators of mod_rails</li>
<li>Fork of MRI</li>
<li>33% less memory consumption on average when used with mod_rails</li>
</ul>
</li>
<li><a href="http://ruby.gemstone.com/">MagLev</a>
<ul>
<li>Commercial</li>
<li>Pending release</li>
<li>Lots of promise in terms of performance and features, but won’t run Rails for some time</li>
</ul>
</li>
</ul>
<p>For critical production applications, there are really only two implementations you should consider. If you are using mod_rails, go with Ruby Enterprise Edition. Otherwise, the standard Ruby implementation, MRI, is the way to go. The other implementations are progressing rapidly and in time <em>will</em> be good to go for production.</p>
<h3>Server Configuration</h3>
<p>There is much activity in this area. These are the choices worth noting:</p>
<ul>
<li><a href="http://nginx.net/">nginx</a> + <a href="http://mongrel.rubyforge.org/">mongrel</a> | <a href="http://code.macournoyer.com/thin/">thin</a> | <a href="http://ebb.rubyforge.org/">ebb</a> | <a href="http://fuzed.rubyforge.org/">fuzed (yaws)</a>
<ul>
<li>nginx is a powerful lightweight frontend server/reverse proxy/load balancer that can take a licking and keep on ticking</li>
<li>mongrel is the veteran backend web server for Ruby on Rails</li>
<li>thin is an evented backend server that’s faster than mongrel and supports unix socket connections</li>
<li>ebb is an evented backend server written in C that’s faster than thin and also supports unix socket connections, but it uses more memory than thin while idling</li>
<li>fuzed allows Rails to be served up by yaws, a server written in Erlang that provides an unparalleled degree of concurrency</li>
</ul>
</li>
<li><a href="http://httpd.apache.org/">Apache</a> + <a href="http://www.modrails.com/">Passenger (mod_rails)</a> + <a href="http://www.rubyenterpriseedition.com/">Ruby Enterprise Edition</a>
<ul>
<li>New and exciting deployment option for Apache</li>
<li>Easy to setup</li>
<li>Deploying an app can be as simple is uploading your app</li>
<li>mod_rails and Ruby Enterprise Edition, both developed by <a href="http://phusion.nl/about.html">Phusion</a>, together provide a 33% lower memory footprint (for Rails) on average</li>
<li>Integrated monitoring and load balancing – monitors Rails processes and starts/kills them as necessary based on demand</li>
</ul>
</li>
<li><a href="http://litespeedtech.com/">LiteSpeed</a>
<ul>
<li>Commercial</li>
<li>Relatively easy to setup</li>
<li>Better performance than most other solutions</li>
<li>Despite its qualities, not amazingly popular</li>
</ul>
</li>
</ul>
<p>I only mention LiteSpeed because of its performance. Few people actually use it for serious Rails deployments. I omitted lighttpd from the list because nginx has stolen the show. Ancient solutions like fastcgi were also omitted.</p>
<p>I personally use nginx + thin. I have not transitioned to ebb because of higher memory consumption (at least on the low end). I included the fuzed project in my list because I find yaws and Erlang fascinating. Yaws puts Apache to <a href="http://www.sics.se/~joe/apachevsyaws.html">shame</a> when it comes to concurrency. I’m not sure how polished the fuzed project is, but it looks like a contender to me! It’s also good to see cooperation between Ruby and Erlang. Mongrel, thin, and ebb are all good options. It all depends on your needs and preferences.</p>
<p>I have not tried out mod_rails. It is being touted as a breakthrough solution because of how simple it makes deployment. Not to take anything away from it, but my impression is that it is more for deployment novices and people with shared hosting provided by operations like <a href="http://blog.dreamhost.com/2008/05/13/passenger-for-ruby-on-rails/">DreamHost</a>. With <a href="http://www.webfaction.com/?affiliate=rzownir"><strong>WebFaction</strong></a>, you have the freedom and ability to build your own stack. I’ve made this a breeze with a shake and bake <a href="http://blog.princetonapps.com/articles/2008/04/11/ruby-on-rails-stack-on-webfaction">shell script</a>. Nginx is a better frontend server than Apache in its ability to serve static pages and with regard to memory usage. What would be great is if mongrel/thin/ebb could take advantage of the memory saving features of Ruby Enterprise Edition. I’m sure that the mod_ruby solution is outstanding. I will check it out for myself and report.</p>
<h3>Load Balancing</h3>
<p>Load balancing allows your applications to scale horizontally.</p>
<ul>
<li>Hardware
<ul>
<li>For very large applications</li>
<li>Most advanced</li>
<li>Expensive</li>
</ul>
</li>
<li><a href="http://haproxy.1wt.eu/">HAProxy</a>
<ul>
<li>For large applications</li>
<li>Very advanced</li>
<li>Very difficult to setup</li>
</ul>
</li>
<li><a href="http://github.com/gnosek/nginx-upstream-fair/tree/master">nginx-upstream-fair</a>
<ul>
<li>Third party module for nginx</li>
<li>Adds fair load balancing to nginx (replaces standard round-robin load balancing)</li>
<li>Very simple to setup</li>
<li>Small to large applications</li>
</ul>
</li>
</ul>
<p>I use the nginx-upstream-fair module for load balancing. Written by Grzegorz Nosek, the module works very well and is so easy to setup that there is no reason not to do so.</p>
<h3>Monitoring</h3>
<p>To make sure that your processes are behaving, you need a process monitor.</p>
<ul>
<li><a href="http://www.tildeslash.com/monit/">monit</a></li>
<li><a href="http://god.rubyforge.org/">god gem</a></li>
</ul>
<p>I use monit. I haven’t tried the god gem, but I’ve heard good things.</p>
]]></content:encoded>
			<wfw:commentRss>http://zownir.net/2008/06/19/rails-deployment-options/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails Stack on WebFaction</title>
		<link>http://zownir.net/2008/04/11/ruby-on-rails-stack-on-webfaction</link>
		<comments>http://zownir.net/2008/04/11/ruby-on-rails-stack-on-webfaction#comments</comments>
		<pubDate>Fri, 11 Apr 2008 16:53:00 +0000</pubDate>
		<dc:creator>Ronnie Zownir</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[WebFaction]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I&#8217;ve created a shell script to build a complete Ruby on Rails stack (application environment) on WebFaction. Although written with WebFaction users in mind, apart from a few minor details, the script is actually generally applicable. All you have to do is edit a few variable assignments (install path, rails app name, and service ports) [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve created a shell script to build a complete <strong>Ruby on Rails</strong> stack (application environment) on <strong><a href="http://www.webfaction.com/?affiliate=rzownir">WebFaction</a></strong>. Although written with <a href="http://www.webfaction.com/?affiliate=rzownir">WebFaction</a> users in mind, apart from a few minor details, the script is actually generally applicable. All you have to do is edit a few variable assignments (install path, rails app name, and service ports) at the beginning of the script and execute. In less than 20 minutes, your rails app will be up and running with nginx reverse proxying (and fair load balancing) to a pair of thin servers and with monit keeping watch.</p>
<p>In case you&#8217;re unfamiliar with <a href="http://code.macournoyer.com/thin/">thin</a>, it&#8217;s the likely successor to mongrel. It uses mongrel&#8217;s excellent http parser, provides various overall enhancements, and offers a number of features mongrel lacks. I specifically chose to use thin on <a href="http://www.webfaction.com/?affiliate=rzownir">WebFaction</a> because of its support for unix socket listeners. For more technical information, see the comments in the script and the accompanying README.markdown file.</p>
<p>What you get:</p>
<ul>
<li>Ruby</li>
<li>RubyGems</li>
<li>Gems: rails, merb, mongrel, mongrel_cluster, thin, capistrano, termios, ferret, acts_as_ferret, god, sqlite3-ruby, mysql, and typo</li>
<li>Git</li>
<li>Nginx (with nginx-upstream-fair third party module)</li>
<li>Monit</li>
<li>Startup scripts and working default configuration files for nginx and monit</li>
</ul>
<p>UPDATE: New script with Passenger on nginx!</p>
<p>I will try to keep this script reasonably up to date at <a href="http://github.com/rzownir/webfaction-rails-environment/tree/master">GitHub</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://zownir.net/2008/04/11/ruby-on-rails-stack-on-webfaction/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>mongrel_cluster with Nonconsecutive Ports</title>
		<link>http://zownir.net/2008/03/15/mongrel_cluster-with-nonconsecutive-ports</link>
		<comments>http://zownir.net/2008/03/15/mongrel_cluster-with-nonconsecutive-ports#comments</comments>
		<pubDate>Sun, 16 Mar 2008 02:30:00 +0000</pubDate>
		<dc:creator>Ronnie Zownir</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Mongrel]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[WebFaction]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Need to operate mongrel_cluster with nonconsecutive ports? No problem. WebFaction assigns ports to its users through the control panel. By design, the panel assigns ports in such a way that users hoping to officially stake claim to a consecutive block of ports are out of luck. Ports that the panel intentionally does not assign can [...]]]></description>
			<content:encoded><![CDATA[<p>Need to operate <code>mongrel_cluster</code> with nonconsecutive ports? No problem.</p>
<p><a href="http://www.webfaction.com?affiliate=rzownir">WebFaction</a> assigns ports to its users through the control panel. By design, the panel assigns ports in such a way that users hoping to officially stake claim to a consecutive block of ports are out of luck. Ports that the panel intentionally does not assign can be put to use, but let us suppose that this practice is frowned upon. If you are interested in running <code>mongrel_cluster</code>, walking the line requires a little bit of effort. Out of the box, <code>mongrel_cluster</code> spawns <code>mongrel_rails</code> listeners on consecutive ports. Configuration is limited to specifying the first port and the number of instances. The situation outlined requires a more precise port configuration and that in turn requires modification the the <code>mongrel_cluster</code> code. Luckily, this modification comes down to a one line addition.</p>
<p>The file requiring modification is <code>lib/mongrel_cluster/init.rb</code> inside the <code>mongrel_cluster</code> gem directory. The easiest way to find and open this file for editing is to execute the following command:</p>
<pre><code>nano `locate lib/mongrel_cluster/init.rb`
</code></pre>
<p>Locate the <code>read_options</code> method. In version 1.0.5, it should read:</p>
<pre><code>def read_options
    @options = {
        "environment" =&gt; ENV['RAILS_ENV'] || "development",
        "port" =&gt; 3000,
        "pid_file" =&gt; "tmp/pids/mongrel.pid",
        "log_file" =&gt; "log/mongrel.log",
        "servers" =&gt; 2
    }
    conf = YAML.load_file(@config_file)
    @options.merge! conf if conf

    process_pid_file @options["pid_file"]
    process_log_file @options["log_file"]

    start_port = end_port = @only
    start_port ||=  @options["port"].to_i
    end_port ||=  start_port + @options["servers"] - 1
    @ports = (start_port..end_port).to_a
end
</code></pre>
<p>Add the following line to the end of the method:</p>
<pre><code>@ports = @options["ports"] if @options["ports"] &amp;&amp; !@only
</code></pre>
<p>What this addition does is acknowledge a parameter named &#8216;ports&#8217; in <code>config/mongrel_cluster.yml</code>. Unless a single port is specified on the command line using the <code>--only</code> option, &#8216;ports&#8217; will be respected over the &#8216;port&#8217; and &#8216;servers&#8217; parameters used to specify a continuous range. The &#8216;ports&#8217; parameter should be accompanied by an array of integers in YAML format. An example <code>mongrel_cluster.yml</code> file that defines nonconsecutive ports follows:</p>
<pre><code>---
cwd: /home/user/webapps/railsapp
environment: production
user: user
group: user
address: 127.0.0.1
log_file: log/mongrel.log
pid_file: tmp/pids/mongrel.pid
ports:
- 3333
- 3335
- 3359
- 3401
</code></pre>
<p>The one line addition does not allow you to define discontinuous ports on the command line. You must edit <code>mongrel_cluster.yml</code> to do so. This is merely a matter of convenience and has no operational impact whatsoever.</p>
]]></content:encoded>
			<wfw:commentRss>http://zownir.net/2008/03/15/mongrel_cluster-with-nonconsecutive-ports/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH Public Key Authentication</title>
		<link>http://zownir.net/2008/02/26/ssh-public-key-authentication</link>
		<comments>http://zownir.net/2008/02/26/ssh-public-key-authentication#comments</comments>
		<pubDate>Wed, 27 Feb 2008 03:54:00 +0000</pubDate>
		<dc:creator>Ronnie Zownir</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[MacBook]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[WebFaction]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[If you use ssh a lot, you should really take the time to learn about public key authentication. It is more secure than password based authentication and with the help of ssh-agent, there is no need to enter a passphrase on each and every login. Setup is well worth the effort. I use public key [...]]]></description>
			<content:encoded><![CDATA[<p>If you use ssh a lot, you should really take the time to learn about public key authentication. It is more secure than password based authentication and with the help of ssh-agent, there is no need to enter a passphrase on each and every login. Setup is well worth the effort. I use public key authentication to ssh into my <a href="http://www.webfaction.com?affiliate=rzownir">WebFaction</a> shell account from my Macbook. The following instructions document how I set that up.</p>
<h3>Instructions</h3>
<h4>~/.ssh Directory Creation</h4>
<p>User specific ssh data is stored in the <code>~/.ssh</code> directory. On both the client and the server execute:</p>
<pre><code>mkdir ~/.ssh
chmod 700 ~/.ssh
</code></pre>
<p>If the directory already exists, make sure that the permissions are set to 700 (<code>rwx------</code>).</p>
<h4>Key Pair Generation</h4>
<p>Create the key pair on the client with:</p>
<pre><code>ssh-keygen -q -f ~/.ssh/id_rsa -t rsa
</code></pre>
<p>Enter a passphrase when asked. It should be at least 16 characters long and not your account password.</p>
<h4>Public Half Key Dissemination</h4>
<p>Upload id_rsa.pub to the server with:</p>
<pre><code>scp ~/.ssh/id_rsa.pub username@remote-machine:~/.ssh/
</code></pre>
<p>Replace <code>username</code> and <code>remote-machine</code> accordingly.</p>
<p>The public key data must be appended into the <code>~/.ssh/authorized_keys</code> file on the server:</p>
<pre><code>cat ~/id_rsa.pub &gt;&gt; ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
rm ~/.ssh/id_rsa.pub
</code></pre>
<h4>SSH into Remote Machine</h4>
<p>The first time you ssh into the remote machine from the client, execute:</p>
<pre><code>ssh -o PreferredAuthentications=publickey username@remote-machine
</code></pre>
<p>Again, replace <code>username</code> and <code>remote-machine</code> accordingly. You will be asked to enter your passphrase.</p>
<h4>Passphrase Tedium</h4>
<p>Entering the private key passphrase each time you ssh into the remote machine can drive you nuts. If you are using Mac OS X 10.5 (Leopard), you have the option to save the passphrase in the Apple Keychain at the passphrase prompt. This feature isn&#8217;t available in Mac OS X 10.4 (Tiger) and lower. However, <a href="http://www.sshkeychain.org/">SSHKeychain</a> gives you similar functionality. If your using another Unix-like system, check out the first resource below.</p>
<h4>SSHKeychain Primer</h4>
<p>I have a number of iMac G3s that I still use regularly. There is no out of the box keychain integration with Mac OS X 10.4 (Tiger), so I decided I would try out SSHKeychain. Setting up SSHKeychain was a little confusing at first, so I&#8217;ll explain the basics here.</p>
<p>There is nothing special about installation, although an installer is involved rather than a simple drag-and-drop action. Once installed, open up SSHKeychain from the Applications directory. Open up the Preferences dialog box. You can do this three ways. You can click &#8220;SSHKeychain&#8221; at the top left of the menubar and select &#8220;Preferences&#8230;&#8221;, click the keychain icon at the top right of the menubar and select &#8220;Preferences&#8230;&#8221;, or right click/click and hold the icon in the dock and select &#8220;Preferences&#8230;&#8221;. Select the &#8220;Environment&#8221; tab and check the &#8220;Manage (and modify) global environment variables&#8221;. (That&#8217;s what I missed at first.) Select the &#8220;SSH Keys&#8221; tab and remove the default values using the minus sign button (unless those private keys actually do exist).  Select the plus sign button and enter the full path of the private key you just created. For example: <code>/Users/username/.ssh/id_rsa</code>. Close the Preferences dialog box, and click &#8220;Agent&#8221; and select &#8220;Add all keys&#8230;&#8221;. You can find &#8220;Agent&#8221; on the menubar or the dock menu. You will be prompted for the private key passphrase and have the option to add the passphrase to the Apple keychain. I had a problem typing in the entire passphrase in the password field. I solved this by typing it in my favorite text editor and doing a copy and paste. If you have to do this, make sure to copy meaningless text afterward. You really don&#8217;t want your passphrase to be exposed on the clipboard for any significant length of time. Before you ssh into your servers using public key authentication managed by SSHKeychain, restart your computer. It should work nicely afterward. There is much more you can do with SSHKeychain, but the aforementioned should get you going along.</p>
<h4>Disabling Standard Password Authentication</h4>
<p>You may want to make it so that only public key authentication can be used to login to a remote machine using ssh. Check out the second resource for more information.</p>
<h3>Other Resources</h3>
<ul>
<li><a href="http://sial.org/howto/openssh/publickey-auth/">OpenSSH Public Key Authentication</a></li>
<li><a href="http://www.debuntu.org/ssh-key-based-authentication">Secure your SSH server with Public/Private key authentification</a></li>
<li><a href="http://www.dribin.org/dave/blog/archives/2007/11/28/securing_ssh_agent/">Securing ssh-agent on Mac OS X 10.5 (Leopard)</a></li>
<li><a href="http://www.sshkeychain.org/mirrors/SSH-with-Keys-HOWTO/">SSH with Keys HOWTO</a></li>
<li><a href="http://www.extrapepperoni.com/2007/03/24/tcossh-public-key-authentication/">Take Controll of SSH, Draft Excerpt: Public Key Authentication</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://zownir.net/2008/02/26/ssh-public-key-authentication/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
