<?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>Justin Carmony &#187; Linux</title>
	<atom:link href="http://www.justincarmony.com/blog/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.justincarmony.com/blog</link>
	<description>Web Designer &#38; Software Engineer</description>
	<lastBuildDate>Wed, 01 Feb 2012 04:30:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Siege with User Authentication</title>
		<link>http://www.justincarmony.com/blog/2011/11/03/siege-with-user-login/</link>
		<comments>http://www.justincarmony.com/blog/2011/11/03/siege-with-user-login/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 16:33:02 +0000</pubDate>
		<dc:creator>Justin Carmony</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[siege]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.justincarmony.com/blog/?p=1043</guid>
		<description><![CDATA[If you want to stress test your application, the quickest and best way to do so is with siege. From the siege website: Siege is an http load testing and benchmarking utility. It was designed to let web developers measure their code under duress, to see how it will stand up to load on the ...


Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2010/07/14/setting-up-ssh-key-authentication-between-servers/' rel='bookmark' title='Setting up SSH Key Authentication Between Servers'>Setting up SSH Key Authentication Between Servers</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/10/10/local-lamp-developement-user-content/' rel='bookmark' title='Local LAMP Developement &amp; User Content'>Local LAMP Developement &#038; User Content</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/11/27/my-php-user-group-experience/' rel='bookmark' title='My PHP User Group Experience'>My PHP User Group Experience</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>If you want to stress test your application, the quickest and best way to do so is with <a href="http://www.joedog.org/index/siege-home">siege</a>. From the siege website:</p>
<blockquote><p>Siege is an http load testing and benchmarking utility. It was designed to let web developers measure their code under duress, to see how it will stand up to load on the internet. Siege supports basic authentication, cookies, HTTP and HTTPS protocols. It lets its user hit a web server with a configurable number of simulated web browsers. Those browsers place the server &#8220;under siege.&#8221;</p></blockquote>
<p>On Linux, you can install it easily via yum or apt. On OS X, you can install it easily via <a href="http://mxcl.github.com/homebrew/">homebrew</a> or <a href="http://www.macports.org/">macports</a>. I personally prefer homebrew. In your terminal just type:</p>
<code class="code">brew install siege</code>
<p>Now you can stress test a given app by simply using the siege command:</p>
<code class="code">siege -c 10 -n 10 http://www.example.com/</code>
<p>You can read the <a href="http://www.joedog.org/index/siege-manual">documentation</a> and <a href="http://www.joedog.org/index/siege-faq">faq</a> on their site to learn more. However, there is one question I get a lot when talking about siege: &#8220;How can I use siege to test users who are logged in?&#8221;</p>
<p>I would always recommend that they send a session header in the config, but today I learned there is an even easier way (although undocumented), thanks to <a href="http://serverfault.com/questions/292679/stress-login-area-with-siege">this question in Server Fault</a>. In your siege&#8217;s configuration you can add the login-url directive:</p>
<code class="code"># Login URL. This is the first URL to be hit by every siege
# client. This feature was designed to allow you to login to 
# a server and establish a session. It will only be hit once
# so if you need to hit this URL more then once, make sure it
# also appears in your urls.txt file.
#
# ex: login-url = http://eos.haha.com/login.jsp POST name=jeff&amp;pass=foo
#
# login-url =</code>
<p>Awesome! Now each connection will authenticate before continuing their siege. A very handy tool, especially if your load is generated by user account pages and such.</p>


<p>Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2010/07/14/setting-up-ssh-key-authentication-between-servers/' rel='bookmark' title='Setting up SSH Key Authentication Between Servers'>Setting up SSH Key Authentication Between Servers</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/10/10/local-lamp-developement-user-content/' rel='bookmark' title='Local LAMP Developement &amp; User Content'>Local LAMP Developement &#038; User Content</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/11/27/my-php-user-group-experience/' rel='bookmark' title='My PHP User Group Experience'>My PHP User Group Experience</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.justincarmony.com/blog/2011/11/03/siege-with-user-login/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting Up Nginx &amp; PHP-FPM on Ubuntu 10.04</title>
		<link>http://www.justincarmony.com/blog/2011/10/24/setting-up-nginx-php-fpm-on-ubuntu-10-04/</link>
		<comments>http://www.justincarmony.com/blog/2011/10/24/setting-up-nginx-php-fpm-on-ubuntu-10-04/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 03:50:59 +0000</pubDate>
		<dc:creator>Justin Carmony</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[system administration]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[web servers]]></category>

		<guid isPermaLink="false">http://www.justincarmony.com/blog/?p=1020</guid>
		<description><![CDATA[This is another wonderful setup that I&#8217;ve found myself using rather than the traditional Apache &#038; mod_php setup. What is Nginx? Nginx (pronounced engine-x) is a fast, powerful, lightweight web server. I won&#8217;t go into the theory under-the-hood, but it&#8217;s focus is high concurrency with low memory usage. So while Apache is more robust in ...


Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2011/10/24/setting-up-percona-server-5-5-on-ubuntu-10-04/' rel='bookmark' title='Setting Up Percona Server 5.5 on Ubuntu 10.04'>Setting Up Percona Server 5.5 on Ubuntu 10.04</a></li>
<li><a href='http://www.justincarmony.com/blog/2011/09/13/preparing-a-vmware-ubuntu-guest-os/' rel='bookmark' title='Preparing a VMWare Ubuntu Guest OS'>Preparing a VMWare Ubuntu Guest OS</a></li>
<li><a href='http://www.justincarmony.com/blog/2011/01/24/php-nginx-and-output-flushing/' rel='bookmark' title='PHP, Nginx, and Output Flushing'>PHP, Nginx, and Output Flushing</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This is another wonderful setup that I&#8217;ve found myself using rather than the traditional Apache &#038; mod_php setup.</p>
<h2>What is Nginx?</h2>
<p>Nginx (pronounced engine-x) is a fast, powerful, lightweight web server. I won&#8217;t go into the theory under-the-hood, but it&#8217;s focus is high concurrency with low memory usage. So while Apache is more robust in supporting many different features, nginx focuses on handling the important features very quickly. I still use Apache internally for our SVN &#038; Trac web server. Heck, even at this time I&#8217;m using Apache to host this blog. However, Dating DNA, Clipish, CEVO, Alienware Arena, and some other high traffic sites/apis use nginx.</p>
<p>Ngnix, unlike Apache, doesn&#8217;t actually load PHP. Instead, it hands it off as a proxy to a &#8220;php handler&#8221; which acts like an Application Server. So nginx by itself won&#8217;t serve PHP files, but just static files.</p>
<h2>What is PHP-FPM?</h2>
<p>In the past, when working with something like Nginx or lighttpd, you would use spawn-fcgi to host your PHP application. However, spawn-fcgi had some major drawbacks and problems. So a guy named Andrei Nigmatulin created PHP-FPM, which stands for &#8220;PHP FastCGI Process Manager.&#8221; Since then, several others have contributed and ultimately it was include into the PHP core in version 5.3.3.</p>
<p>So from a high level look, on every PHP request Apache will load the entire installed PHP environment each time. This is for every request, and while it has been optimized as much as it can, that is a <strong>lot</strong> of overhead! With PHP-FPM, it will spin up a configurable amount of children. Each load the PHP environment and then will serve as many requests as it can without having to reload the environment. This saves on a lot of overhead!</p>
<h2>Why use Nginx &#038; PHP-FPM?</h2>
<p>I should note, it is possible to configure/compile Apache in such a way that it can have similar performance capabilities. However, it takes a <strong>ton of work</strong>. Meanwhile, Nginx &#038; PHP-FPM are very fast from the start, so I prefer just using them. You do lose some features, like .htaccess files won&#8217;t work so you&#8217;ll have to do that configuration in your virtual hosts.<br />
<span id="more-1020"></span></p>
<h2>How to Setup Nginx &#038; PHP-FPM</h2>
<p><strong>Nginx</strong></p>
<p>First off, lets setup Nginx.</p>
<code class="code">sudo aptitude update
sudo apt-get install nginx
/etc/init.d/nginx start</code>
<p>Thats it! If you go to your server&#8217;s IP Address or Domain Name you should see a &#8220;Welcome to Nginx!&#8221;</p>
<p><strong>PHP-FPM</strong></p>
<p>Because PHP-FPM is only included by default in PHP 5.3.3 and later, and Ubuntu 10.04 LTS only has PHP 5.2.3, we have two options. Either we can install by source, or we can add another repository to install PHP-FPM. The latter is much, much easier, and there is a good PHP-FPM Repo for Ubuntu 10.04. To add it, you just run the following commands:</p>
<code class="code">sudo aptitude install python-software-properties
sudo add-apt-repository ppa:brianmercer/php
sudo aptitude update</code>
<p>Now that we have the new repository, we can install PHP5:</p>
<code class="code">sudo aptitude install php5-cli php5-common php5-mysql php5-suhosin php5-gd php5-dev
sudo aptitude install php5-fpm php5-cgi php-pear php5-memcache php-apc
/etc/init.d/php5-fpm restart</code>
<p>Excellent! Now, if you need to change some of PHP-FPM&#8217;s configurations, they are found in /etc/php5/fpm/. The file php5-fpm.conf configures how FPM will opporate, and the php.ini is the settings file that PHP will use while running in FPM.</p>
<p>A few settings I like to change in /etc/php5/fpm/php5-fpm.conf:</p>
<code class="code">pm.max_children = 20</code>
<p>The php5-fpm.conf that comes is pretty well documented on the different settings. Once you make a change, make sure to restart php5-fpm.conf: /etc/init.d/php5-fpm restart</p>
<p><strong>Configuring Nginx</strong></p>
<p>Now, we have a few settings for Nginx. The configuration files are found in /etc/nginx/. First we&#8217;ll edit nginx.conf. Here are a few settings we&#8217;ll want to change:</p>
<code class="code">user www-data;
worker_processes  4; # 1 to 4, I normally put this to the number of cores

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    multi_accept on; # uncomment this line
    use epoll; # Add This - We'll want Nginx to use epoll for event timing
}

http {
    include       /etc/nginx/mime.types;

    access_log  /var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_disable &quot;MSIE [1-6]\.(?!.*SV1)&quot;;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}</code>
<p>Now, we need to add a VirtualHost! Nginx uses the same layout in Ubuntu as Apache, so we&#8217;ll add configurations for each site we want under /etc/nginx/sites-available/. So using vi, nano, or whichever editor you prefer, create a /etc/nginx/sites-available/www.example.com file:</p>
<code class="code"># rewrite from example.com to www.example.com
server { 
	listen 80;
	server_name example.com;
	rewrite ^(.*) http://www.example.com$1 permanent;
}

server {
    listen   80;
    server_name www.example.com;
    access_log /var/log/nginx/www.example.com.access.log;
    error_log /var/log/nginx/www.example.com.error.log;

	client_max_body_size 4M;
	client_body_buffer_size 128k;
	expires 24h;
 
    location / {
        root   /var/www/example.com/;
        index index.html index.php;
		
        # if file exists return it right away
        if (-f $request_filename) {
                break;
        }

        if (-e $request_filename)
        {
                break;
        }

        # Useful rewrite for most frameworks, wordpress
        if (!-e $request_filename) {
                rewrite ^(.+)$ /index.php last;
                break;
        }

    }

    location /nginx_status {
      # copied from http://blog.kovyrin.net/2006/04/29/monitoring-nginx-with-rrdtool/
      stub_status on;
      access_log   off;
      allow 127.0.0.1;
      deny all;
    }

    location ~ \.php$ {
        expires off;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/www/example.com/$fastcgi_script_name;
    }
}</code>
<p>Now, we need to create the symlink from sites-enabled to sites-available:</p>
<code class="code">ln -s /etc/nginx/sites-available/www.example.com /etc/nginx/sites-enabled/www.example.com</code>
<p>Restart nginx with &#8220;/etc/init.d/nginx restart&#8221;. Go ahead and put a test.php file in your directory with a Hello World example, and see if it works. It should work, and you should be good to go.</p>


<p>Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2011/10/24/setting-up-percona-server-5-5-on-ubuntu-10-04/' rel='bookmark' title='Setting Up Percona Server 5.5 on Ubuntu 10.04'>Setting Up Percona Server 5.5 on Ubuntu 10.04</a></li>
<li><a href='http://www.justincarmony.com/blog/2011/09/13/preparing-a-vmware-ubuntu-guest-os/' rel='bookmark' title='Preparing a VMWare Ubuntu Guest OS'>Preparing a VMWare Ubuntu Guest OS</a></li>
<li><a href='http://www.justincarmony.com/blog/2011/01/24/php-nginx-and-output-flushing/' rel='bookmark' title='PHP, Nginx, and Output Flushing'>PHP, Nginx, and Output Flushing</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.justincarmony.com/blog/2011/10/24/setting-up-nginx-php-fpm-on-ubuntu-10-04/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Preparing a VMWare Ubuntu Guest OS</title>
		<link>http://www.justincarmony.com/blog/2011/09/13/preparing-a-vmware-ubuntu-guest-os/</link>
		<comments>http://www.justincarmony.com/blog/2011/09/13/preparing-a-vmware-ubuntu-guest-os/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 07:11:09 +0000</pubDate>
		<dc:creator>Justin Carmony</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[development environment]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://www.justincarmony.com/blog/?p=1006</guid>
		<description><![CDATA[I forget these steps all the time, so I figured I should record them here. A lot of times VMWare will auto-install the VMWare tools for you when you first setup your VM. However, many times after setting it up I&#8217;ll do updates, and updates to the kernel will be applied, knocking out the VMWare ...


Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/10/10/ubuntu-desktop-terminal-su/' rel='bookmark' title='Ubuntu Desktop Terminal &#8211; Su'>Ubuntu Desktop Terminal &#8211; Su</a></li>
<li><a href='http://www.justincarmony.com/blog/2011/03/30/sending-email-from-non-email-ubuntu-server/' rel='bookmark' title='Sending Email from non-email Ubuntu Server'>Sending Email from non-email Ubuntu Server</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/01/19/my-honest-attempt-with-linux-desktop/' rel='bookmark' title='My Honest Attempt With Linux Desktop'>My Honest Attempt With Linux Desktop</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I forget these steps all the time, so I figured I should record them here.</p>
<p>A lot of times VMWare will auto-install the VMWare tools for you when you first setup your VM. However, many times after setting it up I&#8217;ll do updates, and updates to the kernel will be applied, knocking out the VMWare Tools changes. These tools are used for things like file sharing between the guest and host. </p>
<p>So here are the steps to take to fully update and re-install the VMWare Tools. I got most of these from an <a href="https://help.ubuntu.com/community/VMware/Tools">article on Ubuntu&#8217;s website</a>. <span id="more-1006"></span></p>
<p>First, <code>sudo aptitude update</code> to make sure all my repository information is up-to-date.</p>
<p>Second, <code>sudo aptitude safe-upgrade</code> to get any and all updates for my newly installed OS.</p>
<p>Third, <code>sudo apt-get install build-essential linux-headers-`uname -r` psmisc</code> to install the linux headers for my kernel.</p>
<p>Fourth, copy and install the VMWare Tools:</p>
<p><code># make a mount point if needed :<br />
sudo mkdir /media/cdrom</p>
<p># Mount the CD<br />
sudo mount /dev/cdrom /media/cdrom</p>
<p># Make a dir for the VMWare Tools files<br />
mkdir ~/vmtools</p>
<p># Copy and extract VMWareTools<br />
sudo cp /media/cdrom/VMwareTools*.tar.gz ~/vmtools</p>
<p># You can extract with archive manager, right click on the archive and extract ... or<br />
cd ~/vmtools<br />
tar xvf VMwareTools*.tar.gz</p>
<p># Install the tools<br />
cd vmware-tools-distrib<br />
sudo ./vmware-install.pl</code></p>
<p>Just follow the prompts and hit <enter> for all the default values. </p>


<p>Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/10/10/ubuntu-desktop-terminal-su/' rel='bookmark' title='Ubuntu Desktop Terminal &#8211; Su'>Ubuntu Desktop Terminal &#8211; Su</a></li>
<li><a href='http://www.justincarmony.com/blog/2011/03/30/sending-email-from-non-email-ubuntu-server/' rel='bookmark' title='Sending Email from non-email Ubuntu Server'>Sending Email from non-email Ubuntu Server</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/01/19/my-honest-attempt-with-linux-desktop/' rel='bookmark' title='My Honest Attempt With Linux Desktop'>My Honest Attempt With Linux Desktop</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.justincarmony.com/blog/2011/09/13/preparing-a-vmware-ubuntu-guest-os/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Working with Middle-Scale Websites</title>
		<link>http://www.justincarmony.com/blog/2011/07/18/working-with-middle-scale-websites/</link>
		<comments>http://www.justincarmony.com/blog/2011/07/18/working-with-middle-scale-websites/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 00:02:40 +0000</pubDate>
		<dc:creator>Justin Carmony</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[middle-scale]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[scaling]]></category>
		<category><![CDATA[system administration]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.justincarmony.com/blog/?p=940</guid>
		<description><![CDATA[I&#8217;ve been thinking about this idea for awhile, and I thought I would put a name to the thought. I brought up this idea while I was giving my &#8220;Real Life Scaling&#8221; presentation at the Utah Open Source Conference in 2009. Here is the problem I think most individuals in the web development face: Hopefully ...


Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2009/04/18/data-backups-there-are-no-excuses/' rel='bookmark' title='Data Backups &#8211; There Are No Excuses'>Data Backups &#8211; There Are No Excuses</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/09/16/speaking-utah-open-source-conference-2009/' rel='bookmark' title='Speaking: Utah Open Source Conference 2009'>Speaking: Utah Open Source Conference 2009</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/10/11/presentation-real-life-scaling/' rel='bookmark' title='Presentation: Real Life Scaling'>Presentation: Real Life Scaling</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been thinking about this idea for awhile, and I thought I would put a name to the thought. I brought up this idea while I was giving my &#8220;Real Life Scaling&#8221; presentation at the Utah Open Source Conference in 2009. Here is the problem I think most individuals in the web development face:</p>
<p>Hopefully at some point, your website gets a lot of traffic. Yay, you&#8217;ve reached your goal of getting good traffic, but it is soon followed by issues with performance and load. I like to call these the growing pains of a website. So as a web developer, I suddenly have the epiphany of &#8220;Hey, I need to scale my website!&#8221; What follows next is the biggest mistake a web developer can make:</p>
<p>They start looking at articles on how Google scales, or maybe how Facebook manages all of their traffic.</p>
<p><strong>This is a mistake!</strong> To be brutally honest, you are <strong>not</strong> Google. You are not Facebook. You are not Twitter. You are a website that receives less than 0.000001% of the traffic that some major websites receive.</p>
<p>Why is this dangerous for web developers to do? Google, Twitter, Facebook, and others like them are solving complicated at a very large scale. I remember a presentation by a Twitter engineer who developed a program for a unique ID generator that can generate millions of IDs per second. The probability of you needing this type of solution is about the same as being struck by lightening. Applying these same practices at a much smaller scale are not realistic. If a locally owned grocery store wanted to open a second store, they would not adopt the same practices that Wal-mart use to manage their 8970 stores.</p>
<h2>A Little Reality Check</h2>
<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/07/StackExchange.png"><img src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/07/StackExchange.png" alt="" title="StackExchange" width="300" height="80" class="alignnone size-full wp-image-941" /></a></p>
<p>I&#8217;m sure that most of my readers know of <a href="http://stackexchange.com/">StackExchange.com</a>. They power the popular website <a href="http://stackoverflow.com/">StackOverflow</a> and <a href="http://stackexchange.com/sites">several others</a>. They have about two million visitors per day. That is a <em>lot</em> of traffic. StackOverflow is ranked #123 on Alexa. So you would imagine that they have a very large infrastructure serving all of this traffic?</p>
<p>Earlier this year, Stack Exchange wrote <a href="http://blog.serverfault.com/post/stack-exchanges-architecture-in-bullet-points/">an article about their production environment</a>. I was surprised on what exactly they were using. In paticular, the number of Production Servers*:</p>
<blockquote><ul>
<li>12 Web Servers (Windows Server 2008 R2)</li>
<li>2 Database Servers (Windows Server 2008 R2 and SQL Server 2008 R2)</li>
<li>2 Load Balancers (Ubuntu Server and HAProxy)</li>
<li>2 Caching Servers (Redis on CentOS)</li>
<li>1 Router / Firewall (Ubuntu Server)</li>
<li>3 DNS Servers (Bind on CentOS)</li>
</ul>
</blockquote>
<p>That is 22 servers for 2 Million Visits per day, serving 800 HTTP requests per second. Now, StackExchange did clarify that they did have other servers for management and fail over, but 22 servers handle their production load. This is a website that is ranked the 123rd most visited website in the world.</p>
<p>Honestly, most websites could be run on half a dozen servers if designed and configured correctly, including redundancy. Some really busy websites could run off a dozen servers. Unless you&#8217;re in the top 5,000 websites on the web, you really shouldn&#8217;t be worried about large-scale techniques. </p>
<p>So when you&#8217;re website is starting to grow, and you leave small scale, you&#8217;ll enter the phase of &#8220;Middle-Scale.&#8221;</p>
<h2>What is Middle-Scale?</h2>
<p>Middle-Scale is like being an awkward teenager:</p>
<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/07/cera-awkward.jpeg"><img src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/07/cera-awkward-300x200.jpg" alt="" title="cera-awkward" width="300" height="200" class="alignnone size-medium wp-image-942" /></a></p>
<p>You know that you can&#8217;t be the only one suffering through this, but you&#8217;re unsure how to proceed. It feels like you&#8217;re missing missing out on things everyone else must already know, but aren&#8217;t talking about. Like everyone else are awesome vampires or something:</p>
<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/07/twilight-cast.jpeg"><img src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/07/twilight-cast-300x225.jpg" alt="" title="twilight-cast" width="300" height="225" class="alignnone size-medium wp-image-943" /></a></p>
<p>But the reality is this: they don&#8217;t have some awesome secret! They are just normal teenagers.</p>
<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/07/teenage-friends.jpeg"><img src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/07/teenage-friends-300x200.jpg" alt="" title="teenage-friends" width="300" height="200" class="alignnone size-medium wp-image-944" /></a></p>
<p>This same idea applies to Middle-Scale websites.</p>
<p>Middle-Scale is when the <strong>most important things are <em>still</em> the best practices</strong>. Only now when you deviate from them you can feel those consequences. When you only had 100 users, a couple of nested queries and missing indexes didn&#8217;t cause that much of a problem. Your database is powerful enough to hide the inefficiencies. However, when you get to 10,000 users, your database can no longer hide the inefficiencies.</p>
<p>Middle-Scale is when simply separating your web server and database server isn&#8217;t enough. You&#8217;ll probably need to add some sort of cache like <a href="http://www.justincarmony.com/blog/2009/06/24/writing-effictive-php-caches-with-memcached/">memcached</a>. You&#8217;ll need to start tweaking your MySQL, Apache, and PHP configurations. </p>
<p>Then, after you&#8217;ve ironed out your inefficiencies, you&#8217;ll start to use multiple servers. You&#8217;ll probably add a Load Balancer with multiple web servers. After that, you&#8217;ll probably have some sort of Master-Slave replication for your Database for backups and fail-overs.</p>
<p>You start to leave this &#8220;Middle-Scale&#8221; classification when you move to multiple data centers, and start to do some load balancing at the the DNS layer. This is when you&#8217;ll start to have a dedicated sys-admin team.</p>
<h2>Okay, I&#8217;m Middle-Scale! So what should I do? Where do I look?</h2>
<p>First off, you <strong>must adhere to best practices.</strong> If you are working with PHP, research PHP performance and best practices. Do they same for each of your technologies, like Apache and MySQL. You will need to stop treating your application as one big app, and start to understand all of it&#8217;s moving parts.</p>
<p>Second, you <strong>must understand your specific problems.</strong> Scaling ins&#8217;t a problem, nor is it a solution. It is a generic term for many different types of solutions. Without understanding why your website is running slow, or why it cannot handle the load, you will not be able to create an effective solution.</p>
<p>So you don&#8217;t have a scaling problem. You have a MySQL performance issue, or a Apache problem, or a PHP problem. Most likely, it is something extremely specific. You have a high volume of MySQL write operations (i.e. UPDATE, INSERT, DELETE, REPLACE), or perhaps you are missing some indexes and have too many full table scans. </p>
<p>Third, Googling for help will only get you so far. You are starting to enter a phase when it is harder and harder to find answers to your broad issues. Talking with other experienced people who have gone through the Middle-Scale pains before will help immensely. <a href="http://www.justincarmony.com/blog/2009/11/27/my-php-user-group-experience/">I cannot recommend highly enough going to User groups</a>. Being able to communicate with someone, either face to face, on the Phone, over IRC, etc. is invaluable. While I&#8217;ve learned a lot at conference and usergroup presentations, I&#8217;ve learned even more by just talking with the people attending and at the social gatherings.</p>
<h2>Profile &#038; Performance will Naturally Lead to Scaling</h2>
<p>When you want to scale, it can feel like a very daunting task. It seems like this big unknown complicated solution. What in the world am I going to do? I remember feeling these worries when I first started to investigate load balancing and sharding for some websites I was working on.</p>
<p>The thing is, if you start to profile your application, you will discover it&#8217;s inefficiencies. I remember when I spent a sold week, working 12-16 hours a day profiling and optimizing Dating DNA&#8217;s database. I found a lot of bad queries, and I was able to cut our load times from 2-5 seconds to under 0.1 seconds. The CPU on the database server went from 80-90% CPU utilization to under 10%. It was incredible, and then I promptly took the entire next week off. When we migrated to new servers, I was able to move to less powerful database server and still have the same great performance. So by profiling and optimizing our database, I didn&#8217;t need to worry about spinning up multiple master databases and sharding our data.</p>
<p>With Clipish, we faced almost opposite scaling problems. The database was rarely an issue, but our web server CPU&#8217;s were. We do a lot of ImageMagick manipulations of images, and at high volumes on virtual servers this can be a big issue. So over the last year we&#8217;ve introduced some load balancing and CDN tools to help serve all 10 TB of bandwidth for Clipish.</p>
<p>The thing is, when you start to profile your application, you start to understand it&#8217;s low areas better, so you have a much better idea on what do to. Even if you don&#8217;t know your solution, it is much easier to find a solution with a sound understanding of the problem. For example &#8220;scaling mysql&#8221; yields much less helpful results than &#8220;mysql full table scans&#8221; in Google.</p>
<h2>So should I ignore what Facebook and Google do for scaling?</h2>
<p>Of course not! First off, they do cool stuff. Just because I&#8217;ll watch NASA launch a space shuttle doesn&#8217;t mean I&#8217;ll try to make a rocket system for my broken lawn mower. But you have to put what they are doing into context. People from large websites have published several good &#8220;best practices&#8221; articles on techniques that help any website. Especially things on the client/browser side of things. Just use caution. I cringe when I hear someone say &#8220;we&#8217;re trying to use Cassandra to solve XYZ problem at work&#8221; when it is severe overkill. </p>
<h2>Final Thoughts</h2>
<p>Most of the time when I talk about performance and scaling with other people, it is when they are in &#8220;critical mode.&#8221; Their website is down, slow, unusable, etc, and they are looking to fix the problem. I will say, it is much more difficult to profile in &#8220;critical mode&#8221; than profiling before hand. The reason is you are much more desperately focused on getting it working again instead of understanding the problem. </p>
<p>I&#8217;ll be giving a presentation this Thursday at UPHPU on Profiling PHP Applications. I&#8217;ll post the slides, and most likely write some articles on the subject afterwards. As always, feel free to email me or leave a comment.</p>


<p>Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2009/04/18/data-backups-there-are-no-excuses/' rel='bookmark' title='Data Backups &#8211; There Are No Excuses'>Data Backups &#8211; There Are No Excuses</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/09/16/speaking-utah-open-source-conference-2009/' rel='bookmark' title='Speaking: Utah Open Source Conference 2009'>Speaking: Utah Open Source Conference 2009</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/10/11/presentation-real-life-scaling/' rel='bookmark' title='Presentation: Real Life Scaling'>Presentation: Real Life Scaling</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.justincarmony.com/blog/2011/07/18/working-with-middle-scale-websites/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Simple Trick: History Command</title>
		<link>http://www.justincarmony.com/blog/2011/05/31/simple-trick-history-command/</link>
		<comments>http://www.justincarmony.com/blog/2011/05/31/simple-trick-history-command/#comments</comments>
		<pubDate>Tue, 31 May 2011 21:05:08 +0000</pubDate>
		<dc:creator>Justin Carmony</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.justincarmony.com/blog/?p=932</guid>
		<description><![CDATA[So today I quickly installed Redis on a server, and I wanted to keep a copy of all the commands I had used to do so. I knew there was a better way than hitting the up arrow each time to copy and paste each command in reverse order. So after some Googling, I found ...


Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/06/30/soapui-a-simple-and-raw-java-soap-client/' rel='bookmark' title='SoapUI &#8211; a simple and raw Java SOAP Client'>SoapUI &#8211; a simple and raw Java SOAP Client</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/05/20/memcached-simple-effective-and-powerful/' rel='bookmark' title='Memcached: Simple, Effective, and Powerful'>Memcached: Simple, Effective, and Powerful</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/02/11/asp-net-ajax-straight-forward-and-simple-the-way-it-should-be/' rel='bookmark' title='ASP .NET Ajax &#8211; Straight forward and simple, the way it should be.'>ASP .NET Ajax &#8211; Straight forward and simple, the way it should be.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>So today I quickly installed Redis on a server, and I wanted to keep a copy of all the commands I had used to do so. I knew there was a better way than hitting the up arrow each time to copy and paste each command in reverse order. So after some Googling, I found out about the history command. So I was able to type the command &#8220;history&#8221; and it showed me the last two thousand or so commands I had used. I was able to copy and paste that into a wiki, and was good to go. You could also search your history by piping the history command to grep. Cool stuff I don&#8217;t want to forget.</p>


<p>Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/06/30/soapui-a-simple-and-raw-java-soap-client/' rel='bookmark' title='SoapUI &#8211; a simple and raw Java SOAP Client'>SoapUI &#8211; a simple and raw Java SOAP Client</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/05/20/memcached-simple-effective-and-powerful/' rel='bookmark' title='Memcached: Simple, Effective, and Powerful'>Memcached: Simple, Effective, and Powerful</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/02/11/asp-net-ajax-straight-forward-and-simple-the-way-it-should-be/' rel='bookmark' title='ASP .NET Ajax &#8211; Straight forward and simple, the way it should be.'>ASP .NET Ajax &#8211; Straight forward and simple, the way it should be.</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.justincarmony.com/blog/2011/05/31/simple-trick-history-command/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sharing Sessions Across Multiple Servers With Memcache</title>
		<link>http://www.justincarmony.com/blog/2010/09/15/sharing-sessions-across-multiple-servers-with-memcache/</link>
		<comments>http://www.justincarmony.com/blog/2010/09/15/sharing-sessions-across-multiple-servers-with-memcache/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 08:52:15 +0000</pubDate>
		<dc:creator>Justin Carmony</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[sessions]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[web servers]]></category>

		<guid isPermaLink="false">http://www.justincarmony.com/blog/?p=573</guid>
		<description><![CDATA[These last few days have been full of quickly implementing things I&#8217;ve only read about, but hadn&#8217;t done for myself. One situation was looking at splitting web traffic across multiple servers. In our case, we had only 2% of our website that would spike and increase our load by %1000 percent (I&#8217;m not joking) for ...


Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2010/05/04/setting-up-nagios-for-servers/' rel='bookmark' title='Setting up Nagios for Servers'>Setting up Nagios for Servers</a></li>
<li><a href='http://www.justincarmony.com/blog/2010/07/14/setting-up-ssh-key-authentication-between-servers/' rel='bookmark' title='Setting up SSH Key Authentication Between Servers'>Setting up SSH Key Authentication Between Servers</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/03/08/brother-hl-2070n-sharing-an-vista-printer-to-a-xp-machine/' rel='bookmark' title='Brother HL-2070N &#8211; Sharing an Vista Printer to a XP Machine'>Brother HL-2070N &#8211; Sharing an Vista Printer to a XP Machine</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2010/09/memcached-logo-200x152.png"><img src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2010/09/memcached-logo-200x152-150x150.png" alt="" title="memcached-logo-200x152" width="150" height="150" class="alignright wp-image-576" /></a>These last few days have been full of quickly implementing things I&#8217;ve only read about, but hadn&#8217;t done for myself. </p>
<p>One situation was looking at splitting web traffic across multiple servers. In our case, we had only 2% of our website that would spike and increase our load by %1000 percent (I&#8217;m not joking) for a short period of time. So instead of doing traditional load balancing, we opted for routing specific functions to a custom subdomain that would run on another server. That way if the thousands of crazy video game players (you know who you are), slam the servers trying to get a cool skin for their online avatar, it would only take down that one section. <span id="more-573"></span></p>
<p>Well, we were using <a href="http://www.php.net/manual/en/book.session.php">PHP Sessions</a>, and as you might know, they are file based. The problem is that when it&#8217;s file based, server A by default won&#8217;t have access to server B&#8217;s session files. This makes having a user stay logged in between servers a real pain. </p>
<p>After researching all sorts of possibilities, we decided to take the shortest route. You can write your own <a href="http://php.net/manual/en/function.session-set-save-handler.php">PHP Session Handlers</a>, but dealing with <a href="http://www.chipmunkninja.com/Troubles-with-Asynchronous-Ajax-Requests-g@">race conditions</a> and other pitfalls are left to the developer. </p>
<p>So, we decided to use the built in memcache session handler that has all the extra tricky stuff built in. All it takes is installing the php memcache module, and a few php.ini changes <a href="http://www.dotdeb.org/2008/08/25/storing-your-php-sessions-using-memcached/">outlined here</a>.  I&#8217;ve copied the text here to keep a record of it.</p>
<blockquote><p>
The first thing is to install the memcached server on your Debian server :</p>
<p>apt-get install memcached</p>
<p>Then, since the memcache PECL extension now provides its own session handler, it’s easy to plug PHP and memcached servers. Just install the appropriate extension (from Dotdeb) :</p>
<p>apt-get install php5-memcache</p>
<p>and change some of your PHP settings :</p>
<p>session.save_handler = files<br />
; session.save_path = &#8220;N;/path&#8221;</p>
<p>to :</p>
<p>session.save_handler = memcache<br />
; change server:port to fit your needs&#8230;<br />
session.save_path=&#8221;tcp://server:port?persistent=1&amp;weight=1&amp;timeout=1&amp;retry_interval=15&#8243;</p>
<p>That’s all! After relaunching your Apache2 server, your PHP sessions will be stored on the memcached server.</p></blockquote>
<p>Now, you&#8217;ll need to have <a href="http://memcached.org/">memcached</a>, the service, running somewhere that all your php web servers can access. <a href="http://www.justincarmony.com/blog/?s=memcached">In presentations I&#8217;ve given about memcached</a>, I talk about how memcached as zero built in security (well, maybe 0.1% security, close enough to zero). So you need to <a href="http://wiki.centos.org/HowTos/Network/IPTables">secure it with iptables</a> so that only the web servers can access your memcached service. </p>
<p>Tomorrow if I have time I might quickly document my experience of getting a Ubuntu 10.04 server running nginx + php. I was surprised at how easy it was, and even figuring out some more advanced configs were not bad. </p>


<p>Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2010/05/04/setting-up-nagios-for-servers/' rel='bookmark' title='Setting up Nagios for Servers'>Setting up Nagios for Servers</a></li>
<li><a href='http://www.justincarmony.com/blog/2010/07/14/setting-up-ssh-key-authentication-between-servers/' rel='bookmark' title='Setting up SSH Key Authentication Between Servers'>Setting up SSH Key Authentication Between Servers</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/03/08/brother-hl-2070n-sharing-an-vista-printer-to-a-xp-machine/' rel='bookmark' title='Brother HL-2070N &#8211; Sharing an Vista Printer to a XP Machine'>Brother HL-2070N &#8211; Sharing an Vista Printer to a XP Machine</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.justincarmony.com/blog/2010/09/15/sharing-sessions-across-multiple-servers-with-memcache/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Setting up SSH Key Authentication Between Servers</title>
		<link>http://www.justincarmony.com/blog/2010/07/14/setting-up-ssh-key-authentication-between-servers/</link>
		<comments>http://www.justincarmony.com/blog/2010/07/14/setting-up-ssh-key-authentication-between-servers/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 19:52:05 +0000</pubDate>
		<dc:creator>Justin Carmony</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.justincarmony.com/blog//?p=568</guid>
		<description><![CDATA[I always forget how to do this, so I have to look it up each time. This will make it easier the next time. It is so simple, just I always forget. First, I need to generate my ssh pub and private keys on the host server: ssh-keygen Second, I need to copy the pub ...


Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2010/05/04/setting-up-nagios-for-servers/' rel='bookmark' title='Setting up Nagios for Servers'>Setting up Nagios for Servers</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/10/10/local-lamp-developement-user-content/' rel='bookmark' title='Local LAMP Developement &amp; User Content'>Local LAMP Developement &#038; User Content</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2010/07/openssh-logo.png"><img src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2010/07/openssh-logo.png" alt="" title="openssh-logo" width="194" height="191" class="alignright size-full wp-image-592" /></a>I always forget how to do this, so I have to look it up each time. This will make it easier the next time. It is so simple, just I always forget.</p>
<p>First, I need to generate my ssh pub and private keys on the host server: ssh-keygen</p>
<p>Second, I need to copy the pub key to the remote server: ssh-copy-id -i id_rsa.pub user@server.local</p>
<p>Then, that it! Now that I wrote it down, I won&#8217;t forget it&#8230; I hope.</p>


<p>Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2010/05/04/setting-up-nagios-for-servers/' rel='bookmark' title='Setting up Nagios for Servers'>Setting up Nagios for Servers</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/10/10/local-lamp-developement-user-content/' rel='bookmark' title='Local LAMP Developement &amp; User Content'>Local LAMP Developement &#038; User Content</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.justincarmony.com/blog/2010/07/14/setting-up-ssh-key-authentication-between-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up Nagios for Servers</title>
		<link>http://www.justincarmony.com/blog/2010/05/04/setting-up-nagios-for-servers/</link>
		<comments>http://www.justincarmony.com/blog/2010/05/04/setting-up-nagios-for-servers/#comments</comments>
		<pubDate>Tue, 04 May 2010 21:17:20 +0000</pubDate>
		<dc:creator>Justin Carmony</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[system administration]]></category>

		<guid isPermaLink="false">http://www.justincarmony.com/blog/?p=561</guid>
		<description><![CDATA[Ok, so I need to confess, I haven&#8217;t been a good blogger. I&#8217;ve gone two months without writing a post, which is broke a 2 year streak. But, I&#8217;m going to post date these posts, since I can. How I&#8217;ve gone this long without setting up Nagios to monitor servers is beyond me. However, I ...


Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2010/03/22/cloud-to-bare-metal/' rel='bookmark' title='The Cloud to Bare Metal'>The Cloud to Bare Metal</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2010/05/nagios-logo.png"><img src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2010/05/nagios-logo.png" alt="" title="nagios-logo" width="291" height="78" class="alignright size-full wp-image-596" /></a>Ok, so I need to confess, I haven&#8217;t been a good blogger. I&#8217;ve gone two months without writing a post, which is broke a 2 year streak. But, I&#8217;m going to post date these posts, since I can.</p>
<p>How I&#8217;ve gone this long without setting up Nagios to monitor servers is beyond me. However, I was tired of my clients and so finding out a server was offline before me. So I threw up a 256MB virtual server on Slicehost, since I don&#8217;t have any servers with them at the moment, in case a data center went offline.</p>
<p>I put Ubuntu 10.04 LTS on the VM, and I followed the instructions found here on Linode: </p>
<p>http://library.linode.com/server-monitoring/nagios/ubuntu-10.04-lucid</p>
<p>It worked pretty well, but I think in the future I will just install the packages that come with the server distro. The reason being is there were several checking tools, like check_mysql and check_nrpe that were not installed because I didn&#8217;t have some dependencies installed. </p>
<p>Now after a few hours I have 9 servers being monitored with about two dozen services being monitored. I also found out that one server had a 96% full HDD, so it already is paying off. </p>
<p>On another note, for those who know me and are curious, I&#8217;m in full swing in finding sponsors for this years Utah Open Source Conference. I&#8217;ve talked to quite a few, just need to finalize and close their deals. If you know of a company interested in sponsoring this year&#8217;s conference, let me know (check the contact me link up above).</p>


<p>Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2010/03/22/cloud-to-bare-metal/' rel='bookmark' title='The Cloud to Bare Metal'>The Cloud to Bare Metal</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.justincarmony.com/blog/2010/05/04/setting-up-nagios-for-servers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Data Backups &#8211; There Are No Excuses</title>
		<link>http://www.justincarmony.com/blog/2009/04/18/data-backups-there-are-no-excuses/</link>
		<comments>http://www.justincarmony.com/blog/2009/04/18/data-backups-there-are-no-excuses/#comments</comments>
		<pubDate>Sun, 19 Apr 2009 00:04:48 +0000</pubDate>
		<dc:creator>Justin Carmony</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[Data Loss]]></category>
		<category><![CDATA[Horror Storries]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.justincarmony.com/blog/?p=408</guid>
		<description><![CDATA[Today I just had the terrible experience of having a database lose data, need to restore, only to not have a recent backup. If you haven&#8217;t had this experience before, please, take this serious. My wife was home for lunch as it happened, and she watched as the blood drained from my face. It only ...


Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/01/22/asp-net-gridview-access-to-data-in-code/' rel='bookmark' title='ASP .NET GridView Access to Data In Code'>ASP .NET GridView Access to Data In Code</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/01/08/the-dangers-of-twitter/' rel='bookmark' title='The Dangers of Twitter!'>The Dangers of Twitter!</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/01/12/mysql-40-million-rows-myisam-innodb/' rel='bookmark' title='MySQL, 40 Million Rows, MyISAM to InnoDB, 45 Minutes'>MySQL, 40 Million Rows, MyISAM to InnoDB, 45 Minutes</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Today I just had the terrible experience of having a database lose data, need to restore, only to not have a recent backup. If you haven&#8217;t had this experience before, please, take this serious. My wife was home for lunch as it happened, and she watched as the blood drained from my face. It only took a few seconds for the loss to happen, and immediately I knew exactly what the repercussions where. The immediate second thought that passes through your brain is &#8220;Where are my backups?&#8221; That is when I realized I didn&#8217;t have my nightly backups set up on this server. I quickly checked the file date on the last known backup I had.</p>
<p><strong>13 Days</strong>.</p>
<p>It could have been a lot worse, but it was still extremely bad. Those last thirteen days had been record setting days. Emails each day were going around about record new signups, records internal messages sent, etc. Those thirteen had been the best 13 days by far.</p>
<p>If some of you are wondering what had happened, and know me to be very diligent in my backups, I did the one wrong, terrible thing: I made an assumption. I&#8217;ve <a href="http://www.justincarmony.com/blog/2009/01/12/mysql-40-million-rows-myisam-innodb/" target="_blank">blogged before on how backups have saved me in the past</a>, and how I am almost a fanatic about them. So what the heck happened?</p>
<p>This website was on some hardware that was starting to get overburdened.  Then, out of the blue, our traffic exploded and our web server and database server started to grind to a halt. I spent long hours and sleepless nights migrating from these old servers from a terrible host to some new virtual machines. We then discovered our MySQL Database was so intense that the virtual server couldn&#8217;t handle the CPU and I/O requirements. Finally, in a last attempt of desperation I moved the Database to a spare box of another company who gave me permission to use it temporarily. That finally worked and allowed us to handle the load on our Database. By the time I finished this, it was about 8 AM in the morning and I went to bed.</p>
<p>I assumed we&#8217;d only be on this box for a day or two, so I didn&#8217;t setup the backup scripts. However, it gave us more breathing room than we expected, and other issues came up non-db related. The company lending the us the server said we could take our time, so the urgency on ordering our new hardware was pushed off more and more. I had completely forgotten about setting up backups scripts, and we ended up where we are now.</p>
<h2>What I&#8217;m Changing Personally</h2>
<p>I&#8217;ve decided to make two changes personally after this experience.</p>
<p>First, there are zero excuses for not having automated backups. Zero, zilch, nada! If a backup should have occurred, there is no excuse for it not to happen.</p>
<p>Secondly, I&#8217;m going to pick a day of the month where before I do anything else, I verify that all the backups are working. My father-in-law on the first business day of the month has the habit of doing his business&#8217;s billing and other accounting activities. He lets just about nothing stand in the way, and all ways checks his bank accounts and records to make sure everything is in order. I&#8217;m going to adopt this same idea, only with servers and data. The first business day of the month I&#8217;m going to go through all the servers under my care, verify the backups are working, check error logs, etc. I want to catch the problem before anyone else does.</p>
<h2>How To Prevent Data Loss</h2>
<p>Here are a few guidelines to make sure you don&#8217;t fall victim to data loss.</p>
<ol>
<li><strong>Select a Backup Schedule &amp; Follow It 100% </strong>- I suggest for most websites, a daily backup will work out pretty well. If you have a lot of data that would really stink to lose that changes frequently through the day, you could backup several of the tables hourly.</li>
<li><strong>Back Up To Several Locations</strong> &#8211; I like my servers to have two hard drives. One for the live data and another for backups. Then, after a backup has been created, I like to sync that backed up data to another server. It is important that if a meteor fell from the sky and hit your data center (or a flood, fire, earthquake), you would have a very recent backup somewhere else.</li>
<li><strong>Verify Your Backups</strong> &#8211; I can&#8217;t stress this enough. After this terrible accident of not having a recent backup, I went and checked all my other website database backups. I found out that one critical database&#8217;s backups were broken and not running nightly. You never want to find out this information after you have to restore from a backup. Regularly verify that your backups are being created, and that you can restore from them.</li>
</ol>
<p>Hopefully this will motivate at least one person in our profession to evaluate their backup strategy and make it better. You don&#8217;t ever want to tell a client that you just lost 13 days of their record setting work.</p>


<p>Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/01/22/asp-net-gridview-access-to-data-in-code/' rel='bookmark' title='ASP .NET GridView Access to Data In Code'>ASP .NET GridView Access to Data In Code</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/01/08/the-dangers-of-twitter/' rel='bookmark' title='The Dangers of Twitter!'>The Dangers of Twitter!</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/01/12/mysql-40-million-rows-myisam-innodb/' rel='bookmark' title='MySQL, 40 Million Rows, MyISAM to InnoDB, 45 Minutes'>MySQL, 40 Million Rows, MyISAM to InnoDB, 45 Minutes</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.justincarmony.com/blog/2009/04/18/data-backups-there-are-no-excuses/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Recursively Add New Files to SVN</title>
		<link>http://www.justincarmony.com/blog/2009/02/20/recursively-add-new-files-to-svn/</link>
		<comments>http://www.justincarmony.com/blog/2009/02/20/recursively-add-new-files-to-svn/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 16:51:33 +0000</pubDate>
		<dc:creator>Justin Carmony</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.justincarmony.com/blog/?p=401</guid>
		<description><![CDATA[One great thing about running Windows is TortoiseSVN. I makes managing my SVN so easy. One of the problems I&#8217;ve ran into on other systems was I had been working for several hours. I would have dozens of new files and with TortoiseSVN it would show me a list of all the new files and ...


Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2009/02/14/xampp-for-mac-my-frustrations-solutions/' rel='bookmark' title='XAMPP for Mac &#8211; My Frustrations &amp; Solutions'>XAMPP for Mac &#8211; My Frustrations &#038; Solutions</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/01/21/list-of-50-php-tools/' rel='bookmark' title='List of 50 PHP Tools'>List of 50 PHP Tools</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/06/09/redesigning-blog/' rel='bookmark' title='Redesigning blog&#8230;.'>Redesigning blog&#8230;.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>One great thing about running Windows is TortoiseSVN. I makes managing my SVN so easy. One of the problems I&#8217;ve ran into on other systems was I had been working for several hours. I would have dozens of new files and with TortoiseSVN it would show me a list of all the new files and I could hit &#8220;select all&#8221; and commit. However, on Mac I haven&#8217;t found an SVN client that I like, so I just use the terminal commands. There are also times, like when managing a WordPress installation, that WordPress and its plug-ins could auto update. I wanted to be able to add all the new files on the linux server back into the svn.</p>
<p>I never could figure out how to do it until I read a <a href="http://codesnippets.joyent.com/posts/show/45" target="_blank">comment at a blog post</a>:</p>
<pre>svn st --ignore-externals | grep ^? | sed 's/\?/svn add/' | sh</pre>
<p>Man, shell is just awesome. This is better than the first suggestion of using &#8220;svn add &#8211;force *&#8221; because it would add ignored files as well. Hope this helps someone and makes them happy like I am now!</p>


<p>Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2009/02/14/xampp-for-mac-my-frustrations-solutions/' rel='bookmark' title='XAMPP for Mac &#8211; My Frustrations &amp; Solutions'>XAMPP for Mac &#8211; My Frustrations &#038; Solutions</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/01/21/list-of-50-php-tools/' rel='bookmark' title='List of 50 PHP Tools'>List of 50 PHP Tools</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/06/09/redesigning-blog/' rel='bookmark' title='Redesigning blog&#8230;.'>Redesigning blog&#8230;.</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.justincarmony.com/blog/2009/02/20/recursively-add-new-files-to-svn/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 36/131 queries in 0.061 seconds using memcached
Content Delivery Network via Rackspace Cloud Files: c747925.r25.cf2.rackcdn.com

Served from: www.justincarmony.com @ 2012-02-07 20:26:03 -->
