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

<channel>
	<title>Random Musings of an Insane Mind &#187; Webserver Software</title>
	<atom:link href="http://cd34.com/blog/category/webserver/feed/" rel="self" type="application/rss+xml" />
	<link>http://cd34.com/blog</link>
	<description>This is my blog, there are many others like it but this one is mine.</description>
	<lastBuildDate>Tue, 29 Jun 2010 04:22:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Abort mdadm consistency check</title>
		<link>http://cd34.com/blog/webserver/abort-mdadm-consistency-check/</link>
		<comments>http://cd34.com/blog/webserver/abort-mdadm-consistency-check/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 17:27:15 +0000</pubDate>
		<dc:creator>cd34</dc:creator>
				<category><![CDATA[Webserver Software]]></category>
		<category><![CDATA[mdadm]]></category>
		<category><![CDATA[raid]]></category>

		<guid isPermaLink="false">http://cd34.com/blog/?p=970</guid>
		<description><![CDATA[One of our client systems has a Raid 1 setup using two 1 Terabyte drives. Last night, Debian&#8217;s consistency check launched, but, his system was doing some heavy disk IO due to some scripts that were being processed and the system was estimating close to 1000 hours to complete the check. md3 : active raid1 [...]]]></description>
			<content:encoded><![CDATA[<p>One of our client systems has a Raid 1 setup using two 1 Terabyte drives.  Last night, Debian&#8217;s consistency check launched, but, his system was doing some heavy disk IO due to some scripts that were being processed and the system was estimating close to 1000 hours to complete the check.</p>
<pre>
md3 : active raid1 sdb8[1] sda8[0]
      962108608 blocks [2/2] [UU]
      [===>.................]  check = 15.1% (145325952/962108608) finish=60402.6min speed=224K/sec
</pre>
<p>To abandon the check, we issued:</p>
<pre>
echo idle > /sys/block/md3/md/sync_action
</pre>
<p>Which allowed the machine to skip the rest of the test.  While I don&#8217;t like disabling the checks, we&#8217;ll reschedule this one to do the check after they are done doing their work.</p>
]]></content:encoded>
			<wfw:commentRss>http://cd34.com/blog/webserver/abort-mdadm-consistency-check/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DDOS attack mitigation</title>
		<link>http://cd34.com/blog/webserver/ddos-attack-mitigation/</link>
		<comments>http://cd34.com/blog/webserver/ddos-attack-mitigation/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 06:02:58 +0000</pubDate>
		<dc:creator>cd34</dc:creator>
				<category><![CDATA[Webserver Software]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[ddos]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Varnish]]></category>

		<guid isPermaLink="false">http://cd34.com/blog/?p=937</guid>
		<description><![CDATA[Today we had a DDOS attack on one of our clients. They were running prefork with mod_php5 with a rather busy application. While we initially started filtering IP addresses using iptables and a few crudely hacked rules, we knew something had to be done that was a little more permanent. Moving to MPM-Worker with PHP [...]]]></description>
			<content:encoded><![CDATA[<p>Today we had a DDOS attack on one of our clients.  They were running prefork with mod_php5 with a rather busy application.  While we initially started filtering IP addresses using iptables and a few crudely hacked rules, we knew something had to be done that was a little more permanent.  Moving to MPM-Worker with PHP served with FastCGI seemed reasonable, but, looking at the history of the attacks on this machine, I believe Apache still would have been vulnerable since we cannot filter the requests early enough in Apache&#8217;s request handler.</p>
<p>Apache does have the ability to fight some DDOS attacks using <a href="http://www.modsecurity.org/">mod_security</a> and <a href="http://www.zdziarski.com/blog/?page_id=442">mod_evasive</a>, but, this particular attack was designed to affect apache prior to the place where these modules hook into the request.  This also precludes using fail2ban.  We could run mod_forensic or mod_logio to assist fail2ban, but, it is still a stopgap measure.</p>
<p>We could have used some Snort rules and tied those to iptables, but, that is a rather bad solution to the problem.</p>
<p>While we could have used <a href="http://varnish-cache.org/">Varnish</a>, their application would have had some issues.  <a href="http://stderr.net/apache/rpaf/">mod_rpaf</a> can help by adjusting the REMOTE_ADDR to take the value from X-Forwarded-For that Varnish sets.  mod_geoip actually inserts itself before mod_rpaf, so, we would have needed to make a modification to mod_geoip and recompiled it.  I&#8217;m not sure how Varnish would have handled <a href="http://ha.ckers.org/slowloris/">Slowloris</a> and we had to fix this now. </p>
<p>Putting them behind a Layer 7 load balancer would have isolated the origin server and handled the brunt of the attack on the load balancer, but, again we would have needed mod_rpaf and some modifications to their code.</p>
<p>In the end, Lighttpd and Nginx appeared to be the only documented solution.  After the conversion, we did find documentation that said Varnish and Squid were immune to Slowloris.  With Nginx or Lighttpd, we didn&#8217;t have IP address issues to contend with, it would be easy enough to modify the fastcgi config to pass the GEOIP information in the same request variable that their application expected.  We knew we had to run PHP under FastCGI, so, we might as well pick a tool where we can block the attack in the webserver without having to worry about firewall rules.  We did put a few firewall rules in place to block the larger offenders.</p>
<p>in the http { } section of our nginx config, we added:</p>
<pre>
    client_body_timeout 10;
    client_header_timeout 10;
    keepalive_timeout 10;
    send_timeout 10;
    limit_zone limit_per_ip $binary_remote_addr 16m;
</pre>
<p>and in the server { } section, we added:</p>
<pre>
    limit_conn limit_per_ip 5;
</pre>
<p>Since each server was expecting to handle one or two requests from each IP, this gave us a little headroom while solving the problem in the right place.</p>
<p>I believe Varnish would have held the connection and wouldn&#8217;t have sent a request to the backend which makes it fairly versatile as a tool to deal with DDOS attacks.  While I do like the ability to block certain requests in VCL, the methods listed to fight this type of attack appeared to favor a non-threaded webserver.  Varnish in front of Apache would have worked, but, we already knew we needed to move from Apache at some point with this client and this gave us an opportunity to shift them while under the gun.</p>
<p>Wouldn&#8217;t have had it any other way.</p>
]]></content:encoded>
			<wfw:commentRss>http://cd34.com/blog/webserver/ddos-attack-mitigation/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using Varnish to assist with AB Testing</title>
		<link>http://cd34.com/blog/webserver/using-varnish-to-assist-with-ab-testing/</link>
		<comments>http://cd34.com/blog/webserver/using-varnish-to-assist-with-ab-testing/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 01:48:49 +0000</pubDate>
		<dc:creator>cd34</dc:creator>
				<category><![CDATA[Webserver Software]]></category>
		<category><![CDATA[abtest]]></category>
		<category><![CDATA[analytics]]></category>
		<category><![CDATA[Varnish]]></category>

		<guid isPermaLink="false">http://cd34.com/blog/?p=896</guid>
		<description><![CDATA[While working with a recent client project, they mentioned AB Testing a few designs. While I enjoy statistics, we looked at Google&#8217;s Website Optimizer to track trials and conversions. After some internal testing, we opted to use Funnels and Goals rather than the AB or Multivariate test. I had little control over the origin server, [...]]]></description>
			<content:encoded><![CDATA[<p>While working with a recent client project, they mentioned AB Testing a few designs.  While I enjoy statistics, we looked at Google&#8217;s Website Optimizer to track trials and conversions.  After some internal testing, we opted to use Funnels and Goals rather than the AB or Multivariate test.  I had little control over the origin server, but I did have control over the front-end cache.</p>
<p>Our situation reminded me of a situation I encountered years ago.  A client had an inhouse web designer and a subcontracted web designer.  I felt the subcontracted web designer&#8217;s design would convert better.  The client wasn&#8217;t completely convinced, but agreed to running two designs head to head.  However, their implementation of the test biased the results.</p>
<h2>What went wrong?</h2>
<p>Each design was run for a week, in series.  While this provided ample time for gathering data, the inhouse designer&#8217;s design ran during a national holiday with a three day weekend, and the subcontractor&#8217;s design ran the following week.  Internet traffic patterns, the holiday weekend, weather, sporting events, TV/Movie premieres, etc. added so many variables which should have invalidated the results.</p>
<p>Since Google&#8217;s AB Testing has session persistence and splits traffic between the AB tests, we need to emulate this behavior.  When people run AB tests in series rather than parallel, or, switch pages with a cron job or some other automated method, I cringe.  A test at 5pm EST and 6pm EST will yield different results.  At 5pm EST, your target audience could be driving home from work.  At 6pm EST they could be sitting down for dinner.</p>
<h2>How can Varnish help?</h2>
<p>If we allow Varnish to select the landing page/offer page outside the origin server&#8217;s control, we can run both tests run at the same time.  An internet logjam in Seattle, WA would affect both tests evenly.  Likewise, a national or worldwide event would affect both tests equally.  Now that we know how to make sure the AB Test is fairly balanced, we have to implement it.</p>
<p>Redirection sometimes plays havoc on browsers and spiders, so, we&#8217;ll rewrite the URL within Varnish using some Inline C and VCL.  Google uses javascript and a document.location call to send some visitors to the B/alternate page.  Users that have javascript disabled, will only see the Primary page.</p>
<p>Our Varnish config file contains the following:</p>
<pre>
sub vcl_recv {
  if (req.url == "/") {
    C{
      char buff[5];
      sprintf(buff,"%d",rand()%2 + 1);
      VRT_SetHdr(sp, HDR_REQ, "\011X-ABtest:", buff);
    }C
    set req.url = "/" req.http.X-ABtest "/" req.url;
  }
}
</pre>
<p>We&#8217;ve placed our landing pages in /1/ and /2/ directories on our origin server.  The only page Varnish intercepts is the index page at the root of the site.  Varnish randomly chooses to serve the index.html page from /1/ or /2/, internally rewrites our URL and serves it from the cache or the origin server.  Since the URL rewriting is done within vcl_recv, subsequent requests for the page don&#8217;t hit the origin.  The same method can be used to test landing pages that aren&#8217;t at the root of your site by modifying the if (req.url == &#8220;&#8221;) { condition.</p>
<p>You can test multipage offers by placing additional pages within the /1/ and /2/ directories on your origin along with the signup form.  Unlike Google&#8217;s AB Test, Varnish does not support session persistence.  Reloading the root page will result in the surfer alternating between both test pages.  Subsequent pages need to be loaded from /1/ or /2/ based on which landing page was selected.</p>
<p>When doing any AB Test, change as few variables as possible, document the changes, and analyze the difference between the results.  Running at least 1000 views of each is an absolute minimum.  While Google&#8217;s Multivariate test provides a lot more options, a simple AB test between two pages or site tours can give some insight into what works rather easily.</p>
<p>If you cannot use Google&#8217;s AB Test or the Multivariate Test, using their Funnels and Goals tool will still allow you to do AB Testing.</p>
]]></content:encoded>
			<wfw:commentRss>http://cd34.com/blog/webserver/using-varnish-to-assist-with-ab-testing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Varnish VCL, Inline C and a random image</title>
		<link>http://cd34.com/blog/webserver/varnish-vcl-inline-c-and-a-random-image/</link>
		<comments>http://cd34.com/blog/webserver/varnish-vcl-inline-c-and-a-random-image/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 23:48:35 +0000</pubDate>
		<dc:creator>cd34</dc:creator>
				<category><![CDATA[Webserver Software]]></category>
		<category><![CDATA[inline c]]></category>
		<category><![CDATA[Varnish]]></category>
		<category><![CDATA[vcl]]></category>
		<category><![CDATA[vcl_recv]]></category>

		<guid isPermaLink="false">http://cd34.com/blog/?p=884</guid>
		<description><![CDATA[While working with the prototype of a site, I wanted to have a particular panel image randomly chosen when the page was viewed. While this could be done on the server side, I wanted to move this to Varnish so that Varnish&#8217;s cache would be used rather than piping the request through each time to [...]]]></description>
			<content:encoded><![CDATA[<p>While working with the prototype of a site, I wanted to have a particular panel image randomly chosen when the page was viewed.  While this could be done on the server side, I wanted to move this to Varnish so that Varnish&#8217;s cache would be used rather than piping the request through each time to the origin server.</p>
<p>At the top of /etc/varnish/default.vcl</p>
<pre>C{
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
}C
</pre>
<p>and our vcl_recv function gets the following:</p>
<pre>
  if (req.url ~ "^/panel/") {
    C{
      char buff[5];
      sprintf(buff,"%d",rand()%4);
      VRT_SetHdr(sp, HDR_REQ, "\010X-Panel:", buff);
    }C
    set req.url = regsub(req.url, "^/panel/(.*)\.(.*)$", "/panel/\1.ZZZZ.\2");
    set req.url = regsub(req.url, "ZZZZ", req.http.X-Panel);
  }
</pre>
<p>The above code allows for us to specify the source code in the html document as:</p>
<pre>
&lt;img src="/panel/random.jpg" width="300" height="300" alt="Panel Image"/&gt;
</pre>
<p>Since we have modified the request uri in vcl_recv before the object is cached, subsequent requests for the same modified URI will be served from Varnish&#8217;s cache, without requiring another fetch from the origin server.  Based on the other VCL and preferences, you can specify a long expire time, remove cookies, or do ESI processing.  Since the regexp passes the extension through, we could also randomly choose .html, .css, .jpg or any other extension you desire.</p>
<p>In the directory panel, you would need to have   </p>
<pre>
/panel/random.0.jpg
/panel/random.1.jpg
/panel/random.2.jpg
/panel/random.3.jpg
</pre>
<p>which would be served by Varnish when the url /panel/random.jpg is requested.</p>
<p>Moving that process to Varnish should cut down on the load from the origin server while making your site look active and dynamic.</p>
]]></content:encoded>
			<wfw:commentRss>http://cd34.com/blog/webserver/varnish-vcl-inline-c-and-a-random-image/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Varnish and Nginx with Joomla</title>
		<link>http://cd34.com/blog/webserver/varnish-and-nginx-with-joomla/</link>
		<comments>http://cd34.com/blog/webserver/varnish-and-nginx-with-joomla/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 17:01:30 +0000</pubDate>
		<dc:creator>cd34</dc:creator>
				<category><![CDATA[Webserver Software]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Varnish]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://cd34.com/blog/?p=685</guid>
		<description><![CDATA[Recently we had a client that had some performance issues with a Joomla installation. The site wasn&#8217;t getting an incredible amount of traffic, but, the traffic it was getting was just absolutely overloading the server. Since the machine hadn&#8217;t been having issues before, the first thing we did was contact the client and ask what [...]]]></description>
			<content:encoded><![CDATA[<p>Recently we had a client that had some performance issues with a Joomla installation.  The site wasn&#8217;t getting an incredible amount of traffic, but, the traffic it was getting was just absolutely overloading the server.</p>
<p>Since the machine hadn&#8217;t been having issues before, the first thing we did was contact the client and ask what had changed.  We already knew the site and database that was using most of the CPU time, but, the bandwidth graph didn&#8217;t suggest that it was traffic overrunning the server.  Our client rescued this client from another hosting company because the site was unusable in during prime time.  So, we&#8217;ve inherited a problem.  During the move, the site was upgraded from 1.0 to 1.5, so, we didn&#8217;t even have a decent baseline to revert to.</p>
<p>The stopgap solution was to move the .htaccess mod_rewrite rules into the apache configuration which helped somewhat.  We identified a few sections of the code that were getting hit really hard and wrote a mod_rewrite rule to serve those images direct from disk &#8212; bypassing Joomla serving those images through itself.  This made a large impact and at least got the site responsive enough that we could leave it online and work through the admin to figure out what had gone wrong.</p>
<p>Some of the modules that had been enabled contributed to quite a bit of the performance headache.  One chat module generated 404s every second for each person logged in to see if there were any pending messages.  Since Joomla is loaded for each 404 file, this added quite a bit of extra processing.  Another quick modification to the configuration eliminated dozens of bad requests.  At this point, the server is responsive, the client is happy and we make notes in the trouble ticket system and our internal documentation for reference.</p>
<p>Three days later the machine alerts and our load problem is back.  After all of the changes, something is still having problems.  Upon deeper inspection, we find that portions of the system dealing with the menus are being recreated each time.  There&#8217;s no built in caching, so, the decision is to try Varnish.  Varnish has worked in the past for WordPress sites that have gotten hit hard, so, we figured if we could cache the images, css and some of the static pages that don&#8217;t require authentication, we can get the server to be responsive again.</p>
<p>Apart from the basic configuration, our varnish.vcl file looked like this:</p>
<pre>
sub vcl_recv {
  if (req.http.host ~ "^(www.)?domain.com$") {
     set req.http.host = "domain.com";
  }

 if (req.url ~ "\.(png|gif|jpg|ico|jpeg|swf|css|js)$") {
    unset req.http.cookie;
  }
}

sub vcl_fetch {
 set obj.ttl = 60s;
 if (req.url ~ "\.(png|gif|jpg|ico|jpeg|swf|css|js)$") {
      set obj.ttl = 3600s;
 }
}
</pre>
<p>To get the apache logs to report the IP, you need to modify the VirtualHost config to log the <a href="/blog/infrastructure/varnish-and-apache2/">forwarded IP</a>.</p>
<p>The performance of the site after running Varnish in front of Apache was quite good.  Apache was left with handling only .php and the server is again responsive.  It runs like this for a week or more without any issues and only a slight load spike here or there.</p>
<p>However, Joomla doesn&#8217;t like the fact that every request&#8217;s REMOTE_ADDR is 127.0.0.1 and some addons stop working.  In particular an application that allows the client to upload .pdf files into a library requires a valid IP address for some reason.  Another module to add a sub-administration panel for a manager/editor also requires an IP address other than 127.0.0.1.  </p>
<p>With some reservation, we decide to switch to Nginx + FastCGI which removes the reverse proxy and should fix the IP address problems.</p>
<p>Our configuration for Nginx with Joomla:</p>
<pre>
server {
        listen 66.55.44.33:80;
	server_name  www.domain.com;
 	rewrite ^(.*) http://domain.com$1 permanent;
}
server {
        listen 66.55.44.33:80;
	server_name  domain.com;

	access_log  /var/log/nginx/domain.com-access.log;

	location / {
		root   /var/www/domain.com;
		index  index.html index.htm index.php;

           if ( !-e $request_filename ) {
             rewrite (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ /index.php last;
             break;
           }

	}

	error_page   500 502 503 504  /50x.html;
	location = /50x.html {
		root   /var/www/nginx-default;
	}

	location ~ \.php$ {
		fastcgi_pass   unix:/tmp/php-fastcgi.socket;
		fastcgi_index  index.php;
		fastcgi_param  SCRIPT_FILENAME  /var/www/domain.com/$fastcgi_script_name;
		include	fastcgi_params;
	}

        location = /modules/mod_oneononechat/chatfiles/ {
           if ( !-e $request_filename ) {
             return 404;
           }
        }
}
</pre>
<p>With this configuration, Joomla was handed any URL for a file that didn&#8217;t exist.  This was to allow the Search Engine Friendly (SEF) links.  The second 404 handler was to handle the oneononechat module which looks for messages destined for the logged in user.</p>
<p>With Nginx, the site is again responsive.  Load spikes occur from time to time, but, the site is stable and has a lot less trouble dealing with the load.  However, once in a while the load spikes, but, the server seems to recover pretty well.</p>
<p>However, a module called Rokmenu which was included with the template design appears to have issues.  Running php behind FastCGI sometimes gives different results than running as mod_php and it appears that Rokmenu is relying on the path being passed and doesn&#8217;t normalize it properly.  So, when the menu is generated, with SEF on or off, urls look like /index.php/index.php/index.php/components/com_docman/themes/default/images/icons/16&#215;16/pdf.png.</p>
<p>Obviously this creates a broken link and causes more 404s.  We installed a fresh Joomla on Apache, imported the data from the copy running on Nginx, and Apache with mod_php appears to work properly.  However, the performance is quite poor.</p>
<p>In order to troubleshoot, we made a list of every addon and ran through some debugging.  With apachebench, we wrote up a quick command line that could be pasted in at the ssh prompt and decided upon some metrics.  Within minutes, our first test revealed 90% of our performance issue.  Two of the addons required compatibility mode because they were written for 1.0 and hadn&#8217;t been updated.  Turning on compatibility mode on our freshly installed site resulted in 10x worse performance.  As a test, we disabled the two modules that relied on compatibility mode and turned off compatibility mode and the load dropped immensely.  We had disabled SEF early on thinking it might be the issue, but, we found the performance problem almost immediately.  Enabling other modules and subsequent tests showed marginal performance changes.  Compatibility mode was our culprit the entire time.</p>
<p>The client started a search for two modules to replace the two that required compatibility mode and disabled them temporarily while we moved the site back to Apache to fix the url issue in Rokmenu.  At this point, the site was responsive, though, pageloads with lots of images were not as quick as they had been with Nginx or Varnish.  At a later point, images and static files will be served from Nginx or Varnish, but, the site is fairly responsive and handles the load spikes reasonably well when Googlebot or another spider hits.</p>
<p>In the end the site ended up running on Apache because Varnish and Nginx had minor issues with the deployment.  Moving to Apache alternatives doesn&#8217;t always fix everything and may introduce side-effects that you cannot work around.</p>
]]></content:encoded>
			<wfw:commentRss>http://cd34.com/blog/webserver/varnish-and-nginx-with-joomla/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flash Media Encoder and Red5</title>
		<link>http://cd34.com/blog/webserver/flash-media-encoder-and-red5/</link>
		<comments>http://cd34.com/blog/webserver/flash-media-encoder-and-red5/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 18:35:07 +0000</pubDate>
		<dc:creator>cd34</dc:creator>
				<category><![CDATA[Webserver Software]]></category>
		<category><![CDATA[flash media encoder]]></category>
		<category><![CDATA[red5]]></category>

		<guid isPermaLink="false">http://cd34.com/blog/?p=669</guid>
		<description><![CDATA[Using the HTML from the flowplayer and red5 post, you need to change the url in the javascript to: url: 'red5StreamDemo', live: true You will need to use Flash Media Encoder version 2.5 which can be downloaded at adobe.com. Flash Media Encoder version 3.0 will not work with red5 and based on developer comments, will [...]]]></description>
			<content:encoded><![CDATA[<p>Using the HTML from the <a href="/blog/webserver/flowplayer-org-and-red5/">flowplayer and red5</a> post, you need to change the url in the javascript to:</p>
<pre>url: 'red5StreamDemo', live: true</pre>
<p>You will need to use Flash Media Encoder version 2.5 which can be downloaded at <a href="http://www.adobe.com/products/flashmediaserver/flashmediaencoder/">adobe.com</a>.  Flash Media Encoder version 3.0 will not work with red5 and based on developer comments, will probably not be supported</p>
<p>It is against the license for Flash Media Encoder to use it with anything other than Flash Media Server.</p>
<p>Here is a screenshot of the config required to get Flash Media Encoder 2.5 to work with red5. Replace yourhostname with the name of your red5 server.</p>
<p><a href="http://cd34.colocdn.com/blog/wp-content/uploads/2009/06/fme251.jpg"><img src="http://cd34.colocdn.com/blog/wp-content/uploads/2009/06/fme251-300x225.jpg" alt="Flash Media Encoder version 2.5 connecting to red5" title="Flash Media Encoder version 2.5 connecting to red5" width="300" height="225" class="aligncenter size-medium wp-image-673" /></a></p>
<p>After you&#8217;ve configured the FMS Url and the Stream, click the Connect button, and then the Start button at the bottom to start encoding.</p>
]]></content:encoded>
			<wfw:commentRss>http://cd34.com/blog/webserver/flash-media-encoder-and-red5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>flowplayer.org and red5</title>
		<link>http://cd34.com/blog/webserver/flowplayer-org-and-red5/</link>
		<comments>http://cd34.com/blog/webserver/flowplayer-org-and-red5/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 20:34:52 +0000</pubDate>
		<dc:creator>cd34</dc:creator>
				<category><![CDATA[Webserver Software]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flowplayer]]></category>
		<category><![CDATA[red5]]></category>

		<guid isPermaLink="false">http://cd34.com/blog/?p=667</guid>
		<description><![CDATA[Dozens of posts on the net reference using red5 with flowplayer for rtmp streaming, but, none give you precisely the code required. &#60;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> &#60;script src="flowplayer-3.1.1.min.js"> &#60;style> a.rtmp { display:block; width:640px; height:360px; margin:25px 0; text-align:center; } a.rtmp img { border:0px; margin-top:140px; } &#60;/style> &#60;a class="rtmp" href="#"> &#60;img src="http://static.flowplayer.org/img/player/btn/showme.png" /> [...]]]></description>
			<content:encoded><![CDATA[<p>Dozens of posts on the net reference using red5 with flowplayer for rtmp streaming, but, none give you precisely the code required.</p>
<pre>
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

&lt;script src="flowplayer-3.1.1.min.js"></script>	

&lt;style>
a.rtmp {
	display:block;
	width:640px;
	height:360px;
	margin:25px 0;
	text-align:center;
}

a.rtmp img {
	border:0px;
	margin-top:140px;
}
&lt;/style>

&lt;a class="rtmp" href="#">
&lt;img src="http://static.flowplayer.org/img/player/btn/showme.png"  />
&lt;/a>

&lt;script type="text/javascript">

$f("a.rtmp", "flowplayer-3.1.1.swf", { 

	clip: {
		provider: 'rtmp',
// name of the .flv from /webapps/oflaDemo/streams without the .flv
                url: 'IronMan'
	}, 

	plugins: {
	  rtmp: {
		url: '/fprt/flowplayer.rtmp-3.1.0.swf',
		netConnectionUrl: 'rtmp://hostname/oflaDemo'
	  }
	}
});
&lt;/script>
</pre>
<p>Make sure you have the following files:</p>
<p>* flowplayer-3.1.1.swf<br />
* flowplayer.controls-3.1.1.swf<br />
* flowplayer.rtmp-3.1.0.swf</p>
<p>If you receive the error:</p>
<p>300: Player Initialization Failed: TypeError: Error #1009</p>
<p>Then you are missing flowplayer.controls-3.1.1.swf from your directory.</p>
<p>In the javascript, </p>
<blockquote><p>netConnectionUrl: &#8216;rtmp://hostname/oflaDemo&#8217;</p></blockquote>
<p>needs to be set the hostname of your red5 server.</p>
<blockquote><p>url: &#8216;IronMan&#8217;</p></blockquote>
<p>needs to be set to the name of the .flv in the webapps/oflaDemo/streams directory without the .flv extension</p>
<pre>
/usr/lib/red5/webapps/oflaDemo/streams# ls -1 *.flv
DarkKnight.flv
IronMan.flv
on2_flash8_w_audio.flv
test.flv
</pre>
]]></content:encoded>
			<wfw:commentRss>http://cd34.com/blog/webserver/flowplayer-org-and-red5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx after one day and conversion of two more machines</title>
		<link>http://cd34.com/blog/scalability/nginx-after-one-day-and-conversion-of-two-more-machines/</link>
		<comments>http://cd34.com/blog/scalability/nginx-after-one-day-and-conversion-of-two-more-machines/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 20:16:59 +0000</pubDate>
		<dc:creator>cd34</dc:creator>
				<category><![CDATA[Scalability]]></category>
		<category><![CDATA[Webserver Software]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[openx]]></category>
		<category><![CDATA[phpadsnew]]></category>

		<guid isPermaLink="false">http://cd34.com/blog/?p=617</guid>
		<description><![CDATA[Nginx impressed me with the way it was written and its performance has impressed me as well. This one client has 3 machines that ran Apache2-mpm-worker with php5 running under fastcgi.  While page response time was good, the machines constantly ran at roughly 15% idle cpu time, with roughly 600mb-700mb of the ram used for [...]]]></description>
			<content:encoded><![CDATA[<p>Nginx impressed me with the way it was written and its performance has impressed me as well.</p>
<p>This one client has 3 machines that ran Apache2-mpm-worker with php5 running under fastcgi.  While page response time was good, the machines constantly ran at roughly 15% idle cpu time, with roughly 600mb-700mb of the ram used for cache.  All of the machines are quadcore with 4gb RAM and have been running for quite a while and have been tweaked and tuned along the way.</p>
<p>We started with the conversion of one site on one machine which resulted in the client being so impressed that we converted a second site on that machine which resulted in about 80mb/sec being served from nginx within minutes of deployment.  The next morning after we glanced over everything and confirmed that nginx was holding up, we converted the rest of that machine over to Nginx.  Traffic grew almost 20% after that change.</p>
<p>We started looking at the other machines, one of which runs phpadsnew on a relatively large network of his sites and the banners that are served from two of the main sites on one machine.  Converting those two over to nginx meant another 50mb/sec of traffic swapped from Apache.  Immediately he saw results with faster pageloads of his sites that pulled content from a central domain and with the banner ads being displayed more quickly.  After a few moments of analysis, it was decided to swap the entire machine from Apache2 to Nginx.  That process took a few hours due to the number of virtual hosts and the lack of any real script to migrate the configurations.  Response time on the sites was definitely faster.  After a little more discussion, rather than give that machine a day to settle in to see if we would find any problems, we converted his third machine.</p>
<p>First response in the morning:</p>
<blockquote><p>yesterday we sent 69.1k unique surfers to sponsors, that is the highest we have ever done.</p></blockquote>
<p>While only one of three machines was running Nginx for the entire day, one machine had about 8 hours under Nginx and the other about 2 hours under Nginx for that &#8216;day.&#8217;</p>
<p>Today, the results are somewhat clear.  Traffic is up overall, the machines are much more responsive.  Each machine is now roughly 80% idle and has roughly 2.4gb of memory reserved for cache.</p>
<p><a href="http://cd34.colocdn.com/blog/wp-content/uploads/2009/04/75.png"><img class="aligncenter size-medium wp-image-618" src="http://cd34.colocdn.com/blog/wp-content/uploads/2009/04/75-300x135.png" alt="75" width="300" height="135" /></a></p>
<p><a href="http://cd34.colocdn.com/blog/wp-content/uploads/2009/04/76.png"><img class="aligncenter size-medium wp-image-619" src="http://cd34.colocdn.com/blog/wp-content/uploads/2009/04/76-300x135.png" alt="76" width="300" height="135" /></a></p>
<p><a href="http://cd34.colocdn.com/blog/wp-content/uploads/2009/04/861.png"><img class="aligncenter size-medium wp-image-620" src="http://cd34.colocdn.com/blog/wp-content/uploads/2009/04/861-300x135.png" alt="861" width="300" height="135" /></a></p>
<p>Backups are scheduled at 3am on the boxes, a few rsync jobs are run to keep some content directories synced between the machines.  Overall you can see the impact on the first graph as the right hand side shows a bit more growth.  The last graph was running nginx, but, struggled to push more than 85mb/sec or so.  The middle graph shows a decline, but, they believe that is external to the process.  The sites are loading more quickly and they expect that the sites will grow quite a bit.  So far, they are reporting roughly an 18% increase in clicks to their sponsor.</p>
]]></content:encoded>
			<wfw:commentRss>http://cd34.com/blog/scalability/nginx-after-one-day-and-conversion-of-two-more-machines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Varnish and Apache2</title>
		<link>http://cd34.com/blog/scalability/varnish-and-apache2/</link>
		<comments>http://cd34.com/blog/scalability/varnish-and-apache2/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 20:07:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scalability]]></category>
		<category><![CDATA[Webserver Software]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Varnish]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://cd34.com/blog/?p=615</guid>
		<description><![CDATA[One client had some issues with Apache2 and a WordPress site. While WordPress isn&#8217;t really a great performer, this client had multiple domains on the same IP and dropping Nginx in didn&#8217;t seem like it would make sense to solve the immediate problem. First things first, we evaluated where the issue was with WordPress and [...]]]></description>
			<content:encoded><![CDATA[<p>One client had some issues with Apache2 and a WordPress site.  While WordPress isn&#8217;t really a great performer, this client had multiple domains on the same IP and dropping Nginx in didn&#8217;t seem like it would make sense to solve the immediate problem.</p>
<p>First things first, we evaluated where the issue was with WordPress and installed db-cache and wp-cache-2.  We had tried wp-super-cache but had seen some issues with it in some configurations.  Immediately the pageload time dropped from 41 seconds to 11 seconds.  Since the machine was running on a quadcore with 4gb ram and was running mostly idle, the only thing left was the 91 page elements being served.  Each pageload, even with pipelining still seemed to cause some stress.  Two external javascripts and one external flash object caused some delay in rendering the page.  The javascripts were actually responsible for holding up the page rendering which made the site seem even slower than it was.  We made some minor modifications, but, while apache2 was configured to serve things as best it could, we felt there was still some room for improvement.</p>
<p>While I had tested <a href="/blog/infrastructure/apache-varnish-nginx-and-lighttpd/">Varnish in front of Apache2</a>, I knew it would make an impact in this situation due to the number of elements on the page and the fact that apache did a lot of work to serve each request.  Varnish and its VCL eliminated a lot of the overhead Apache had and should result in the capacity for roughly 70% better performance.  For this installation, we removed the one IP that was in use by the problem domain from Apache and used that for Varnish and ran Varnish on that IP, using 127.0.0.1 port 80 as the backend.</p>
<p>Converting a site that is in production and live is not for the fainthearted, but, here are a few notes.</p>
<p>For Apache you&#8217;ll want to add a line like this to make sure your logs show the remote IP rather than the IP of the Varnish server:</p>
<pre>
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-A
gent}i\"" varnishcombined
</pre>
<p>Modify each of the VirtualHost configs to say:</p>
<pre>
&lt;VirtualHost 127.0.0.1:80>
</pre>
<p>and change the line for the logfile to say:</p>
<pre>
CustomLog /var/log/apache2/domain.com-access.log varnishcombined
</pre>
<p>Add Listen Directives to prevent Apache from listening to port 80 on the IP address that you want varnish to answer and comment out the default Listen 80:</p>
<pre>
#Listen 80
Listen 127.0.0.1:80
Listen 66.55.44.33:80
</pre>
<p>Configuration changes for Varnish:</p>
<pre>
backend default {
.host = "127.0.0.1";
.port = "80";
}

sub vcl_recv {
  if (req.url ~ "\.(jpg|jpeg|gif|png|tiff|tif|svg|swf|ico|mp3|mp4|m4a|ogg|mov|avi|wmv)$") {
      lookup;
  }

  if (req.url ~ "\.(css|js)$") {
      lookup;
  }
}
sub vcl_fetch {
        if( req.request != "POST" )
        {
                unset obj.http.set-cookie;
        }

        set obj.ttl = 600s;
        set obj.prefetch =  -30s;
        deliver;
}
</pre>
<p>Shut down Apache, Restart Apache, Start Varnish.</p>
<p>tail -f the logfile for Apache for one of the domains that you have moved.  Go to the site.  Varnish will load everything the first time, but, successive reloads shouldn&#8217;t show requests for images, javascript, css.  For this client we opted to hold things in cache for 10 minutes (600 seconds).</p>
<p>Overall, the process was rather seamless.  Unlike converting a site to Nginx, we are not required to make changes to the rewrite config or worry about setting up a fastcgi server to answer .php requests.  Overall, varnish is quite seamless to the end product.  Clients will lose the ability to do some things like deny hotlinking, but, Varnish will run almost invisibly to the client.  Short of the page loading considerably quicker, the client was not aware we had made any server changes and that is the true measure of success.</p>
]]></content:encoded>
			<wfw:commentRss>http://cd34.com/blog/scalability/varnish-and-apache2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>First Impressions of Nginx</title>
		<link>http://cd34.com/blog/webserver/first-impressions-of-nginx/</link>
		<comments>http://cd34.com/blog/webserver/first-impressions-of-nginx/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 06:22:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Webserver Software]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[tux]]></category>

		<guid isPermaLink="false">http://cd34.com/blog/?p=613</guid>
		<description><![CDATA[When I did the testing last week, I didn&#8217;t expect overly dramatic results. Yes, replacing apache and moving to a FastCGI/PHP installation did seem to make sense and nginx definitely is designed to handle things well. The conversion of one virtualhost on that machine resulted in a few minor hitches. Rewrite rules are a little [...]]]></description>
			<content:encoded><![CDATA[<p>When I did the testing last week, I didn&#8217;t expect overly dramatic results.  Yes, replacing apache and moving to a FastCGI/PHP installation did seem to make sense and nginx definitely is designed to handle things well.</p>
<p>The conversion of one virtualhost on that machine resulted in a few minor hitches.  Rewrite rules are a little different and while our conversion of those rules mostly worked, a few minor differences in the syntax cropped up and needed slight adjustments.  </p>
<pre>
RewriteRule ^external/([0-9]+)/? external.php?vid=$1 [L]
</pre>
<p>changes to</p>
<pre>
rewrite "^/external/([0-9]+)/?" /external.php?vid=$1 last;
</pre>
<p>The leading / is now required in both places but the rule converts over fairly nicely.</p>
<p>Performance tuning is tricky at best since there aren&#8217;t too many documents that explain the different config arguments, and, very few that explain how to diagnose and tune.  Most is done through trial and error watching the processes, watching logs, seeing the system react and making adjustments.</p>
<p>Virtual Host configuration was a challenge at first as the documentation assumes that the machine will just listen on port 80.  When the machine shares the IPs with Apache which is also answering on port 80 and you&#8217;re just moving a few things over, you need to make some minor changes.</p>
<pre>
server {
        listen 66.55.44.33:80 default;
        server_name  _;

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

        location / {
                root   /var/www/uc;
                index  index.html;
        }
}

server {
        listen 66.55.44.33:80;
        server_name  www.domain.com domain.com;
</pre>
<p>made virtual hosting work when you are only able to listen to a few IPs.</p>
<p>Overall, I am reasonably impressed with Nginx.  The machine we upgraded was pushing about 65mb/sec, with a load of 15 and roughly 15% idle CPU.  After moving 2 domains over to Nginx, the machine almost instantly climbed to 80mb/sec with a load of 2 and roughly 85% idle.  System Cache went from 880mb to 2.7gb and the number of Apache processes dropped from 350 to 40.  The machine is incredibly responsive now and the pages load almost instantly.</p>
<p>I&#8217;ll continue to monitor it, but, at this point it looks like a userland process will challenge Tux&#8217;s performance.</p>
]]></content:encoded>
			<wfw:commentRss>http://cd34.com/blog/webserver/first-impressions-of-nginx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
