<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>nginx &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://wordpress.com/tag/nginx/</link>
	<description>Feed of posts on WordPress.com tagged "nginx"</description>
	<pubDate>Sat, 26 Jul 2008 10:41:44 +0000</pubDate>

	<generator>http://wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[nginx + mongrel installation and configuration for RoR app.]]></title>
<link>http://linxfo.wordpress.com/?p=22</link>
<pubDate>Wed, 23 Jul 2008 04:15:35 +0000</pubDate>
<dc:creator>linxfo</dc:creator>
<guid>http://linxfo.wordpress.com/?p=22</guid>
<description><![CDATA[
I&#8217;m going to compile in nginx server from the source. I&#8217;m assuming that you&#8217;ve pa]]></description>
<content:encoded><![CDATA[<div class="entry-content">
<p>I'm going to compile in nginx server from the source. I'm assuming that you've packages like ruby, Rails etc. pre-installed on your system/server.</p>
<p>I've compiled in nginx from the source, so you'll need a gcc complier.</p>
<pre>Download the source.
wget http://sysoev.ru/nginx/nginx-0.5.35.tar.gz

Untar it
tar zxvf nginx-0.5.35.tar.gz

Run.

cd nginx-0.5.35
./configure --prefix=/usr/local/nginx
make
make install</pre>
<p>If everything does fine, nginx will get installed /usr/local/nginx</p>
<p>Here is a sample nginx configuration file. Just copy it as nginx.conf(/usr/local/nginx/conf/nginx.conf) and modify it accordingly four your application setup.</p>
<pre>user  www www;
worker_processes  3;

error_log  /var/log/nginx/error.log;

pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /usr/local/nginx/conf/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] $status '
                      '"$request" $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    tcp_nopush     on;
    tcp_nodelay    on;

        gzip  on;
    upstream mongrel {
     server 127.0.0.1:4000;
     server 127.0.0.1:4001;
    }

        #Rails App here
            server {
        listen       80;
        root /var/www/railsapp/public;
        index index.html index.htm;
        server_name yourdomain.com www.yourdomain.com;
        client_max_body_size 50M;

        access_log  /var/log/nginx/localhost.access.log;

        location / {
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded_for $proxy_add_x_forwarded_for;
         proxy_set_header Host $http_host;
         proxy_redirect false;
         proxy_max_temp_file_size 0;

         if (-f $request_filename) {
            break;
          }
         if (-f $request_filename/index.html) {
            rewrite (.*) $1/index.html break;
         }
         if (-f $request_filename.html) {
            rewrite (.*) $1.html break;
         }
         if (!-f $request_filename) {
            proxy_pass http://mongrel;
            break;
         }

        }
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /500.html;
        location = /500.html {
            root  /var/www/railsapp/public;
        }
    }

}</pre>
<p>You may start the nginx server using the command</p>
<pre>/usr/local/nginx/bin/nginx -c /usr/local/nginx/conf/nginx.conf</pre>
<p>Now you may want an init startup script to start&#124;stop&#124;restart the server. Just copy the below script as /etc/init.d/nginx and set it executable(chmod 755 /etc/init.d/nginx)</p>
<pre>#!/bin/sh

# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'sudo update-rc.d nginx defaults', or use the appropriate command on your
# distro.
#
# Author:       Ryan Norbauer
# Modified:     Geoffrey Grosenbach http://topfunky.com

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/nginx.conf
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Gracefully exit if the package has been removed.
test -x $DAEMON &#124;&#124; exit 0

d_start() {
  $DAEMON -c $CONFIGFILE &#124;&#124; echo -n " already running"
}

d_stop() {
  kill -QUIT `cat $PIDFILE` &#124;&#124; echo -n " not running"
}

d_reload() {
  kill -HUP `cat $PIDFILE` &#124;&#124; echo -n " can't reload"
}

case "$1" in
  start)
        echo -n "Starting $DESC: $NAME"
        d_start
        echo "."
        ;;
  stop)
        echo -n "Stopping $DESC: $NAME"
        d_stop
        echo "."
        ;;
  reload)
        echo -n "Reloading $DESC configuration..."
        d_reload
        echo "reloaded."
  ;;
  restart)
        echo -n "Restarting $DESC: $NAME"
        d_stop
        # One second might not be time enough for a daemon to stop,
        # if this happens, d_start will fail (and dpkg will break if
        # the package is being upgraded). Change the timeout if needed
        # be, or change d_stop to have start-stop-daemon use --retry.
        # Notice that using --retry slows down the shutdown process somewhat.
        sleep 1
        d_start
        echo "."
        ;;
  *)
          echo "Usage: $SCRIPTNAME {start&#124;stop&#124;restart&#124;force-reload}" &#62;&#38;2
          exit 3
        ;;
esac

exit 0</pre>
<p>Also don't forget to add the user www using "useradd -s /sbin/nologin www" if the user doesn't exists.</p>
<p>Now time to setup mongrel for your app. Install the mongrel gem, if it's not installed already.</p>
<pre>gem install mongrel</pre>
<p>Then configure the mongrel cluster for your app and start the mongrel server.</p>
<pre>cd /var/www/railsapp (your application directory)

mongrel_rails cluster::configure -e production -p 4000 -N 2

mongrel_rails cluster::start</pre>
<p>You can of course use the mongrel_rails cluster::start&#124;stop&#124;restart commands to manage your mongrel instance.</p>
<p>Hope that this tutorial is useful...</p></div>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Soporte de Syslog para Nginx]]></title>
<link>http://lbosque.wordpress.com/?p=95</link>
<pubDate>Thu, 10 Jul 2008 09:06:08 +0000</pubDate>
<dc:creator>Luis</dc:creator>
<guid>http://lbosque.wordpress.com/?p=95</guid>
<description><![CDATA[Estos días tenía la necesidad de hacer que nginx mandase sus logs al syslog local.
Nginx no tiene ]]></description>
<content:encoded><![CDATA[<p>Estos días tenía la necesidad de hacer que <a href="http://nginx.net/">nginx</a> mandase sus logs al syslog local.<br />
Nginx no tiene soporte nativo para usar syslog. Puede escribir los logs o en fichero o mandarlos a un pipe.<br />
Estuve bsucando y encontré un <a href="http://bugs.gentoo.org/show_bug.cgi?id=222373">parche</a> de la versión 0.6.31 que resuelve el problema. <a href="http://www.ruby-forum.com/topic/153141">Aquí</a> habla también un poco del parche.</p>
<p>A pesar de que en ese último link explica por encima como hacerlo, lo voy a contar yo también.</p>
<ul>
<li>Bajamos la versión 0.6.31 de nginx en <a href="http://sysoev.ru/nginx/nginx-0.6.31.tar.gz">http://sysoev.ru/nginx/nginx-0.6.31.tar.gz</a>. Según el comentario de Marlon (el creador del parche) debería funcionar también con las versiones 0.6.30 y 0.6.29, y mirando los changelogs pienso que tambíen debería funcionar en la última que es la 0.6.32. Si alguien lo prueba que me lo diga.</li>
<li>Descomprimimos:<br />
<code># cd /usr/src/<br />
# tar xvzf nginx-0.6.31.tar.gz</code></li>
<li>Bajamos el parche:<br />
<code># wget http://bugs.gentoo.org/attachment.cgi?id=153345 -O nginx_syslog.patch</code></li>
<li>Parcheamos:<br />
<code># patch -p0 &#60; nginx_syslog.patch</code>
</li>
<li>Compilamos e instalamos nginx:<br />
<code># cd nginx-0.6.31<br />
# ./configure --with-syslog<br />
# make<br />
# make install</code></li>
</ul>
<p>En mi caso antes de compilar he tenido que hacer un cambio en una linea de los fuentes del nginx. He tenido que substituir en el fichero <em>auto/cc/gcc</em> la siguiente linea:<br />
<code>CFLAGS="$CFLAGS -Werror"</code><br />
por:<br />
<code>CFLAGS="$CFLAGS"</code></p>
<p>Esto únicamente hace que no se rompa la compilación al encontrar algun warning. En mi caso los warning que lanza la compilación se pueden ignorar tranquilamente, por lo que resulta seguro continuar con ellos.</p>
<p>Si todo ha ido bien deberíamos de tener funcionando nginx. Faltaría unicamente configurarlo y ponerlo en marcha. En el fichero de configuración no hace falta indicar nada para que mande correctamente los logs al syslog. Por defecto los manda a la facility daemon.</p>
<p>Yo lo he probado ya en servidores en producción y por el momento funciona estupendamente.</p>
<p>Desde aquí agradezco el esfuerzo a <a href="http://mjdeboer.hyves.nl/">Marlon de Boer</a>, que no he conseguido encontrar un blog suyo donde hacerlo.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Another comparison of HAProxy and Nginx]]></title>
<link>http://affectioncode.wordpress.com/?p=29</link>
<pubDate>Sat, 28 Jun 2008 00:32:00 +0000</pubDate>
<dc:creator>Alexander</dc:creator>
<guid>http://affectioncode.wordpress.com/?p=29</guid>
<description><![CDATA[In my previous post about web application proxies, I compared HAProxy and Nginx performance when pr]]></description>
<content:encoded><![CDATA[<p>In my <a href="http://affectioncode.wordpress.com/2008/06/11/comparing-nginx-and-haproxy-for-web-applications/">previous post</a> about web application proxies, I compared HAProxy and Nginx performance when proxying a simple Rails application. While HAProxy was able to serve pages faster and more consistently, the beanchmark also uncovered an apparent design flaw in HAProxy that caused some connections to hang around in the queue for a long time. HAProxy's author, Willy Tarreau, quickly stepped in to attack the problem, and soon provided a <a href="http://haproxy.1wt.eu/download/1.3/src/">new point release</a>:</p>
<blockquote><p>My first analysis was that this problem was caused by "direct" requests (those with a server cookie) always being considered before the load balanced ones. But while fixing this design idiocy, I discovered a real problem : it was perfectly possible for a fresh new request to be served immediately without passing through the queue, causing requests in the queue to be delayed for at least as long as the queue timeout, until they might eventually expire. Now *that* explains the horrible peaks on Alexander's graphs. My problem was that it was a real misdesign, which could not be fixed by a 3-liner patch. So I spent the whole week reworking the queue management logic in a saner manner and running regression tests.</p></blockquote>
<p>The fix has further repercussions:</p>
<blockquote><p>[T]he good news is that not only this fixes a number of 503 errors and long response times when running with a low maxconn, but as an added bonus, the "redispatch" option is now naturally considered when a server's maxqueue is reached, so that it will now not be necessary anymore to trade between large queues and the risk of returning 503 errors.</p></blockquote>
<p>Willy also realized that his redesign work would lead the way to priority-based request scheduling in the future, which is great news.</p>
<p>With the new release in hand, I have finally found the time to sit down and do a rematch. The conclusion? In short, the patch works as intended: It eliminates the odd spikes while still providing smoother performance than Nginx. The spikes that remain are present with Nginx as well, and their regularity implies some kind of periodic activity, possibly on the box itself, although a much more likely culprit is Ruby's garbage collection. Damn you, curiously slow and old-fashioned interpreter implementation!</p>
<p>Finally, some people requested CPU usage data from vmstat. For this new benchmark I updated my scripts to run vmstat concurrently with ab, hoping there would some meaty differences for charting, but it turns out that there is no significant difference between HAProxy and Nginx — at best, CPU usage looks a trifle smoother with HAProxy, but this could be a fluke. I suspect you have to amp up the load considerably to achieve a sensible comparison. Still, I have included the vmstat data in the <a href="http://purefiction.net/paste/nginx_vs_haproxy_1.3.15.2.tar.bz2">raw data tarball</a> for anyone who is interested.</p>
<p>Anyway, enjoy the graphs. Many thanks to Willy for working out a solution so promptly and expertly.</p>
<p><strong>Nginx vs HAProxy at 3 concurrent connections</strong></p>
<p><a href="http://affectioncode.wordpress.com/files/2008/06/2ab_nginx_n1000_c3dat.png"><img class="alignnone size-medium wp-image-39" src="http://affectioncode.wordpress.com/files/2008/06/2ab_nginx_n1000_c3dat.png?w=300" alt="" width="240" height="180" /></a><a href="http://affectioncode.wordpress.com/files/2008/06/2ab_haproxy_n1000_c3dat.png"><img class="alignnone size-medium wp-image-36" src="http://affectioncode.wordpress.com/files/2008/06/2ab_haproxy_n1000_c3dat.png?w=300" alt="" width="240" height="180" /></a></p>
<p><strong>Nginx vs HAProxy at 10 concurrent connections</strong></p>
<p><a href="http://affectioncode.wordpress.com/files/2008/06/2ab_nginx_n1000_c10dat.png"><img class="alignnone size-medium wp-image-40" src="http://affectioncode.wordpress.com/files/2008/06/2ab_nginx_n1000_c10dat.png?w=300" alt="" width="240" height="180" /></a><a href="http://affectioncode.wordpress.com/files/2008/06/2ab_haproxy_n1000_c10dat.png"><img class="alignnone size-medium wp-image-37" src="http://affectioncode.wordpress.com/files/2008/06/2ab_haproxy_n1000_c10dat.png?w=300" alt="" width="240" height="180" /></a></p>
<p style="text-align:left;"><strong>Nginx vs HAProxy at 30 concurrent connections</strong></p>
<p><a href="http://affectioncode.wordpress.com/files/2008/06/2ab_nginx_n1000_c30dat.png"><img class="alignnone size-medium wp-image-41" src="http://affectioncode.wordpress.com/files/2008/06/2ab_nginx_n1000_c30dat.png?w=300" alt="" width="240" height="180" /></a><a href="http://affectioncode.wordpress.com/files/2008/06/2ab_haproxy_n1000_c30dat.png"><img class="alignnone size-medium wp-image-38" src="http://affectioncode.wordpress.com/files/2008/06/2ab_haproxy_n1000_c30dat.png?w=300" alt="" width="240" height="180" /></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Scaling on EC2]]></title>
<link>http://webmynd.wordpress.com/?p=16</link>
<pubDate>Mon, 23 Jun 2008 19:38:11 +0000</pubDate>
<dc:creator>James Brady</dc:creator>
<guid>http://webmynd.wordpress.com/?p=16</guid>
<description><![CDATA[Like any application developed for a platform, the success of a Firefox Add-on is closely tied to th]]></description>
<content:encoded><![CDATA[<p>Like any application developed for a platform, the success of a Firefox Add-on is closely tied to the popularity and distribution you get from the underlying delivery mechanism. So, when we honed down the <a href="http://webmynd.com">WebMynd</a> feature set, improving the product enough to get on Mozilla's Recommended List, we were delighted by our increasing user numbers. A couple of weeks later, <a href="http://www.mozilla.com/en-US/firefox/all.html">Firefox 3</a> was released, and we got a usage graph like this:<a href="http://webmynd.files.wordpress.com/2008/06/usage1.png"><img class="aligncenter size-full wp-image-22" src="http://webmynd.wordpress.com/files/2008/06/usage1.png" alt="WebMynd usage statistics" width="500" height="177" /></a></p>
<p>With a product like WebMynd, where part of the service we provide is to save and index a person's web history, this sort of explosive expansion brings with it some growing pains. Performance was a constant battle with us, even with the relatively low user numbers of the first few months. This was due mainly to some poor technology choices; thankfully, the underlying architecture we chose from the start has proven to be sound.</p>
<p>I would not say that we have completely solved the difficult problem in front of us - we are still not content with the responsiveness of our service, and we're open about the brown-outs we still sometimes experience - but we have made huge progress and learned some invaluable lessons over the last few months.</p>
<p>What follows is a high level overview of some of the conclusions we've arrived at today, best practices that work for us and some things to avoid. In later weeks, I plan to follow up with deeper dives into certain parts of our infrastructure as and when I get a chance!</p>
<h2>Scaling is all about removing bottlenecks</h2>
<p>This sounds obvious, but should strongly influence all your technology and architecture decisions.</p>
<p>Being able to remove bottlenecks means you need to be able to swap out discrete parts which aren't performing well enough, and swap in bigger, faster, better parts which will perform as required. This will move the bottleneck somewhere else, at which point you need to swap out discrete parts which aren't performing well enough, and swap in bigger, faster, better parts... well you get the idea. This cycle can be repeated ad infinitum until you've optimised the heck out of everything and you're just <a href="http://www.techcrunch.com/2008/05/10/facebook-raises-another-100-million/">throwing machines at the problem</a>.</p>
<p>At WebMynd, for our search backend, we've done this four or five times already in the five months we've been alive, and I think I still have some iterations left in me. Importantly, I wouldn't say that any of these iterations were a mistake. In a parallel to the <a href="http://ycombinator.com/">Y Combinator</a> ethos of launching a product early, scaling should be an iterative process with as close a feedback loop as possible. Premature optimisation of any part of the service is a waste of time and is often <a href="http://www.acm.org/ubiquity/views/v7i24_fallacy.html">harmful</a>.</p>
<p>Scaling relies on having discrete pieces with clean interfaces, which can be iteratively improved.</p>
<h2>Horizontal is better than vertical</h2>
<p>One of the reasons Google triumphed in the search engine wars was that their core technology was designed from the ground up to scale horizontally across cheap hardware. Compare this with their competitors' approach, which was in general to scale vertically - using larger and larger monolithic machines glued together organically. Other search engines relied on <a href="http://en.wikipedia.org/wiki/Moore%27s_Law">improving hardware</a> to cope with demand, but when the growth of the internet outstripped available hardware, they had nowhere to go. Google was using inferior pieces of hardware, but had an architecture and infrastructure allowing for cheap and virtually limitless scaling.</p>
<p>Google's key breakthroughs were the <a href="http://labs.google.com/papers/gfs.html">Google File System</a> and <a href="http://labs.google.com/papers/mapreduce.html">MapReduce</a>, which together allow them to horizontally partition the problem of indexing the web. If you can architect your product in such a way as to allow for similar partitioning, scaling will be all the more easy. It's interesting to note that some of the current trends of Web2.0 products are extremely hard to horizontally partition, due to the hyper-connectedness of the user graph (witness <a href="http://twitter.com">Twitter</a>).</p>
<p>The problem WebMynd is tackling is <a href="http://en.wikipedia.org/wiki/Embarrassingly_parallel">embarrassingly</a> partitionable. Users have their individual slice of web history, and these slices can be moved around the available hardware at will. New users equals new servers.</p>
<h2>Hardware is the lowest common denominator</h2>
<p>By running your application on virtual machines using <a href="http://www.amazon.com/ec2">EC2</a>, you are viewing the hardware you're running on as a commodity which can be swapped in and out at the click of a button. This is an useful mental model to have, where the actual machine images you're running on are just another component in your architecture which can be scaled up or down as demand requires. Obviously, if you're planning on scaling horizontally, you need to be building on a substrate which has low marginal cost for creating and destroying hardware - marginal cost in terms of time, effort and <a href="http://en.wikipedia.org/wiki/Capital_expenditure">capex</a>.</p>
<h2>A real example</h2>
<p>To put the above assertions into context, I'll use WebMynd's current architecture:<a href="http://webmynd.files.wordpress.com/2008/06/wm_arch3.png"><img class="aligncenter size-full wp-image-21" src="http://webmynd.wordpress.com/files/2008/06/wm_arch3.png" alt="WebMynd architecture" width="500" height="334" /></a></p>
<p>The rectangles represent EC2 instances. Their colour represents their function. The red arrow in the top right represents incoming traffic. Other arrows represent connectedness and flows of information.</p>
<p>This is a simplified example, but here's what the pieces do in general terms:</p>
<ul>
<li>All traffic is currently load balanced by a single <a href="http://haproxy.1wt.eu/">HAProxy</a> instance</li>
<li>All static content is served from a single <a href="http://nginx.net/">nginx</a> instance (with a hot failover ready)</li>
<li>Sessions are distributed fairly across lots of TurboGears application servers, on several machines</li>
<li>The database is a remote MySQL instance</li>
<li>Search engine updates are handled asynchronously through a queue</li>
<li>Search engine queries are handled synchronously over a direct TurboGears / Solr connection (not shown)</li>
</ul>
<p>One shouldn't be timid in trying new things to find the best solution; almost all of these parts have been iterated on like crazy. For example, we've used <a href="http://httpd.apache.org/">Apache</a> with <a href="http://www.modpython.org/">mod_python</a>, Apache with <a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html">mod_proxy</a>,  Apache with <a href="http://code.google.com/p/modwsgi/">mod_wsgi</a>. We've used <a href="http://dev.krys.ca/turbolucene">TurboLucene</a>, looked very hard at <a href="http://xapian.org/">Xapian</a>, various configurations of <a href="http://lucene.apache.org/solr/">Solr</a>.</p>
<p>For the queue, I've written my own queuing middleware, I've used <a href="http://activemq.apache.org/index.html">ActiveMQ</a> running on an EC2 instance and I'm now in the process of moving to Amazon's <a href="http://www.amazon.com/sqs">SQS</a>. We chose to use SQS as although ActiveMQ is free as in <a href="http://c2.com/cgi/wiki?FreeAsInBeer">beer</a> and <a href="http://c2.com/cgi/wiki?FreeAsInSpeech">speech</a>, it has an ongoing operations cost in terms of time, which is one thing you're always short of during hyper-growth.</p>
<p>The two parts which are growing the fastest are the web tier (the TurboGears servers) and the search tier (the Solr servers). However, as we can iterate on our implementations and rapidly horizontally scale on both of those parts, that growth has been containable, if not completely pain free.</p>
<p>&#160;<br />
Amazon's Web Services give growing companies the ideal building blocks to scale and keep up with demand. By iteratively improving the independent components in our architecture, we have grown to meet the substantial challenge of providing the WebMynd service to our users.<br />
&#160;</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[High performance PHP]]></title>
<link>http://alword.wordpress.com/?p=15</link>
<pubDate>Thu, 19 Jun 2008 22:11:38 +0000</pubDate>
<dc:creator>alword</dc:creator>
<guid>http://alword.wordpress.com/?p=15</guid>
<description><![CDATA[If you have the need to run php with a very high traffic you should think about the follwoing setup.]]></description>
<content:encoded><![CDATA[<p>If you have the need to run php with a very high traffic you should think about the follwoing setup.</p>
<p>Don't think it will work in 5 minutes and you don't need some knowledge about how to setup an webserver and a php application, you definitely need it.</p>
<p>If you think this is a step by step description for people which only want to copy and past commands and it works then you are wrong here, please take a websearch engine for a alternative description.</p>
<p>What you need:</p>
<ol>
<li>nginx <a title="nginxhome" href="http://www.nginx.net/" target="_blank">http://www.nginx.net/</a></li>
<li>php-fm <a title="php-fmlink" href="http://php-fpm.anight.org/" target="_blank">http://php-fpm.anight.org/</a></li>
<li>php http://www.php.net/</li>
<li>a compile environment</li>
<li>the development libraries for the wanted php features and libxml2</li>
<li>A clear test scenario and target how many requests per second should be reached on static and dynamic part.</li>
</ol>
<p>How you can build this environment:</p>
<ol>
<li>Extract, build and install nginx <a title="nginxgettingstarted" href="http://wiki.codemongers.com/NginxGettingStarted">http://wiki.codemongers.com/NginxGettingStarted</a></li>
<li>Extract, build   and install php-fm <a title="php-fmdoc" href="http://php-fpm.anight.org/docs.html" target="_blank">http://php-fpm.anight.org/docs.html</a></li>
<li>configure nginx for fast-cgi proxying <a title="nginxfcgimod" href="http://wiki.codemongers.com/NginxHttpFcgiModule" target="_blank">http://wiki.codemongers.com/NginxHttpFcgiModule</a></li>
</ol>
<p><img src="http://none.at/high-perf-php.gif" alt="High Performance View" /></p>
<p>A brief description how the flow is:</p>
<ul>
<li>A request comes to nginx</li>
<li>He takes a look into his config to find the right <a title="nginxlocationlink" href="http://wiki.codemongers.com/NginxHttpCoreModule#location" target="_blank">location</a> or <a title="nginxserverlink" href="http://wiki.codemongers.com/NginxHttpCoreModule#server" target="_blank">server</a> config</li>
<li>If the static content rule matches then he will deliver the content directly from the disc</li>
<li>If the dynamic rule matches the he will contact php-fm, which manage the php-instances</li>
<li>php-fm execute the php script and send the dynamic content back to nginx</li>
<li>nginx sends the content back to the client</li>
</ul>
<p>There are some pitfalls:</p>
<ol>
<li><a title="nginxclienbodbufsizlink" href="http://wiki.codemongers.com/NginxHttpCoreModule#client_body_buffer_size" target="_blank">client_body_buffer_size</a></li>
<li><a title="nginxfastcgibodbufsizlink" href="http://wiki.codemongers.com/NginxHttpFcgiModule#fastcgi_buffers" target="_blank">fastcgi_buffers*</a></li>
</ol>
<p>You should take your time to find the right config setup for nginx and php-fm to be able to fulfill the assumed traffic.</p>
<p>I have started to translate the russian documentation, which is still not complete.</p>
<p>You can take a look here:</p>
<p><a title="phpfmcurrprobs" href="http://none.at/phpfm/docs/current_php_fastcgi_problems_en.html" target="_blank">why_fastcgi_en</a></p>
<p><a title="phpfmcurrprobs" href="http://none.at/phpfm/docs/current_php_fastcgi_problems_en.html" target="_blank">current_php_fastcgi_problems_en</a></p>
<p><a title="phpfmextrafeatures" href="http://none.at/phpfm/docs/extra_features_en.html" target="_blank">extra_features_en</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[use the event ports in nginx]]></title>
<link>http://alword.wordpress.com/?p=13</link>
<pubDate>Sat, 14 Jun 2008 08:45:42 +0000</pubDate>
<dc:creator>alword</dc:creator>
<guid>http://alword.wordpress.com/?p=13</guid>
<description><![CDATA[Solaris have since version 10 a new polling infrastrucutre Event Ports here a more detailed article ]]></description>
<content:encoded><![CDATA[<p>Solaris have since version 10 a new polling infrastrucutre <a title="Event Ports" href="http://docs.sun.com/app/docs/doc/817-0547/whatsnew-196?l=en&#38;a=view&#38;q=event+port" target="_blank">Event Ports</a> here a more detailed article about <a title="Event Ports Framework" href="http://developers.sun.com/solaris/articles/event_completion.html" target="_blank">Event Completion Framework</a>. <a title="AdLe" href="http://www.opensolaris.org/viewProfile.jspa?id=21" target="_blank">Adam Leventhal</a> wrotes in his <a title="AhlBlog" href="http://blogs.sun.com/ahl/" target="_blank">Blog</a> for him this is one of the top <a title="top20" href="http://blogs.sun.com/ahl/date/20040712" target="_blank">20 best thing in Solaris 10</a>.</p>
<p>By default nginx do not use this event methode due to the fact that there was some security related problems <a title="EvPortSecProblem1" href="http://sunsolve.sun.com/search/document.do?assetkey=1-26-102485-1" target="_blank">Security Vulnerabilities in The Solaris Event Port API May Result in a Denial of Service (DoS) Condition</a> and  <a title="EvPortSecProblem" href="http://sunsolve.sun.com/search/document.do?assetkey=1-66-235122-1" target="_blank">Vulnerability in the Solaris 10 Event Port Implementation May Lead to a System Panic, Resulting in a Denial of Service (DoS)</a> if you have a newer Version or applied the Patch you should use the event ports in nginx.</p>
<p>You only need to add</p>
<blockquote><p>use eventport;</p></blockquote>
<p>in the <strong>events { ... }</strong> section. If you don't add this then nginx by default us the <a title="devpoll" href="http://developers.sun.com/solaris/articles/polling_efficient.html" target="_blank">/dev/poll</a> method.</p>
<p>More about the possible polling methods can be found <a title="nginxoptis" href="http://wiki.codemongers.com/NginxOptimizations">here</a>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[nginx build on opensolaris with SunStudio]]></title>
<link>http://alword.wordpress.com/?p=9</link>
<pubDate>Fri, 13 Jun 2008 14:47:13 +0000</pubDate>
<dc:creator>alword</dc:creator>
<guid>http://alword.wordpress.com/?p=9</guid>
<description><![CDATA[Today I was interested if the latest nginx (nginx-0.7.1) is able to build on the opensolaris box and]]></description>
<content:encoded><![CDATA[<p>Today I was interested if the latest nginx (nginx-0.7.1) is able to build on the opensolaris box and YES it does ;-)</p>
<p>1.) get it</p>
<blockquote><p>wget http://sysoev.ru/nginx/nginx-0.7.1.tar.gz</p></blockquote>
<p>2.) extract it</p>
<blockquote><p>gtar xfvz nginx-0.7.1.tar.gz</p></blockquote>
<p>3.) build it</p>
<blockquote><p>cd nginx-0.7.1 &#38;&#38; ./configure --prefix=$HOME/servers/nginx --with-http_ssl_module --with-debug --with-cc=/opt/SunStudioExpress/bin/cc</p></blockquote>
<p>It's so easy, thanks Igor.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Install Deki Wiki on Nginx Ubuntu - Nginx Conf File Included]]></title>
<link>http://honewatson.wordpress.com/?p=312</link>
<pubDate>Fri, 13 Jun 2008 03:51:23 +0000</pubDate>
<dc:creator>honewatson</dc:creator>
<guid>http://honewatson.wordpress.com/?p=312</guid>
<description><![CDATA[Deki Wiki is cool but Apache is really too bloated.
Here&#8217;s how to get it working on Nginx Ubun]]></description>
<content:encoded><![CDATA[<p>Deki Wiki is cool but Apache is really too bloated.</p>
<p>Here's how to get it working on Nginx Ubuntu.</p>
<p><!--more--></p>
<p>Follow the instructions for the source installation.  Do not apt-get apache and apache associated libraries.  <a href="http://wiki.developer.mindtouch.com/Deki_Wiki/Installation_and_Upgrade/1.9.0_Itasca_Source_Code_Install_and_Upgrade_Guide">Source installation.</a></p>
<p>I presume you already have mysql and php installed.</p>
<p class="code"><code><br />
apt-get install imagemagick wv pdftohtml html2text html2ps htmldoc aspell links mono-gmcs mono-mcs libmono-sqlite2.0-cil libmono-sqlite2.0-cil libmono-system-web2.0-cil<br />
</code></p>
<p>Note the above may not be all you need.  The complete package list is at <a href="http://wiki.developer.mindtouch.com/Deki_Wiki/Installation_and_Upgrade/1.9.0_Itasca_Source_Code_Install_and_Upgrade_Guide">Source installation</a>.</p>
<p>Make sure pear is installed.... aptitude install php-pear</p>
<p>There are problems with /skins/ace/neutral/css.php files etc.  Sometimes they these files can't find the includes files so you may have to edit these and put the full path for these includes.</p>
<p>After the full install you may have to also <strong>aptitude install libmono-i18n2.0-cil</strong> otherwise you might get some 500 errors with mysql.</p>
<p>If you get an error with @api you may have to change the /etc/dekiwiki/mindtouch.host.conf</p>
<blockquote><p># hostname to listen on<br />
IP="*:8081"</p></blockquote>
<p>Note I also had to:</p>
<blockquote><p>cp source_folder/config/dekiwiki-init.debian /etc/init.d/dekiwiki &#38;&#38; chmod +x /etc/init.d/dekiwiki</p>
<p>mkdir /var/www/.wapi
</p></blockquote>
<p>server {<br />
listen       80;<br />
server_name wiki.mookiesplace.com;<br />
access_log  /usr/local/nginx/logs/campaign.access.log;</p>
<p>location ~* ^.+\.(html&#124;jpg&#124;jpeg&#124;gif&#124;png&#124;ico&#124;css&#124;zip&#124;tgz&#124;gz&#124;rar&#124;bz2&#124;doc&#124;xls&#124;exe&#124;pdf&#124;ppt&#124;txt&#124;tar&#124;mid&#124;midi&#124;wav&#124;bmp&#124;rtf&#124;js)$<br />
{<br />
root /home/mookiesplace/dekiwiki;<br />
expires 10d;<br />
break;<br />
error_page 404 /index.php?title=$uri;<br />
}</p>
<p>location /      {<br />
root   /home/jollymarketing/campaignwiki;<br />
index index.php;</p>
<p>rewrite ^/$ /index.php?title= last;<br />
rewrite ^/@gui/(.*)$ /proxy.php?path=$1 last;</p>
<p>if (!-e $request_filename) {<br />
rewrite ^/(.+)$ /index.php?title=$1 last;<br />
}<br />
}</p>
<p>location /@api {<br />
proxy_pass http://127.0.0.1:8081;<br />
}</p>
<p>location ~ \.php$ {<br />
fastcgi_pass   127.0.0.1:8084;<br />
fastcgi_index  index.php;<br />
fastcgi_param  SCRIPT_FILENAME /home/mookiesplace/dekiwiki$fastcgi_script_name;<br />
include        /usr/local/nginx/conf/fastcgi_params;<br />
}<br />
error_page   500 502 503 504  /50x.html;</p>
<p>location = /50x.html {<br />
root   /var/www/nginx-default;<br />
}</p>
<p>}</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Comparing Nginx and HAProxy for web applications]]></title>
<link>http://affectioncode.wordpress.com/?p=3</link>
<pubDate>Tue, 10 Jun 2008 23:13:15 +0000</pubDate>
<dc:creator>Alexander</dc:creator>
<guid>http://affectioncode.wordpress.com/?p=3</guid>
<description><![CDATA[The last few days I have been comparing Nginx to HAProxy, with surprising results.
First, a bit of ]]></description>
<content:encoded><![CDATA[<p style="text-align:left;">The last few days I have been comparing Nginx to HAProxy, with surprising results.</p>
<p style="text-align:left;">First, a bit of background. For a long time we at Bengler have been using Nginx as the main web server for our projects (<a href="http://underskog.no/">1</a>, <a href="http://origo.no/">2</a>), as well as to proxy Rails running under Mongrel. Nginx is a superb little open-source web server with a small footprint, sensible configuration language, modern feature set and buckets of speed. However, we quickly realized that the load balancing features of the proxy are not up to scratch.</p>
<p style="text-align:left;">The core problem is the proxy load balancing algorithm. Nginx only comes with a round-robin balancer and a hash-based balancer. Only the former is of interest to us since our object is to distribute the load evenly across a pack of Mongrel back ends. The round-robin algorithm is often an acceptable tool: if every request finishes within a few milliseconds, there's no problem.</p>
<p style="text-align:left;">But if a page takes a while to load, Nginx will start routing requests to backends that are already processing requests — as a result, some backends will be queueing up requests while some backends will remain idle. You will get an uneven load distribution, and the unevenness will increase with the amount of load subject to the load-balancer.</p>
<p style="text-align:left;">So when Gzegorz Nosek, backed by <a href="http://brainspl.at/articles/2007/11/09/a-fair-proxy-balancer-for-nginx-and-mongrel">EngineYard</a>, announced his <a href="http://git.localdomain.pl/?p=nginx-upstream-fair.git;a=summary">fair load balancer</a> module, we naturally pounced on it. Gzegorz's module routes requests to the back end with the fewest outstanding requests, and this improved performance a lot.</p>
<p style="text-align:left;">Unfortunately, Gzegorz's patch is not completely stable, and turned out to be the main source of our stability problems of late. Sometimes it sits down chewing the carpet while backends go idle and requests pile up, or worse, goes into tailspin and refuses to serve requests, for which the only remedy is a cold restart of Nginx. Even in normal operation, however, it will often send multiple connections to a backend even when some are idle, since there is no limit on the number of connections each backend can receive.</p>
<p style="text-align:left;">After reading about <a href="http://haproxy.1wt.eu/">HAProxy</a> (there's nice blog Rails-oriented blog post <a href="http://www.igvita.com/2008/05/13/load-balancing-qos-with-haproxy/">here</a>), I felt the itch to try out this product myself. HAProxy has a handsome feature set:</p>
<ul style="text-align:left;">
<li><strong>It's is proxy — and only a proxy.</strong> It can't serve files, for example: proxying is all its does.</li>
<li>It can proxy anything TCP-based — not just HTTP.</li>
<li>Plenty of load-balancing algorithms, <strong>including a "least connections" strategy</strong> that picks the backend with the fewest pending connections. Which happens to be just what we want.</li>
<li>Backends can be sanity- and health-checked by URL to avoid routing requests to brain-damaged backends. (It can even stagger these checks to avoid spikes.)</li>
<li><strong>A dedicated </strong><a href="http://www.igvita.com/posts/05-08/haproxy-large.png"><strong>status page</strong></a> gives you backend status, uptime and lots of yummy metrics. There's also a way to read metrics from a Unix domain socket.</li>
<li>Requests can be routed based on all sorts of things: cookies, URL substrings, client IP, etc.</li>
</ul>
<div style="text-align:left;">
<p>I like the fact that HAProxy is so single-minded in its approach. Experience tells me that simple, specialized, single-purpose applications are preferable over complex, flexible one-size-fits-all applications, <a href="http://varnish.projects.linpro.no/">Varnish</a> and <a href="http://www.danga.com/memcached/">Memcached</a> being two relevant examples.</p>
<p>To determine if HAProxy is up to par, I have done a few simple benchmarks. They're not awesomely scientific, but I think they are good enough.</p>
<p><strong>The setup</strong>: Dedicated test machine (quad-core AMD64 2.4GHz, 4GB RAM), 3 mongrels running an actual Rails 1.2 app. I use Apache's ab benchmarking tool for the testing (many people prefer httperf, but we have never quite seen eye to eye) and I run 1,000 requests at various levels of concurrency. The page being tested is a minimal controller action that makes one database call, one Memcached lookup and renders an empty page; it takes about 20ms to render.</p>
<p>I have configured Nginx with Gzegorz's fair load-balancing patch. The configuration does nothing except set up a proxy against Mongrel.</p>
<p>I have configured HAProxy with the "leastconns" algorithm and "maxconn 1" for each Mongrel. This is intentionally unfair — but the object is not a comparison of HAProxy and Nginx when each is configured identically; rather, I would like to observe what kind of performance profile can be achieved with HAProxy's superior gadgetry.</p>
<p>The "maxconns" setting is significant — since only a single request is handed to Mongrel at a time, it means that when all backends are busy, pending client requests will idle inside HAProxy — rather than inside Mongrel. Subsequently, when a backend becomes available, the next request in line will be routed to that backend. Without this restriction, of course, requests would end up in busy Mongrels and sit there even though other backends might be available.</p>
<p>Nginx, using the fair load-balancing patch, will behave similarly, but will suffer occasionally overlapping requests since it has no limit on the number of connections each back end can receive.</p>
<p><strong>So, the data</strong>. The following graphs show the response times of each request.</p>
<p style="text-align:center;"><strong>Nginx — 3 concurrent connections</strong></p>
<p style="text-align:center;"><a href="http://affectioncode.wordpress.com/files/2008/06/new_ab_nginx_n1000_c3dat.png"><img class="alignnone size-full wp-image-21" src="http://affectioncode.wordpress.com/files/2008/06/new_ab_nginx_n1000_c3dat.png" alt="Nginx — 3 concurrent connections" width="400" height="300" /></a></p>
<p style="text-align:center;"><strong>HAProxy — 3 concurrent connections</strong></p>
<p style="text-align:center;"><a href="http://affectioncode.wordpress.com/files/2008/06/new_ab_haproxy_n1000_c3dat.png"><img class="alignnone size-full wp-image-17" src="http://affectioncode.wordpress.com/files/2008/06/new_ab_haproxy_n1000_c3dat.png" alt="HAProxy — 3 concurrent connections" width="400" height="300" /></a></p>
<p style="text-align:center;"><strong>Nginx — 10 concurrent connections</strong></p>
<p style="text-align:center;"><a href="http://affectioncode.wordpress.com/files/2008/06/new_ab_nginx_n1000_c10dat.png"><img class="alignnone size-full wp-image-22" src="http://affectioncode.wordpress.com/files/2008/06/new_ab_nginx_n1000_c10dat.png" alt="Nginx — 10 concurrent connections" width="400" height="300" /></a></p>
<p style="text-align:center;"><strong>HAProxy — 10 concurrent connections</strong></p>
<p style="text-align:center;"><a href="http://affectioncode.wordpress.com/files/2008/06/new_ab_haproxy_n1000_c10dat.png"><img class="alignnone size-full wp-image-18" src="http://affectioncode.wordpress.com/files/2008/06/new_ab_haproxy_n1000_c10dat.png" alt="HAProxy — 10 concurrent connections" width="400" height="300" /></a></p>
<p style="text-align:center;"><strong>Nginx — 30 concurrent connections</strong></p>
<p style="text-align:center;"><a href="http://affectioncode.wordpress.com/files/2008/06/new_ab_nginx_n1000_c30dat.png"><img class="alignnone size-full wp-image-23" src="http://affectioncode.wordpress.com/files/2008/06/new_ab_nginx_n1000_c30dat.png" alt="Nginx — 10 concurrent connections" width="400" height="300" /></a></p>
<p style="text-align:center;"><strong>HAProxy — 30 concurrent connections</strong></p>
<p style="text-align:center;"><a href="http://affectioncode.files.wordpress.com/2008/06/new_ab_haproxy_n1000_c30dat1.png"><img class="alignnone size-full wp-image-25" src="http://affectioncode.wordpress.com/files/2008/06/new_ab_haproxy_n1000_c30dat1.png" alt="HAProxy — 30 concurrent connections" width="400" height="300" /></a></p>
<p style="text-align:left;">HAproxy comes out on top with regard to requests/second — at 30 concurrent connections, we get 218 req/s compared to 162 req/s for Nginx — but the real difference here is in the distribution of response time.</p>
<p>At 3 concurrent connections, Nginx begins to serve <em>every</em> request a bit more slowly, whereas HAProxy at 10 concurrnet connections manages to deliver 95% of the requests all within the time of the fastest request. At the same time, Nginx performance is all over the map while HAProxy remains fairly consistent. Unfortunately, this evenness happens at the expense of returning a small number of connections extremely slowly.</p>
<p>I'm uncertain if HAProxy imposes an absolute ordering on the request queue; since backends tend to be full, perhaps some connections simply sit around for a long time without being scheduled. That would explain the blips on the graph; in one test session I had a single request taking 47 seconds.</p></div>
<p style="text-align:left;">In a real-world situation, some of these requests would simply time out, hopefully to be rescued by a friendly "sorry, we're overloaded" error page. Is this an acceptable compromise between performance and responsiveness? I think it is, given that they should only occur during exceptional load; in such situations I prefer serving really fast pages to most users and possibly disappointing an extremely small number of users, rather than letting everyone suffer.</p>
<p style="text-align:left;">I think these results show that HAProxy is a better choice for us. The additional features and fine-grained proxy control are also extremely welcome. HAProxy's lack of support for sharing static files means that we will also put Nginx behind HAProxy and route requests accordingly.</p>
<p style="text-align:left;">You can <a href="http://purefiction.net/paste/haproxy_vs_nginx_data.tar.bz2">download the raw data here</a>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Here's the secret!]]></title>
<link>http://edogawaconan.wordpress.com/?p=276</link>
<pubDate>Wed, 04 Jun 2008 13:52:25 +0000</pubDate>
<dc:creator>EdogawaConan</dc:creator>
<guid>http://edogawaconan.wordpress.com/?p=276</guid>
<description><![CDATA[
(moar nginx post. And with totally unrelated pics)
If you find &#8220;No file specified&#8221; erro]]></description>
<content:encoded><![CDATA[<p style="text-align:center;"><a href="http://edogawaconan.files.wordpress.com/2008/06/secret.jpg"><img class="size-medium wp-image-277" src="http://edogawaconan.wordpress.com/files/2008/06/secret.jpg?w=300" alt="" width="300" height="225" /></a></p>
<p>(moar nginx post. And with totally unrelated pics)</p>
<p>If you find "No file specified" error message disturbing (as I did), here's the configuration to remove it!<br />
<code>location ~ \.php$ {<br />
<strong>if (!-e /var/www/htdocs/genshiken.unit.itb.ac.id$fastcgi_script_name) {<br />
return 404;<br />
break;<br />
}</strong><br />
include /etc/nginx/fastcgi_params;<br />
fastcgi_pass 127.0.0.1:55555;<br />
fastcgi_index index.php;<br />
fastcgi_param  SCRIPT_FILENAME    /var/www/htdocs/genshiken.unit.itb.ac.id$fastcgi_script_name;<br />
}</code><br />
Basically the key is using full pathname to check the file availability. Using normal <code>if (-f $request_filename)</code> won't work.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Google App Engine SDK Nginx Proxy Pass proxy_pass Ubuntu]]></title>
<link>http://bookmarks.honewatson.com/2008/05/28/google-app-engine-sdk-nginx-proxy-pass-proxy_pass-ubuntu/</link>
<pubDate>Wed, 28 May 2008 08:53:38 +0000</pubDate>
<dc:creator>honewatson</dc:creator>
<guid>http://bookmarks.honewatson.com/2008/05/28/google-app-engine-sdk-nginx-proxy-pass-proxy_pass-ubuntu/</guid>
<description><![CDATA[Here&#8217;s a quick set up for Google App Engine&#8217;s SDK on Nginx.



server {
listen       80;]]></description>
<content:encoded><![CDATA[<p>Here's a quick set up for Google App Engine's SDK on Nginx.</p>
<p><!--more--></p>
<p class="code">
<code><br />
server {<br />
listen       80;<br />
server_name  yourhotdomain.com;<br />
access_log  logs/yourhotdomain.access.log;<br />
location / {<br />
proxy_pass  http://localhost:8080;<br />
}<br />
}<br />
</code>
</p>
<p>If you want to change the datastore location do this:</p>
<p class="code">
<code><br />
sudo ./dev_appserver.py helloworld/<br />
ctrl c<br />
cp /tmp/dev_appserver.datastore /some_new_path/dev_appserver.datastore<br />
sudo ./dev_appserver.py --datastore_path=/some_new_path/dev_appserver.datastore helloworld/<br />
</code>
</p>
<p>Your App Engine app should now be running on 'yourhotdomain.com'.</p>
<p>If you want to run it on your local computer just change your /etc/hosts file to include 'yourhotdomain.com'</p>
<p class="code">
<code><br />
127.0.0.1      yourhotdomain.com	yourhotdomain.com<br />
</code></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Install and configure NGINX  and Mongrel for Rails]]></title>
<link>http://laurentbois.wordpress.com/?p=294</link>
<pubDate>Tue, 06 May 2008 10:10:59 +0000</pubDate>
<dc:creator>lbois</dc:creator>
<guid>http://laurentbois.wordpress.com/?p=294</guid>
<description><![CDATA[Some times ago i wrote an article about installing a Rails stack on Debian Etch (our production serv]]></description>
<content:encoded><![CDATA[<p>Some times ago i wrote an article about installing a Rails stack on Debian Etch (our production server), then how to configure Apache 2 + fcgid to run our Rails app.</p>
<p>After several tests with this deployment configuration , we encountered some problems of performance (i will detail what our application does in a future article) :</p>
<p>- First with Apache server, after an idle time, then accessing a page of our application, we should wait for a long time before our page loads. Seems fcgid processes take a long time to (re)start.</p>
<p>- In our application, we deliver some files with a download controller : for bigger files, the download was very long.</p>
<p>We decided recently to switch the Apache2 / fcgid  configuration to Mongrel (Ruby HTTP server) + nginx (as proxy in front of Mongrel).</p>
<p><!--more--></p>
<p>I will explain you how to proceed.</p>
<p>We suppose here you have already installed Ruby , Rails, mySQL.</p>
<p>Connect as root and follow these steps :</p>
<p><strong>First stop Apache2 :</strong></p>
<p>#/etc/init.d/apache2 stop</p>
<p><strong>Install Mongrel</strong></p>
<p># gem install mongrel</p>
<p># gem install mongrel_cluster</p>
<p><strong>Install nginx:</strong></p>
<p># aptitude install nginx</p>
<p><strong>Configure what we have installed</strong></p>
<p>We have to setup our server apps to boot when the server starts, and shutdown gracefully when the server reboots.</p>
<p>Concerning nginx, it already did automatically this setup at install:</p>
<p># ls -l /etc/rc?.d/*nginx<br />
lrwxrwxrwx 1 root root 15 2008-05-05 11:00 /etc/rc0.d/K20nginx -&#62; ../init.d/nginx<br />
lrwxrwxrwx 1 root root 15 2008-05-05 11:00 /etc/rc1.d/K20nginx -&#62; ../init.d/nginx<br />
lrwxrwxrwx 1 root root 15 2008-05-05 11:00 /etc/rc2.d/S20nginx -&#62; ../init.d/nginx<br />
lrwxrwxrwx 1 root root 15 2008-05-05 11:00 /etc/rc3.d/S20nginx -&#62; ../init.d/nginx<br />
lrwxrwxrwx 1 root root 15 2008-05-05 11:00 /etc/rc4.d/S20nginx -&#62; ../init.d/nginx<br />
lrwxrwxrwx 1 root root 15 2008-05-05 11:00 /etc/rc5.d/S20nginx -&#62; ../init.d/nginx<br />
lrwxrwxrwx 1 root root 15 2008-05-05 11:00 /etc/rc6.d/K20nginx -&#62; ../init.d/nginx</p>
<p>As you can see, for runlevels 0, 1 and 6 there is a <strong>K</strong> at the beginning of the link, for runlevels 2, 3, 4 and 5, there is a <strong>S</strong>. Those two letters stands for <strong>K</strong><em>ill</em> and <strong>S</strong><em>tart</em>.<br />
On Debian (and Ubuntu), runlevels 2, 3, 4 and 5 are multi-users runlevels.<br />
Runlevel 0 is <em>Halt</em>.<br />
Runlevel 1 is <em>single user mode</em><br />
Runlevel 6 is <em>reboot</em></p>
<p><strong>Remove Apache 2 service</strong></p>
<p>By hand you should remove every link /etc/rc.X/*apache2.</p>
<p>Using update-rc.d is as simple as :</p>
<p># update-rc.d -f apache2 remove</p>
<p>Removing any system startup links for /etc/init.d/apache2 ...<br />
/etc/rc0.d/K09apache2<br />
/etc/rc1.d/K09apache2<br />
/etc/rc2.d/S91apache2<br />
/etc/rc3.d/S91apache2<br />
/etc/rc4.d/S91apache2<br />
/etc/rc5.d/S91apache2<br />
/etc/rc6.d/K09apache2</p>
<p><strong>Add Mongrel service for automatic startup/stop</strong></p>
<p># cp /usr/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.5/resources/mongrel_cluster /etc/init.d/mongrel_cluster</p>
<p>Edit /etc/init.d/mongrel_cluster and add the following environment setup:</p>
<pre>PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local:/usr/local/sbin:/usr/local/bin</pre>
<p># chmod +x /etc/init.d/mongrel_cluster</p>
<p># update-rc.d mongrel_cluster defaults<br />
Adding system startup for /etc/init.d/mongrel_cluster ...<br />
/etc/rc0.d/K20mongrel_cluster -&#62; ../init.d/mongrel_cluster<br />
/etc/rc1.d/K20mongrel_cluster -&#62; ../init.d/mongrel_cluster<br />
/etc/rc6.d/K20mongrel_cluster -&#62; ../init.d/mongrel_cluster<br />
/etc/rc2.d/S20mongrel_cluster -&#62; ../init.d/mongrel_cluster<br />
/etc/rc3.d/S20mongrel_cluster -&#62; ../init.d/mongrel_cluster<br />
/etc/rc4.d/S20mongrel_cluster -&#62; ../init.d/mongrel_cluster<br />
/etc/rc5.d/S20mongrel_cluster -&#62; ../init.d/mongrel_cluster</p>
<p>But as you can see, the default value is 20 which is pretty different than 91 ... a S20 link is started before a S91 and and K91 is kill before K20.</p>
<p>I decided to startup nginx after mongrel, and stop nginx before mongrel. I'll use 23 for nginx.</p>
<p>First remove nginx symlinks:</p>
<p># update-rc.d -f nginx remove</p>
<p>Then create symlinks for nginx with custom priorities :</p>
<p># update-rc.d nginx defaults 23 23<br />
Adding system startup for /etc/init.d/nginx ...<br />
/etc/rc0.d/K23nginx -&#62; ../init.d/nginx<br />
/etc/rc1.d/K23nginx -&#62; ../init.d/nginx<br />
/etc/rc6.d/K23nginx -&#62; ../init.d/nginx<br />
/etc/rc2.d/S23nginx -&#62; ../init.d/nginx<br />
/etc/rc3.d/S23nginx -&#62; ../init.d/nginx<br />
/etc/rc4.d/S23nginx -&#62; ../init.d/nginx<br />
/etc/rc5.d/S23nginx -&#62; ../init.d/nginx<br />
Create the folder /etc/mongrel_cluster that our Rails app Mongrel config will live in.</p>
<p># mkdir /etc/mongrel_cluster</p>
<p>Generate the Rails app Mongrel config file:</p>
<p># mongrel_rails cluster::configure -e production -p 8001 -N 3 -c /path/to/rails/app -C /path/to/rails/app/config/mongrel_cluster.yml -P /path/to/rails/app/log/mongrel.pid -l /path/to/rails/app/log/mongrel.log --user &#60;user&#62; --group &#60;group&#62;  -a 127.0.0.1</p>
<p>Verify the config file (/path/to/rails/app/config/mongrel_cluster.yml)</p>
<p>user: &#60;user&#62;<br />
cwd: /path/to/rails/app<br />
log_file: /path/to/rails/app/log/mongrel.log<br />
port: "8001"<br />
environment: production<br />
group: &#60;group&#62;<br />
address: 127.0.0.1<br />
pid_file: /path/to/rails/app/mongrel.pid<br />
servers: 3</p>
<p>Create a symlink to this file into /etc/mongrel_cluster :</p>
<pre>ln -s /path/to/your/rails/app/mongrel_cluster.yml /etc/mongrel_cluster/YOURAPPNAME.yml</pre>
<p><strong>Configure nginx</strong></p>
<p>We now need to edit our nginx.conf file found in <strong>/etc/nginx/nginx.conf</strong> to set it up. Edit the values found in my <a href="http://laurentbois.wordpress.com/files/2008/05/nginx.pdf" target="_blank">nginx.conf</a> file and modify it to suit your needs.</p>
<p>Nginx is a powerful UNIX tool.</p>
<p>You have noticed we used here <a href="http://nginx.net/" target="_blank">nginx</a> as Reverse-Proxy in front of a Mongrel cluster; if the web-server (Mongrel in our case) cannot handle more load , you can even put nginx before the web-server to use it as web-server to handle requests to static files.</p>
<p>Thanks to nginx flexibility, you can pass any types of requests to web-server server by using <tt>location</tt> sections (all files, only dynamic content requests or some specific locations in your web-server tree):</p>
<div class="codecolorer-container nginx">
<div class="codecolorer" style="font-family:monospace;"><span class="kw1">location</span> / <span class="br0">{</span><br />
<span class="kw2">proxy_pass</span> <span class="re2">http://mongrel:<span class="nu0">8000</span>/</span>;<br />
<span class="kw2">proxy_set_header</span> <span class="kw4">X-Real-IP</span> <span class="re0">$remote_addr</span>;<br />
<span class="br0">}</span></div>
</div>
<p>It should be fine now! Reboot your server and test everything is up after startup :</p>
<p># shutdown -r now<br />
Nota : Another tool to test: <a href="nginx google analytics top 5" target="_blank">Varnish</a>, an high-performance HTTP-accelerator.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Load Balancer Update]]></title>
<link>http://barry.wordpress.com/?p=191</link>
<pubDate>Mon, 28 Apr 2008 18:47:11 +0000</pubDate>
<dc:creator>Barry</dc:creator>
<guid>http://barry.wordpress.com/?p=191</guid>
<description><![CDATA[A while back, I posted about some testing we were doing of various software load balancers for WordP]]></description>
<content:encoded><![CDATA[<p>A while back, I <a href="http://barry.wordpress.com/2006/08/30/load-balancer-testing/">posted</a> about some testing we were doing of various software load balancers for WordPress.com.  We chose to use <a href="http://www.apsis.ch/pound/">Pound</a> and have been using it past 2-ish years.  We started to run into some issues, however, so we starting looking elsewhere.  Some of these problems were:</p>
<ul>
<li>Lack of true configuration reload support made managing our 20+ load balancers cumbersome.  We had a solution (hack) in place, but it was getting to be a pain.</li>
<li>When something would break on the backend and cause 20-50k connections to pile up, the thread creation would cause huge load spikes and sometimes render the servers useless.</li>
<li>As we started to push 700-1000 requests per second per load balancer, it seemed things started to slow down.  Hard to get quantitative data on this because page load times are dependent on so many things.</li>
</ul>
<p>So...  A couple weeks ago we finished converting all our load balancers to <a href="http://nginx.net/">Nginx</a>.  We have been using Nginx for <a href="http://en.gravatar.com/">Gravatar</a> for a few months and have been impressed by its performance, so moving WordPress.com over was the obvious next step.  Here is a graph that shows CPU usage before and after the switch.  Pretty impressive!</p>
<p><a href="http://barry.files.wordpress.com/2008/04/nginx-cpu.png"><img class="aligncenter size-full wp-image-192" src="http://barry.wordpress.com/files/2008/04/nginx-cpu.png" alt="" width="450" height="343" /></a>  </p>
<p>Before choosing nginx, we looked at <a href="http://haproxy.1wt.eu/">HAProxy</a>, <a href="http://www.danga.com/perlbal/">Perlbal</a>, and <a href="http://www.linuxvirtualserver.org/">LVS</a>. Here are some of the reasons we chose Nginx:</p>
<ul>
<li>Easy and flexible configuration (true config "reload" support has made my life easier)</li>
<li>Can also be used as a web server, which allows us to simplify our software stack (we are not using nginx as a web server currently, but may switch at some point).</li>
<li>Only software we tested which could handle 8000 (live traffic, not benchmark) requests/second on a single server</li>
</ul>
<div>We are currently using Nginx 0.6.29 with the <a href="http://wiki.codemongers.com/NginxHttpUpstreamRequestHashModule">upstream hash module</a>  which gives us the <a href="http://barry.wordpress.com/2007/11/01/static-hostname-hashing-in-pound/">static hashing</a> we need to proxy to varnish.  We are regularly serving about 8-9k requests/second  and about 1.2Gbit/sec through a few Nginx instances and have plenty of room to grow!</div>
<p> </p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Nginx SuperCache WP Super Cache Plugin Rewrites Wordpress Mu]]></title>
<link>http://bookmarks.honewatson.com/2008/04/24/nginx-supercache-wp-super-cache-plugin-rewrites-wordpress-mu/</link>
<pubDate>Thu, 24 Apr 2008 01:39:28 +0000</pubDate>
<dc:creator>honewatson</dc:creator>
<guid>http://bookmarks.honewatson.com/2008/04/24/nginx-supercache-wp-super-cache-plugin-rewrites-wordpress-mu/</guid>
<description><![CDATA[Nginx combined with WP Super Cache for WordPress Mu is an interesting idea.  However, you can potent]]></description>
<content:encoded><![CDATA[<p>Nginx combined with WP Super Cache for Wordpress Mu is an interesting idea.  However, you can <a href="http://www.ruby-forum.com/topic/140396">potentially set up</a> a simpler, and superior caching system using internal Nginx features that replaces the need for Super Cache.</p>
<p><!--more--></p>
<p>I will be working on this WP Super Cache replacement using Nginx but in the mean time here is a set up for Nginx and WP Super Cache rewrites.</p>
<p>First you need install 0.6.29 or up which has a module called Gzip Pre-Compression Module.  Download and unzip the latest Nginx.  Then set it up like this:</p>
<p class="code">
<code><br />
./configure --with-http_gzip_static_module  --with-http_ssl_module<br />
make<br />
sudo make install<br />
</code>
</p>
<p>In the http area of your nginx.conf file include:</p>
<p class="code">
<code><br />
gzip_static on;<br />
gzip_http_version   1.1;<br />
gzip_proxied        expired no-cache no-store private auth;<br />
gzip_disable        "MSIE [1-6]\.";<br />
gzip_vary           on;<br />
</code>
</p>
<p>Now what the above setting does is makes Nginx first see if there is a file in the directory already gzipped.  If there is no gzip file Nginx will gzip the file on the fly then send the file out.</p>
<p>Now for the rewrites:</p>
<blockquote><p>
server {<br />
listen       80;<br />
server_name  yourmublogs.com *.yourmublogs.com;</p>
<p>location ~* ^.+\.(html&#124;jpg&#124;jpeg&#124;gif&#124;png&#124;ico&#124;css&#124;zip&#124;tgz&#124;gz&#124;rar&#124;bz2&#124;doc&#124;xls&#124;exe&#124;pdf&#124;ppt&#124;txt&#124;tar&#124;mid&#124;midi&#124;wav&#124;bmp&#124;rtf&#124;js)$<br />
{<br />
root /home/yourmublogs/public_html;<br />
rewrite ^/.*(/(wp-admin&#124;wp-includes)/.*\.(html&#124;jpg&#124;jpeg&#124;gif&#124;png&#124;ico&#124;css&#124;zip&#124;tgz&#124;gz&#124;rar&#124;bz2&#124;doc&#124;xls&#124;exe&#124;pdf&#124;ppt&#124;txt&#124;tar&#124;mid&#124;midi&#124;wav&#124;bmp&#124;rtf&#124;js))$ $1 last;<br />
rewrite ^/.*(/wp-content/(themes&#124;plugins&#124;mu-plugins)/.*\.(html&#124;jpg&#124;jpeg&#124;gif&#124;png&#124;ico&#124;css&#124;zip&#124;tgz&#124;gz&#124;rar&#124;bz2&#124;doc&#124;xls&#124;exe&#124;pdf&#124;ppt&#124;txt&#124;tar&#124;mid&#124;midi&#124;wav&#124;bmp&#124;rtf&#124;js))$ $1 last;<br />
rewrite ^.*/files/(.*(html&#124;jpg&#124;jpeg&#124;gif&#124;png&#124;ico&#124;css&#124;zip&#124;tgz&#124;gz&#124;rar&#124;bz2&#124;doc&#124;xls&#124;exe&#124;pdf&#124;ppt&#124;txt&#124;tar&#124;mid&#124;midi&#124;wav&#124;bmp&#124;rtf&#124;js))$ /wp-content/blogs.php?file=$1 last;</p>
<p>rewrite ^.*/files/(.*(html&#124;jpg&#124;jpeg&#124;gif&#124;png&#124;ico&#124;css&#124;zip&#124;tgz&#124;gz&#124;rar&#124;bz2&#124;doc&#124;xls&#124;exe&#124;pdf&#124;ppt&#124;txt&#124;tar&#124;mid&#124;midi&#124;wav&#124;bmp&#124;rtf&#124;js))$ /wp-content/blogs.php?file=$1 last;<br />
expires 10d;<br />
break;<br />
}</p>
<p>location / {<br />
root   /home/yourmublogs/public_html;<br />
index  index.html index.htm index.php;</p>
<p>if (!-e $request_filename) {<br />
rewrite ^.+?(/wp-.*) $1 last;<br />
rewrite ^.+?(/.*\.php)$ $1 last;<br />
}</p>
<p>if ($http_cookie !~* "comment_author_&#124;wordpress&#124;wp-postpass_" ) {<br />
rewrite ^(.*)$ /wp-content/cache/supercache/$http_host/$1index.html;<br />
break;<br />
}</p>
<p>error_page    404  =  @tricky;<br />
}</p>
<p>location @tricky {<br />
rewrite ^ /index.php last;<br />
rewrite ^/.*(/wp-login.php)$ $1;<br />
rewrite ^/.*(/wp-admin/.*\.php)$ $1;<br />
rewrite ^/.*(/wp-includes/.*\.php)$ $1;<br />
fastcgi_pass   127.0.0.1:8084;<br />
fastcgi_index  index.php;<br />
fastcgi_param  SCRIPT_FILENAME /home/yourmublogs/public_html$fastcgi_script_name;<br />
include /usr/local/nginx/conf/fastcgi_params;<br />
}</p>
<p>error_page   500 502 503 504  /50x.html;<br />
location = /50x.html {<br />
root   html;<br />
}<br />
}</p>
<p>server {<br />
server_name www.yourmublogs.com;<br />
rewrite ^/(.*) http://yourmublogs.com/$1 permanent;<br />
}</p>
</blockquote>
<p>Ajax could be used for commenting.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Multiple FastCgi PHP Servers Nginx Load Balancing]]></title>
<link>http://bookmarks.honewatson.com/2008/04/24/multiple-fastcgi-php-servers-nginx-load-balancing/</link>
<pubDate>Thu, 24 Apr 2008 01:16:43 +0000</pubDate>
<dc:creator>honewatson</dc:creator>
<guid>http://bookmarks.honewatson.com/2008/04/24/multiple-fastcgi-php-servers-nginx-load-balancing/</guid>
<description><![CDATA[Update: Do not use this config for php.  Instead use php-fpm with xcache.
To configure Nginx to loa]]></description>
<content:encoded><![CDATA[<p><strong><em>Update: </em></strong>Do not use this config for php.  Instead use php-fpm with xcache.</p>
<p>To configure Nginx to load balance multiple FastCgi servers use this type of configuration:</p>
<blockquote><p>upstream servercom {<br />
server 127.0.0.1:44440;<br />
server 127.0.0.1:44441;<br />
server 127.0.0.1:44442;<br />
server 127.0.0.1:44443;<br />
server 127.0.0.1:44444;<br />
}</p>
<p>location ~ \.php$ {<br />
fastcgi_pass servercom;<br />
fastcgi_index stream.app;<br />
fastcgi_param SCRIPT_FILENAME /var/www/htdocs$fastcgi_script_name;<br />
include /etc/nginx/fastcgi.conf;<br />
}</p></blockquote>
<p><!--more--></p>
<p>If you're using spawn-fcgi from lighttpd consider replacing it with <a href="http://php-fpm.anight.org/docs.html">php-fpm</a>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Open source software at Smarkets]]></title>
<link>http://smarkets.wordpress.com/?p=19</link>
<pubDate>Wed, 23 Apr 2008 11:29:59 +0000</pubDate>
<dc:creator>Hunter Morris</dc:creator>
<guid>http://smarkets.wordpress.com/?p=19</guid>
<description><![CDATA[I&#8217;m an unabashed open source fanboy.  At Smarkets, I use a lot of software written by other pe]]></description>
<content:encoded><![CDATA[<p>I'm an unabashed open source fanboy.  At Smarkets, I use a lot of software written by other people.  Here is a quick summary of the Smarkets stack; think of them as geek shoutouts.</p>
<ul>
<li><a href="http://www.erlang.org/">Erlang</a> - Almost everything is built atop the Erlang/OTP application system. I like <a href="http://en.wikipedia.org/wiki/Functional_programming">functional programming</a>. It is easier to manage complexity in a language with reasonably isolated <a href="http://en.wikipedia.org/wiki/Side_effect_%28computer_science%29">side effects</a>. Erlang's <a href="http://en.wikipedia.org/wiki/Concurrency_%28computer_science%29">concurrency</a> primitives have been touted many times before, and conceptualising concurrent systems as communicating sequential processes now feels a lot more natural than other paradigms. As Damien Katz <a href="http://damienkatz.net/2008/04/lisp_as_blub.html">recently mentioned</a>, systems built atop Erlang/OTP don't seem to suffer the same failures under high load as certain other garbage collected languages do.</li>
<li><a href="http://code.google.com/p/distel/">Distel</a> on <a href="http://www.gnu.org/software/emacs/">Emacs</a> - When writing code (and actually quite a bit more), I like Emacs. When writing Erlang, I like Distel. It provides a natural entry point for debugging pieces of Erlang code. Getting Emacs to communicate with an inferior Erlang VM is especially useful for rapid prototyping. Being able to do everything within Emacs is good for productivity.</li>
<li><a href="http://www.erlang.org/doc/apps/mnesia/index.html">Mnesia</a> - Arbitrary term storage is a simple way to avoid having to interface with another database management system. Because Mnesia is part of Erlang/OTP, you get it for free.</li>
<li><a href="http://code.google.com/p/mochiweb/">Mochiweb</a> and <a href="http://nginx.net/">nginx</a> - Thanks to <a href="http://bob.pythonmac.org/">Bob Ippolito</a> and Matthew Dempsky (and others I'm sure I've missed) for the mochiweb HTTP toolkit. It's lightweight and embeddable, so it was very easy for us to integrate with our backend. Nginx performs well and is very simple to integrate with a backend powered by mochiweb.</li>
<li><a href="http://code.google.com/p/sgte/">sgte</a> and <a href="http://www.stringtemplate.org/">StringTemplate</a> - <a href="http://blog.sgconsulting.it/">Filippo Pacini's</a> sgte template engine ("inspired by" StringTemplate) was the basis for our templating system.</li>
<li><a href="http://www.stacken.kth.se/project/yxa/">YXA</a> - While we don't specifically deploy any SIP software, YXA is a great example of well-written Erlang. I learned a lot from reading through Magnus Ahltorp and Fredrik Thulin's code. It's been around for several years and has matured quite a bit as a result.</li>
<li><a href="http://en.wikipedia.org/wiki/Flat_file">Flat files</a> - Writing a binary file to disk is sometimes overlooked as a solid way to persist sequential data that's only needed locally. I'm not sure who I should thank here, but I think the list would probably be pretty long.</li>
</ul>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Nginx SSL passphrase at startup]]></title>
<link>http://pandemoniumillusion.wordpress.com/?p=9</link>
<pubDate>Mon, 21 Apr 2008 15:47:17 +0000</pubDate>
<dc:creator>jamstooks</dc:creator>
<guid>http://pandemoniumillusion.wordpress.com/?p=9</guid>
<description><![CDATA[I&#8217;m using nginx to serve all my media files and it is also a proxy to my apache server. I]]></description>
<content:encoded><![CDATA[<p>I'm using <a href="http://wiki.codemongers.com/Main">nginx</a> to serve all my media files and it is also a proxy to my <a href="http://www.apache.org/">apache</a> server. I've been using SSL encryption for specific sections of the site, using nginx's built in SSL support:<br />
<code><br />
server {</p>
<p>    listen 443;<br />
    server_name host.com;</p>
<p>    access_log /var/log/nginx/register/host.access.log;</p>
<p>    # SSL<br />
    ssl on;<br />
    ssl_certificate /home/jamstooks/ssl_certs/2008_cert/host.com.crt;<br />
    ssl_certificate_key /home/jamstooks/ssl_certs/2008_cert/host.com.key;</p>
<p>    # Register<br />
    location ^~ /register/ {<br />
        proxy_pass         http://127.0.0.1:8080/;<br />
        proxy_redirect     off;</p>
<p>        proxy_set_header   Host             register.host.com;<br />
        proxy_set_header   X-Real-IP        $remote_addr;<br />
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;</p>
<p>        client_max_body_size       10m;<br />
        client_body_buffer_size    128k;</p>
<p>        proxy_connect_timeout      90;<br />
        proxy_send_timeout         90;<br />
        proxy_read_timeout         90;</p>
<p>        proxy_buffer_size          4k;<br />
        proxy_buffers              4 32k;<br />
        proxy_busy_buffers_size    64k;<br />
        proxy_temp_file_write_size 64k;<br />
    }</p>
<p>    # Redirect everything else<br />
    location / {<br />
        rewrite ^(.*) http://www.host.com$1 permanent;<br />
    }</p>
<p>}<br />
</code><br />
When I boot up Nginx it requests the passphrase for the encrypted certificate key. This is a huge problem though when there are unexpected shutdowns because the Nginx process won't restart.</p>
<p>However, the problem is not with Nginx, but with the certificate itself. Because it is encrypted, Nginx can't use it unless it until it has the pass-phrase. So, the easiest way to solve this is to provide Nginx with a decrypted version of the certificate key. The only issue is that you need to tie down the permissions on the file so that no one can access it at use it to impersonate you.</p>
<p>Apache details the process <a href="http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html#removepassphrase">here</a>:</p>
<blockquote><p>
# Remove the encryption from the RSA private key (while keeping a backup copy of the original file):</p>
<p>$ cp server.key server.key.org<br />
$ openssl rsa -in server.key.org -out server.key</p>
<p># Make sure the server.key file is only readable by root:</p>
<p>$ chmod 400 server.key
</p></blockquote>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Tuning FreeBSD to serve 100-200 thousands of connections]]></title>
<link>http://rerepi.wordpress.com/?p=11</link>
<pubDate>Sat, 19 Apr 2008 18:50:58 +0000</pubDate>
<dc:creator>rerepi</dc:creator>
<guid>http://rerepi.wordpress.com/?p=11</guid>
<description><![CDATA[I&#8217;m back finally. There&#8217;s the translation of the Igor Sysoev&#8217;s report made on the ]]></description>
<content:encoded><![CDATA[<p style="margin-bottom:0;">I'm back finally. There's the translation of the Igor Sysoev's report made on the <a title="Russina internet Technologies site (Russain language!)" href="http://www.rit2008.ru/">RIT</a> conference. Igor Sysoev is the creator of one of the most used lightweight http servers in Russia and the world - <a title="Sysoev's website" href="http://sysoev.ru/en/">nginx</a>.<!--more--></p>
<p style="margin-bottom:0;">I also use nginx as reverse-proxy and load balancer in my project.</p>
<h2>mbuf clusters</h2>
<p style="margin-bottom:0;">FreeBSD stores the network data in the mbuf clusters 2Kb each, but only 1500B are used in each cluster (the size of the Ethernet packet)</p>
<h2>mbufs</h2>
<p>For each mbuf cluster there is “mbuf” structure needed, which have 256B in size and used to organize mbuf clusters in chains. There's possibility to store some additional useful 100B data into the mbuf, but it is not always used.</p>
<p>If server have the RAM of 1Gb or more 25 thousands of mbuf clusters will be created by default but it is not enough in some cases.</p>
<p>When there's no any free mbuf clusters available FreeBSD enters the zonelimit state and stops to answer to any network requests. You can see it as the `zoneli` state in the output of the `top` command.</p>
<p>To fix this problem the only solution is to log in through the local console and reboot the system. It is impossible to kill the process in `zoneli` state. This problem is also actual for Linux 2.6.x but even local console will not work in this state for Linux.</p>
<p>There is the patch that fixes the problem, it returns ENOBUFS error,  which indicates entering the `zoneli` state and the program may close some connections when receives the error. Unfortunately this patch have not been merged into FreeBSD yet.</p>
<p>The state of used mbuf clusters can be checked by the following command:</p>
<blockquote><p>&#62; netstat -m<br />
1/1421/1425 mbufs in use (current/cache/total)</p>
<p>0/614/614/25600 mbufs clusters in use (current/cache/total/max)
</p></blockquote>
<p>You can increase quantity of the mbufs clusters through the kern.ipc.mbclusters parameter:</p>
<blockquote><p>&#62; sysctl kern.ipc.mbclusters=65536</p></blockquote>
<p>For earlier versions of FreeBSD mbuf clusters can be configured only in boot time:</p>
<blockquote><p>/boot/loader.conf:</p>
<p>kern.ipc.mbclusters=65536</p></blockquote>
<p>25000 mbuf clusters takes bout a 50Mb in the memory, 32000 – 74Mb, 65000 – 144 Mb (raises by the power of 2). 65000 is the boundary value and I can't recommend to exceed it without increasing address space of the kernel first.</p>
<h2>Increasing the amount of memory available for kernel</h2>
<p>The default space for the kernel in memory is 1Gb for i386 architecture. To set it to 2Gb specify the following line in the kernel configuration file:</p>
<blockquote><p>options KVA_PAGES=512</p></blockquote>
<p>On the amd64 the the KVA is always 2Gb and there's no possibility to increase it yet.</p>
<p>In addition to increasing the address space there's the possibility to increase the limit of the physical memory available for kernel (320Mb by default). Let's increase it to 1Gb:</p>
<blockquote><p>/boot/loader.conf:</p>
<p>vm.kmem_size=1G</p></blockquote>
<p>And reserve 275Mb for mbuf cluster from that space:</p>
<blockquote><p>sysctl kern.ipc.nmbclusters=262144</p></blockquote>
<h2>Establishing the connection. syncache and syncookies</h2>
<p>There's approximately 100 bytes needed to serve one single connection.<br />
Approximatelly 100 bytes space is used for single unfinished connection in syncache.<br />
There's possibility to store information about 15000 connections in memory. Approximately.</p>
<p>Snyncache parameters can bee seen by “sysctl net.inet.tcp.syncache” command (read-only).</p>
<p>Syncache parameters can be changed only during boot time:</p>
<blockquote><p>/boot/loader.conf:<br />
net.inet.tcp.syncache.hashsize=1024<br />
net.inet.tcp.syncache.bucketlimit=100</p></blockquote>
<p>when the new connection does not fit into overfull syncache FreeBSD enters the `syncookies` state (TCP SYN cookies). This possibility is enabled with:</p>
<blockquote><p>sysctl net.inet.tcp.syncookies=1</p></blockquote>
<p>The syncache population and the syncookies stats can be seen with `ntestat -s -p tcp` command.</p>
<p>When the connection is accepted it comes to the “listen socket queue”</p>
<p>Their's stats can be seen with the `netstat -Lan` command.</p>
<p>Inreasing of the queue is possible with the `sysctl kern.ipc.somaxconn=4096` command</p>
<p>Whan the connection is accepted FreeBSD creates the sockets structures.</p>
<p>To increase the limit of the open sockets:</p>
<blockquote><p>sysctl kern.ipc.maxsockets=204800</p></blockquote>
<p>In earlier versions:</p>
<blockquote><p>/boot/loader.conf:<br />
kern.ipc.maxsockets=204800</p></blockquote>
<p>The current state can be seen with the following command:</p>
<blockquote><p>&#62; vmstat -z</p></blockquote>
<h2>tcb hash</h2>
<p>If the server processes several tens of thousands connections the tcb hash allows to detect the target connection for each incoming tcp packet quickly.</p>
<p>The tcb hash is 512 bytes by default.</p>
<p style="page-break-before:always;">The current size can be seen with:</p>
<blockquote><p>sysctl net.inet.tcp.tcbhashsize</p></blockquote>
<p>It is changeable in the boot time:</p>
<blockquote><p>/boot/loader.conf:&#124;<br />
sysctl net.inet.tcp.tcbhashsize=4096</p></blockquote>
<h2>Files</h2>
<p>Applicatios are working not with the sockets but with files. And there's file descriptor needed for each socket because of that. To increase:</p>
<blockquote><p>sysctl kern.maxfiles=204800<br />
sysctl kern.maxfilesperproc=200000</p></blockquote>
<p>These options can be changed on the live system but they will not affect already running processes. nginx have the ability to change the open files limit on the fly:</p>
<blockquote><p>nginx.conf:<br />
worker_limit_nofile  200000;<br />
events {<br />
worker_connections  200000;<br />
}</p></blockquote>
<h2>receive buffers</h2>
<p>Buffers for incoming data. 64Kb by default, if there's no large uploads can be decreased to 8Kb (decreases the probability of overflow during a DDoS attack):</p>
<blockquote><p>sysctl net.inet.tcp.recvspace=8192</p></blockquote>
<p>For nginx:</p>
<blockquote><p>nginx.conf:<br />
listen 80 default rcvbuf=8k;</p></blockquote>
<h2>send buffers</h2>
<p>Buffers for outgoing data. 32K by default. If data have a small size usually or there's a lack of mbuf clusters it may be decreased:</p>
<blockquote><p>sysctl net.inet.tcp.sendspace=16384</p></blockquote>
<p>For nginx:</p>
<blockquote><p>nginx.conf:<br />
listen 80 default sendbuf=16k;</p></blockquote>
<p>In the case when server has written some data to the socket but the client do not want to receive it the data will live in the kernel for several minutes even after the connection will be closed by timeout. Nginx have the option to erase all data after the timeout:</p>
<blockquote><p>nginx.conf:<br />
reset_timedout_connections on;</p></blockquote>
<h2>sendfile</h2>
<p>Another way to save some mbuf clusters is the sendfile. It uses the kernel file buffers memory to send the data to the network interface without any intermediate buffers usage.</p>
<p>To enable in nginx:</p>
<blockquote><p>nginx.conf:<br />
sendfile on;</p></blockquote>
<p>(you should explicitly switch it off if you're sending files from the partition mounted via smbfs or cifs - <em>ReRePi</em>)</p>
<p>On the i386 platform with 1Gb and more memory 6656 sendfile buffers will be allocated which is usually enough. On the amd64 platform more optimal implementation is used and there's no need in sendbufs at all.</p>
<p>On the sendbuf overflow the process stucks in the `sfbufa` state, but things turns ok after the buffer size is increased:</p>
<blockquote><p>/boot/loader.conf:<br />
kern.ipc.nsfbufs=10240</p></blockquote>
<h2>TIME_WAIT</h2>
<p>After the connection was closed the socket enters the TIME_WAIT state. In this state it can live for 60 seconds by default. This time can be changed with sysctl (in milliseconds divided by 2. 2x30000 MSL = 60 seconds):</p>
<blockquote><p>sysctl net.inet.tcp.mls=30000</p></blockquote>
<h2>TCP/IP ports</h2>
<p>Outgoing connection are bind to the ports from the 49152 – 65535 range (16 thousands). It is better to be increased (1024 – 65535):</p>
<blockquote><p>sysctl net.inet.ip.portrange.first=1024<br />
sysctl net.inet.ip.portrange.last=65535</p></blockquote>
<p>To use ports in natural order instead of random (to make the second connection for the same port impossible before TIME_WAIT):</p>
<blockquote><p>sysctl net.inet.ip.portrange.randomized=0</p></blockquote>
<p>In FreeBSD 6.2 the possibility to not create TIME_WAIT state for localhost connections was added:</p>
<blockquote><p>sysctl net.inet.tcp.nolocaltimewait=1</p></blockquote>
]]></content:encoded>
</item>
<item>
<title><![CDATA[The plain HTTP request was sent to HTTPS port]]></title>
<link>http://bookmarks.honewatson.com/2008/04/15/the-plain-http-request-was-sent-to-https-port/</link>
<pubDate>Tue, 15 Apr 2008 23:36:53 +0000</pubDate>
<dc:creator>honewatson</dc:creator>
<guid>http://bookmarks.honewatson.com/2008/04/15/the-plain-http-request-was-sent-to-https-port/</guid>
<description><![CDATA[&#8220;The plain HTTP request was sent to HTTPS port&#8221; is an Nginx error you can some times get]]></description>
<content:encoded><![CDATA[<p>"The plain HTTP request was sent to HTTPS port" is an Nginx error you can some times get when using applications that are set to redirect to https.</p>
<p><!--more--></p>
<p>An example is <a href="http://bookmarks.honewatson.com/2008/02/21/nginx-phpmyadmin-https/">phpmyadmin</a> where this error can occur.</p>
<p>If you get this error you're missing the following code on your ssl vhost:</p>
<p><code>fastcgi_param HTTPS on;</code></p>
<p>You want to use this line in this kind of context here:</p>
<p><code><br />
        location ~ \.php$ {<br />
            fastcgi_param HTTPS on;<br />
            fastcgi_pass   127.0.0.1:xxxx;<br />
            fastcgi_index  index.php;<br />
            fastcgi_param  SCRIPT_FILENAME /var/www$fastcgi_script_name;<br />
            include        /usr/local/nginx/conf/fastcgi_params;<br />
        }</p>
<p></code></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Goodbye Litespeed, hello Nginx, says Wordpress.com]]></title>
<link>http://fatalerror.wordpress.com/?p=328</link>
<pubDate>Mon, 14 Apr 2008 11:21:53 +0000</pubDate>
<dc:creator>shyam</dc:creator>
<guid>http://fatalerror.wordpress.com/?p=328</guid>
<description><![CDATA[As mentioned earlier, WordPress.com has made the move from Litespeed for their frontend serving need]]></description>
<content:encoded><![CDATA[<p>As mentioned <a href="http://fatalerror.wordpress.com/2007/01/22/wordpresscom-growth-issues-and-the-road-ahead/">earlier</a>, Wordpress.com has made the move from Litespeed for their frontend serving needs to <a href="http://nginx.net">Nginx</a>, the little lightning fast server from Russia. <a href="http://ma.tt/">Matt</a> had mentioned that they were quite happy with <a href="http://litespeedtech.com/">LiteSpeed</a>, but wanted to move to something else purely to have their entire stack run with open sourced software.</p>
<p>It is a huge boost for Nginx, which has in any case been <a href="http://survey.netcraft.com/Reports/200804/">growing at a rapid pace in terms of adoption</a> in the recent years, especially as a reverse proxying solutin for the Ruby On Rails crowd. What is quite interesting is that Wordpress.com is running the development version of the software (0.6.29) than the stable one (0.5.35). There is, though, no clarity if Nginx is being used purely as a reverse proxying solution for Wordpress.com, or if it is actually serving PHP too though the FCGI route.</p>
<p><a href="http://uptime.netcraft.com/up/graph?site=wordpress.com">According to Netcraft</a>, the switchover was made on 11th of April.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Трошки про nginx та Linux]]></title>
<link>http://grandse.wordpress.com/?p=16</link>
<pubDate>Sat, 12 Apr 2008 00:35:18 +0000</pubDate>
<dc:creator>grandse</dc:creator>
<guid>http://grandse.wordpress.com/?p=16</guid>
<description><![CDATA[Сьогодні, гортаючи сторінки Google наштовхнувся в одному ]]></description>
<content:encoded><![CDATA[<p>Сьогодні, гортаючи сторінки <a title=")" href="http://google.com" target="_blank">Google</a> наштовхнувся <a title="Посилання на оригінал" href="http://andrew2002.com/2008_02_11/41/" target="_blank">в одному блозі на недолік</a>, що стосується одного як на мене <a title="Посилання на мої попередні висловлювання з цього приводу" href="http://grandse.wordpress.com/2008/02/03/nginx-%d1%88%d0%b2%d0%b8%d0%b4%d0%ba%d0%b8%d0%b9-http-%d1%81%d0%b5%d1%80%d0%b2%d0%b5%d1%80-%d1%82%d0%b0-%d0%bf%d0%be%d1%88%d1%82%d0%be%d0%b2%d0%b8%d0%b9-proxy-%d1%81%d0%b5%d1%80%d0%b2%d0%b5%d1%80/" target="_blank">чудового сервера nginx</a> (про який вже я писав).</p>
<p>Цей недолік стосується низької швидкості роботи nginx під управлінням ОС Linux. Так вже вийшло, що цей сервер розроблявся спеціально для роботи у FreeBSD, а лише потім був портований під інші платформи. Саме тому йому вдається краще використовувати ресурси саме рідної для нього ОС. Іншого пояснення достатньо вагомого падіння швидкодії при переході на іншу ОС, причому таку, що для більшості задач не поступається ні в коєму разі FreeBSD, я не бачу. Будемо сподіватись, що скоро ситуація, або вирівняється, або буде знайдено іншу причину такої поведімки nginx.</p>
<p>Все одно цей веб та проксі сервер є якщо не найшвидшим для деяких задач, то однозначно одним з найшвидших.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[wc -l 172, Arie's Random Note]]></title>
<link>http://ariekusumaatmaja.wordpress.com/?p=283</link>
<pubDate>Sat, 05 Apr 2008 04:49:25 +0000</pubDate>
<dc:creator>Arie Kusuma Atmaja</dc:creator>
<guid>http://ariekusumaatmaja.wordpress.com/?p=283</guid>
<description><![CDATA[[cross culture] Bih! Ternyata mlintir mi (gaya Eropa) tu sulit ya =)) melintir gitu =)) bisa bisa ta]]></description>
<content:encoded><![CDATA[<p>[cross culture] Bih! Ternyata mlintir mi (gaya Eropa) tu sulit ya =)) melintir gitu =)) bisa bisa tangan ma jari gw yangmlintir. bukan mi nya. </p>
<p>[cross culture] jadi kalo orang amrik denger gw order pake melayu dikiranya croissant perancis itu, padahal gw bilang limo ais kosong buat dia , it's even funny for Indonesian like me as we say : jus jeruk or es jeruk pake gula or nggak pake gula (the default setting is always with sugar) in Indonesia. we have "es" word to say "ice" i don't know in malay i guess its written malay is "ais" </p>
<p>[cross culture bule lawan bule] ini pas kita lagi ma'em di warung cina masakan paporit</p>
<p>[id-ruby] duh ada yang ngomong hebat banget, punten abdi teh cuma biasa sama yang biasa biasa aja. masih baru belajar bareng kitu. </p>
<p>[idup bareng bu'le'] kakiku pegel tiap wiken hik.</p>
<p>[idup bareng bu'le'] pernah seharian cuma makan sayur bukannya jadi kuat kayak mereka malah nggelinding pusing tuju keliling! jadi masi tetap makan nasi.</p>
<p>[indonesiana] 'blogosfer' ??? yuck! i hate that term and i hate it's being used!</p>
<p>[digital camera] i feel stupid but curious of i want to get the best camera but i don't know which one to choose. it's just like old people asked that they want the best computer but don't know how to use it yet</p>
<p>[kelakuan] jangan liat/nilai orang cuman dari jas, penampilan, apalagi sampai membangga-banggakan lalu menjadi pengikut buta. Barangsiapa yang melakukan ini, maka suatu saat ia pasti akan kecewa, karena hari gini tidak ada manusia sempurna.</p>
<p>[pilihanhidup] "bagaimana ada banyak orang yang bilang bahwa seseorang itu pintar dan hebat padahal ini orang nggak ngerti sama sekali apa yang dimaksud dari yang dibicarakan dari seseorang yang disebut pintar itu?" kurang lebih begitulah apa yang disebut oleh Zed Shaw di interview nya dulu itu.. sebaiknya memang bersikap sesuai saja dengan yang dihadapi, mis. baru bisa bikin inisiasi Class ya bilanglah begitu tanpa harus mengagung-agungkan siapapun juga karena tindakan itu juga tiada faedah dan hanya menimbulkan reaksi negatif seperti iri dengki sombong bahkan bisa sampai lupa diri. Bukankah yang lebih nikmat adalah menjalani hidup sesuai dengan yang diimpikan saja... sesuai apa yang diingini sesuai ideologi masing-masing. pasti ada alasan besar bila seseorang senang melakukan apa pun (seekstrim apapun itu bahkan), mis. ingin jadi wartawan di iraq, ingin code pake semau-maunya demi produktifitas karena 1 sampai 2 jam saja langsung jadi dan stabil/siap pakai seterusnya. berhenti nghakimin orang, tapi lebihlah melihat cermin diri ini apa saja yang sudah dihasilkan. kalau memang pada saatnya nanti aku pun harus switch 100 persen ke rubinius, ku mau tak seorang pun mengganggu. tidak juga kau.</p>
<p>[bahasa indonesia grammar] we usually alter "meng" by "ng" only as it's simple and short to say :-) ie. mengakali, menggoda, mengencangkan.... oh ou, it shouldn't be any references at all to non-indonesian cos i just realise that we only say : ngakalin, nggodain, but... ngencangin... kencangin... hm, now there are two options, damn i don't even know indonesian grammar then! i can't speak formal Indonesian! ie. I'll just say to a driver this straight in Jakarta: "Gambir." for short, not this long : "Mohon sudilah kiranya bapak memberikan tumpangan taksi kepada saya dari sini sampai stasiun kereta Gambir" or in english : "Would you like to give me a ride from here to Gambir Train Station, please"</p>
<p>[abad kemarin ngomong e'e'pisi?] blah muntah muntah denger sebelah (iye jerman gedebag gedebug) kek cacing kena panggang manas-manasin gw biar punya tu e'e' e' pisi cape deeh kalo cuman buat keren kerenan , trus cewek lah, trus punya banyak bagus bagus lagi di kos, yah :-) kelakuan gitu cuman nambah daptar orang buat jadi objek (ke)gemes(an)ku. Hidup tanpa laptop menyihatkan. # ngacir</p>
<p>[Terminal] Control M sama dengan Return.</p>
<p>[Terminal] Bah Control Keyboard aing bleguk!</p>
<p>[Blog Roll Feature for Blog is useless for me!] It's only usefull to non dynamic blogger, but if a blogger change it continuously, then it's useless.  Let's say me for example, I find Wordpress Blog Roll facility is useless. It can't keep up to my speed. I prefer have a YAML file instead, then update periodically my links page. # No no no, for Indonesian pals, don't try to start talking or even thinking why I don't use Mephisto or other Ruby based blog, if I can get a free wordpress blog, why should I use a mephisto blog and host it somewhere. I'm even lazy to set things up for any settings or config there, just want to focus on contents (which is mostly my learning notes or could be anyone else's learning notes/see howto for detail). </p>
<p>[Song only] <a href="http://youtube.com/watch?v=8v2CipM0CYs&#38;feature=related">I like this song so much (thanks to romire who uploaded it on youtube).</a><br />
<span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/8v2CipM0CYs'></param><param name='wmode' value='transparent'></param><embed src='http://www.youtube.com/v/8v2CipM0CYs&rel=0' type='application/x-shockwave-flash' wmode='transparent' width='425' height='350'></embed></object></span></p>
<p>[#$%!?] Sebisa mungkin kalau bisa selalu mengangkat, bukan menjatuhkan, contoh: wanda hamidah bilang pinginnya sih jangan yang 9 to 5 kayak kantoran, dijawab: ya bikin kantor sendiri aja. Lah memangnya kalo bikin kantor sendiri lantas bebas ongkang ongkang babi haha mending dibungkus buang aja nih, lagipula kalo kerja kantoran juga ada kok yang bisa fleksibel, tinggal kantornya gimana gimana aja / tinggal milih mah kalo emang potensi. Ya bikin perusahaan sendiri juga gak pa pa, tapi jangan dikait-kaitkan sama gak ada kerjaannya si ongkang-ongkang babi. Rajin pangkal pandai. Hemat pangkal kaya. Gak usah terlalu dihebohin kalo ada yang punya perusahaan datangnya paling pagi pulang paling belakangan (ngomongin Superman, gw pilih Anne Clark aja dah).</p>
<p>[<strong>man port</strong>] if I couldn't do <strong>man port</strong> on this macbook, simply just do </p>
<p><strong>m:man arie$ man -M . port</strong></p>
<p><strong>m:man arie$ pwd</strong></p>
<p><strong>/opt/local/man</strong></p>
<p>ato tinggal nambahin ginian doang (ah payah, tinggal perintah <strong>man man</strong> aja linggisnya arie nyeruduk nyeruduk)</p>
<p><strong>export MANPATH=/opt/local/man:$MANPATH</strong></p>
<p>di simpan taro di profile lah ato di bash profile nya ndiri lah</p>
<p>[spam] keknya gw dispam ma anak filipin deh. uuh. kumustaka kumis lu itu... abisnya lonya ndiri yang kurang tegas, mampaatin kalo tu orang cewe kan, dasar.</p>
<p>[wanita cantik] Matamu berbinar, Kulit putih mulus sampai nyamuk dan lalat pun pasti tergelincir karnanya, senyummu yang teduh, hu uh, tak bisa aku tulis dengan kata kata, yang ada hanyalah jongkok ngitung receh berapa puluh juta rupiah sebulan biaya ngerawat bidadari segitu =)) Jadi inget kalo jadi php programmer bergaji Rp 30 juta sebulan, berarti masih kalah sama Tukul yang gajinya <strong>katanya</strong> Rp 20 juta <strong>sekali tayang</strong>. .... Jongkok lagi ngitung recehan sen... Gile! Makinari makin cantik aja tuh produk2x indo -_-V</p>
<p>[<strong>travelling</strong>] how many of you will really check and recheck again what must do etc, saved by wikitravel :-) Here are some links: <a href="http://wikitravel.org/en/Bandung">Bandung</a>, <a href="http://wikitravel.org/en/Bali">Bali</a>, <a href="http://wikitravel.org/en/Bangkok">Bangkok</a>, <a href="http://wikitravel.org/en/Krabi">Krabi</a>. Hoooh wait, of course if you've been to Bandung that Batagor looks so deluxe :-D I bet that must be more than Rp 5,000 :-P that's too deluxe actually, we usually got plain and lot one =)) Oh I miss Jakarta where I can get Batagor so easily (also soto mi, bakso, sate, Indonesian Food is the best.... drool / hey anti rice, those foods i mentioned just before got no rice at all you know :-P Just eat, cos I can't cook)</p>
<p>[jis] najis tralala bener kok abis paragrap titik titik trus ngomongin mo jalan jalan ke titik titik.</p>
<p>[vim for leopard] I just realised that the executable vim path is in /usr/bin which means it's been delivered on leopard by default. I know I can easily compile vim myself to any OS that I love (like Mac OS X and Linux) but my question is why Apple doesn't deliver ViM GUI by default? I think it's nice to have cocoa ViM.</p>
<p>[#$%^@!] anjing bangsat internet mampus bikin frustasi aja di server amrik!!! hantu hantu di server pusing....</p>
<p>[#$%^!!] aku hajar lagi dinding dinding kebun binatang sontoloyo aku hajar hajar lagi kegeblekan itu. dan terlahirlah pelampiasan tulisan tulisan berpoin poin dibawah ini!</p>
<p>[<strong>nginx</strong>] mungkin sudah bisa didapat dari wikinya yang pake inggris, kalo masi tulisan asli pake bahasa rusia ya dasar nasib mampus blech untung ada temen kos anak rusia.</p>
<p><strong>nginx path prefix: "/usr/local/nginx"</strong></p>
<p><strong>nginx binary file: "/usr/local/sbin"</strong></p>
<p><strong>nginx configuration file: "/usr/local/nginx/conf/nginx.conf"</strong></p>
<p><strong>nginx pid file: "/usr/local/nginx/logs/nginx.pid"</strong></p>
<p><strong>nginx error log file: "/usr/local/nginx/logs/error.log"</strong></p>
<p><strong>nginx http access log file: "/usr/local/nginx/logs/access.log"</strong></p>
<p><strong>nginx http client request body temporary files: "/usr/local/nginx/client_body_temp"</strong></p>
<p><strong>nginx http proxy temporary files: "/usr/local/nginx/proxy_temp"</strong></p>
<p><strong>nginx http fastcgi temporary files: "/usr/local/nginx/fastcgi_temp"</strong></p>
<p>saya perlu restart monit kalo sudah ubah ubah konfigurasi file di conf monit. oh path pathnya dimana? Nih!</p>
<p><strong>`monitrc` -&#62; `/usr/local/etc/monitrc`</strong></p>
<p><strong>`ruby_application.monitrc' -&#62; `/usr/local/etc/monit.d/ruby_application.monitrc'</strong></p>
<p><strong>`ruby_application_staging.monitrc' -&#62; `/usr/local/etc/monit.d/ruby_application_staging.monitrc'</strong></p>
<p><strong>`mysql.monitrc' -&#62; `/usr/local/etc/monit.d/mysql.monitrc'</strong></p>
<p><strong>`nginx.monitrc' -&#62; `/usr/local/etc/monit.d/nginx.monitrc'</strong></p>
<p><strong>`nginx.conf` -&#62; `/usr/local/nginx/nginx.conf`</strong></p>
<p><strong>`monit` -&#62; `/etc/default/monit`</strong></p>
<p>[selingan prancis/disela cewek prancis] anjing! cantik banget!! ting tong ting tong ciong ciong tung tuing tuing tuing</p>
<p>[monit sama nginx lagi] cara restart monit <strong>sudo /etc/init.d/monit restart</strong>. dapetin gitu doang sampe 3 jam lebih + ganggu ganggu iblis, bah! koplok! # sambil pegang pedang starwars</p>
<p>[monit sama nginx lagi] cara restart semua aplikasi <strong>sudo monit restart all -g nginx</strong>, awas kalo ada banyak aplikasi jalan tu bakal ke restart lho.</p>
<p>[monit lagi] kalau hasil dari <strong>sudo monit status</strong> keluar doesn't have file gitu periksa lagi port yang dipakai apakah sudah bersesuaian dengan yang ada di config/deploy.rb. Kalau ternyata malah gak ada,  ya berarti pasang di config/mongrel_cluster.yml</p>
<pre>
---
cwd: '/home/rubykusayang/apps/rubykumanis/current'
port: 8450
environment: 'production'
address: '127.0.0.1'
pid_file: '/home/rubykusayang/apps/rubykumanis/shared/pids/mongrel.pid'
log_file: '/home/rubykusayang/apps/rubykumanis/shared/log/mongrel.log'
servers: 2
</pre>
<p>note:</p>
<p>"rubykusayang" = a user home</p>
<p>"rubykumanis"  = an application name</p>
<p>[alasan kenapa mongrel_cluster.yml] kenapa di sebagian aplikasi tidak pakai mongrel_cluster.yml, karena ... linggis ah... why in some apps we use mongrel_cluster.yml, and in some apps we don't use mongrel_cluster.yml ? Because ... this file shouldn't be in SCM repository, it should go to the server config only. so we always use mongrel_cluster.yml, it's just being symlinked from <strong>#{deploy_to}/#{shared_dir}/config/mongrel_cluster.yml to #{release_path}/config/mongrel_cluster.yml</strong> . Iblis sebelah ini juga nerangin kalau pakai merb gak pake mongrel_cluster.yml malah pake satu file di config nambah satu baris gitu doang, dengan senyuman pembunuhannya itu pendekar berpedang itu bilang : "it's well documented" # kabur.. takut.. dikejarnya pakai parang sambil ngomong bahasa jawa nanti aku!</p>
<p>[bash doang] if you got your Leoapard Terminal without color while doing "ls" command, simply add alias for it, ex. edit /Users/arie/.profile then just add there <strong>alias ls="ls -G"</strong>. Done!</p>
<p>[tunjul yang diatas] abis gitu colokin laptopnya di monitor layar lebar huhuhu cute banget Terminalnya.</p>
<p>[tunjul lagi monit yang diatas] ya tapi gimana cara nge-restart si monit nya itu sendiri???? </p>
<p>Nih caranya:</p>
<p><strong>sudo /etc/init.d/monit restart</strong></p>
<p>[check a method] check that attr_accessor :something so that don't get panic to ask where "something" local variable  come from. it came from method.</p>
<p>[goyang gejrot] pusing sama plugin tzinfo yang katanya deprecated sama sering banget pake cara cara frozen atau alamat/bakal frozen gitu? liatin file testnya, jalanin deh rake test:plugins error tuh, biar jalan kalo di textmate tinggal tekan apple r tinggal tumpuk aja require nya dengan code-code dibawah ini.</p>
<pre>
require "rubygems"
require "tzinfo"
require "../lib/tzinfo_timezone"
</pre>
<p>[pp rails] pp is not being required by default anymore since recent rails edge. so do give command require 'pp' first before using it in rails script/console.</p>
<pre>
m:e arie$ script/about&#124;rak Edge
  10&#124;Edge Rails revision       264
m:b arie$ script/about&#124;rak Edge
  10&#124;Edge Rails revision       9088
</pre>
<p>[expatpool] making friend through <a href="http://kl.expatpool.com">ExpatPool</a> is fun! Wish many more girls want to meet us =)) I know I don't speak that much and perhaps that makes girls act as unexpected to me.... # gubrak, sialan gw jadi curhat.</p>
<p>[jeruk makan jeruk] sst .. jadi uda seneng ada yg bantuin bersih2 ya :p susah nih kebiasaan gak nyaman dibantu, malah dipaksa sama pembantu sering ngerasa aneh juga. ugh gejala konflik kultur nih. Terserah deh mo sebut di gw gituh biasa ditempatin datuk kek datok kek, gw nggak ngeh dah</p>
<p>Cute Cats... Thanks for someone who uploaded the video!!! I love cats.</p>
<p><span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/03OJvZhU-3M'></param><param name='wmode' value='transparent'></param><embed src='http://www.youtube.com/v/03OJvZhU-3M&rel=0' type='application/x-shockwave-flash' wmode='transparent' width='425' height='350'></embed></object></span></p>
<p>[new vocab] outlier = outlier &#124;ˈaʊtlʌɪə&#124;<br />
noun<br />
a person or thing situated away or detached from the main body or system : less accessible islands and outliers.<br />
• a person or thing excluded from a group; an outsider.<br />
• Geology a younger rock formation isolated among older rocks.<br />
• Statistics a data point on a graph or in a set of results that is very much bigger or smaller than the next nearest data point.</p>
<p>[mac greeting] we use grawl notification here. press control space, then press . (dot). then just type something, for example: Hei Orang Gila Jelek Lu :-P . And then press Enter/Return. Then we'll see that string using big fonts on our lovely mac screen ;-) Credit goes to Someone near me who likes making others curious :-P spooky spooky spooky scoobeedoobeedoo.... -_-V</p>
<p>[edge rails active record] nice! since when it supports <strong>first</strong>, <strong>last</strong>, <strong>all</strong> just like Data Mapper!</p>
<p>And The Log:</p>
<pre>
 Country Load (1) (0.000837)   SELECT * FROM `countries` LIMIT 1
 Country Load (1) (0.000908)   SELECT * FROM `countries` ORDER BY countries.id DESC LIMIT 1
</pre>
<p>[edge rails] always check <strong>rake -T</strong> to get new cool features. it's just getting longer and longer.</p>
<p>[<a href="http://www.youtube.com/watch?v=NzKbG0Ny9CE">nak myuzik boleh ke?</a>]</p>
<p><span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/NzKbG0Ny9CE'></param><param name='wmode' value='transparent'></param><embed src='http://www.youtube.com/v/NzKbG0Ny9CE&rel=0' type='application/x-shockwave-flash' wmode='transparent' width='425' height='350'></embed></object></span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[How-to: Bazaar smart server on Nginx]]></title>
<link>http://hario.wordpress.com/?p=171</link>
<pubDate>Sat, 08 Mar 2008 23:40:42 +0000</pubDate>
<dc:creator>hario</dc:creator>
<guid>http://hario.wordpress.com/?p=171</guid>
<description><![CDATA[This is a recipe which will teach you how to set-up a Bazaar smart server on top of the great Nginx ]]></description>
<content:encoded><![CDATA[<p>This is a recipe which will teach you how to set-up a <a href="http://bazaar-vcs.org/Specs/SmartServer">Bazaar smart server</a> on top of the great <a href="http://nginx.net">Nginx</a> HTTP server. I will not deal with optimization or fancy setups at all, the goal is just having your Bazaar branches published, feel free to comment if you feel like the proposed setup could be improved.</p>
<p>First of all, you will need the following:</p>
<ul>
<li>An Un*x box. It does not matter which particular incarnation you prefer (*BSD, GNU/Linux, MacOS X...), just make sure the following components work with your operating system of choice.</li>
<li><a href="http://bazaar-vcs.org">Bazaar</a> 1.0 or newer.</li>
<li><a href="http://nginx.net">Nginx</a> 0.6.x with the latest <a href="http://wiki.codemongers.com/NginxNgxWSGIModule">mod_wsgi</a> builtin (Manlio did a great job bringing WSGI support o life!)</li>
<li>Your text editor of choice.</li>
</ul>
<p>Now, the recipe for a read-only repository of Bazaar branches:</p>
<ol>
<li>Install Nginx with mod_wsgi. If you are a fortunate <a href="http://gentoo.org">Gentoo</a> user, you can use the Nginx ebuilds from <span style="text-decoration:line-through;"><a href="http://foobar.homeunix.org/trac/overlay">my overlay</a></span> <a href="http://code.connectical.com/overlay">the Connectical Overlay</a>, just make sure you set <tt>python</tt> USE-flag when emerging <tt>www-servers/nginx</tt>.</li>
<li>Create a directory where you will store your branches. I myself decided to place them under <tt>/home/bzr</tt>. Make sure that Nginx will be able of reading its contentse e.g. by making the directory and its contents world-readable.</li>
<li>Write a small Python script which creates a WSGI application for the smart server and save it to <tt>/home/bzr/smartserver.wsgi</tt>. It should look like the following:
<pre>      from bzrlib.transport.http import wsgi

      application = wsgi.make_app(
         root="/home/bzr",
         prefix="/bzr",
         path_var="REQUEST_URI",
         readonly=True)</pre>
</li>
<li>Edit <tt>/etc/nginx/nginx.conf</tt> and add the directives into a <tt>server</tt> section, be sure to use the same <tt>location</tt> as in the <tt>prefix</tt> variable above:
<pre>      location /bzr {
         wsgi_pass /home/bzr/smartserver.wsgi;
      }</pre>
</li>
<li>Restart Nginx and enjoy: Now you can access a branch stored at <tt>/home/bzr/mybranch</tt> using the <tt>bzr+http://host/bzr/mybranch</tt> URL.</li>
</ol>
<p>Final note: you must have <tt>include wsgi_vars</tt> somewhere in your Nginx configuration file, in a <tt>server</tt> section. That's all for today. And remember... Bazaar and Nginx are a joy to work with! ;-)</p>
]]></content:encoded>
</item>

</channel>
</rss>
