<?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>Derivante &#187; Web Technology</title>
	<atom:link href="http://www.derivante.com/category/web-technology/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.derivante.com</link>
	<description>to obtain or receive from a source</description>
	<lastBuildDate>Mon, 26 Apr 2010 18:44:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>PHP Content Rating / Confidence</title>
		<link>http://www.derivante.com/2009/09/01/php-content-rating-confidence/</link>
		<comments>http://www.derivante.com/2009/09/01/php-content-rating-confidence/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 21:15:51 +0000</pubDate>
		<dc:creator>Clay vanSchalkwijk</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Technology]]></category>
		<category><![CDATA[content analysis]]></category>
		<category><![CDATA[rating]]></category>

		<guid isPermaLink="false">http://www.derivante.com/?p=717</guid>
		<description><![CDATA[For those web masters dealing with user feedback looking to weight content finding the right algorithm can be challenging. From experience, there is going to be no out of the box solution since each site and the requirements will be unique. Getting started and putting a solid foundation is the first step and of course, [...]]]></description>
			<content:encoded><![CDATA[<p>For those web masters dealing with user feedback looking to weight content finding the right algorithm can be challenging. From experience, there is going to be no out of the box solution since each site and the requirements will be unique.  Getting started and putting a solid foundation is the first step and of course, refining over time to get just the right recipe. The following is a binomial proportion confidence interval (what?).  It is a PHP implementation using the Wilson Score Interval to weight the feedback.</p>
<p><span id="more-717"></span></p>
<pre class="php"><span style="color: #000000; font-weight: bold;">class</span> Rating
<span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <a style="text-decoration: none;" href="http://www.php.net/static"><span style="color: #000066;">static</span></a> <span style="color: #000000; font-weight: bold;">function</span> ratingAverage<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$positive</span>, <span style="color: #0000ff;">$total</span>, <span style="color: #0000ff;">$power</span> = <span style="color: #ff0000;">'0.05'</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$total</span> == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0</span>;
&nbsp;
    <span style="color: #0000ff;">$z</span> = Rating::<span style="color: #006600;">pnormaldist</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>-<span style="color: #0000ff;">$power</span>/<span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #0000ff;">$p</span> = <span style="color: #cc66cc;">1.0</span> * <span style="color: #0000ff;">$positive</span> / <span style="color: #0000ff;">$total</span>;
    <span style="color: #0000ff;">$s</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$p</span> + <span style="color: #0000ff;">$z</span>*<span style="color: #0000ff;">$z</span>/<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>*<span style="color: #0000ff;">$total</span><span style="color: #66cc66;">&#41;</span> - <span style="color: #0000ff;">$z</span> * <a style="text-decoration: none;" href="http://www.php.net/sqrt"><span style="color: #000066;">sqrt</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$p</span>*<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>-<span style="color: #0000ff;">$p</span><span style="color: #66cc66;">&#41;</span>+<span style="color: #0000ff;">$z</span>*<span style="color: #0000ff;">$z</span>/<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">4</span>*<span style="color: #0000ff;">$total</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>/<span style="color: #0000ff;">$total</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>/<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>+<span style="color: #0000ff;">$z</span>*<span style="color: #0000ff;">$z</span>/<span style="color: #0000ff;">$total</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$s</span>;
  <span style="color: #66cc66;">&#125;</span> 
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <a style="text-decoration: none;" href="http://www.php.net/static"><span style="color: #000066;">static</span></a> <span style="color: #000000; font-weight: bold;">function</span> pnormaldist<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$qn</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#123;</span>
    <span style="color: #0000ff;">$b</span> = <a style="text-decoration: none;" href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
      <span style="color: #cc66cc;">1.570796288</span>, <span style="color: #cc66cc;">0.03706987906</span>, <span style="color: #cc66cc;">-0</span>.8364353589e<span style="color: #cc66cc;">-3</span>,
      <span style="color: #cc66cc;">-0</span>.2250947176e<span style="color: #cc66cc;">-3</span>, <span style="color: #cc66cc;">0</span>.6841218299e<span style="color: #cc66cc;">-5</span>, <span style="color: #cc66cc;">0</span>.5824238515e<span style="color: #cc66cc;">-5</span>,
      <span style="color: #cc66cc;">-0</span>.104527497e<span style="color: #cc66cc;">-5</span>, <span style="color: #cc66cc;">0</span>.8360937017e<span style="color: #cc66cc;">-7</span>, <span style="color: #cc66cc;">-0</span>.3231081277e<span style="color: #cc66cc;">-8</span>,
      <span style="color: #cc66cc;">0</span>.3657763036e<span style="color: #cc66cc;">-10</span>, <span style="color: #cc66cc;">0</span>.6936233982e<span style="color: #cc66cc;">-12</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$qn</span> &lt; <span style="color: #cc66cc;">0.0</span> || <span style="color: #cc66cc;">1.0</span> &lt; <span style="color: #0000ff;">$qn</span><span style="color: #66cc66;">&#41;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0.0</span>;
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$qn</span> == <span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#41;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0.0</span>;
&nbsp;
    <span style="color: #0000ff;">$w1</span> = <span style="color: #0000ff;">$qn</span>;
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$qn</span> &gt; <span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#41;</span>
      <span style="color: #0000ff;">$w1</span> = <span style="color: #cc66cc;">1.0</span> - <span style="color: #0000ff;">$w1</span>;
&nbsp;
    <span style="color: #0000ff;">$w3</span> = - <a style="text-decoration: none;" href="http://www.php.net/log"><span style="color: #000066;">log</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">4.0</span> * <span style="color: #0000ff;">$w1</span> * <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1.0</span> - <span style="color: #0000ff;">$w1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #0000ff;">$w1</span> = <span style="color: #0000ff;">$b</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$i</span> = <span style="color: #cc66cc;">1</span>;<span style="color: #0000ff;">$i</span> &lt;= <span style="color: #cc66cc;">10</span>; <span style="color: #0000ff;">$i</span>++<span style="color: #66cc66;">&#41;</span>
      <span style="color: #0000ff;">$w1</span> += <span style="color: #0000ff;">$b</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$i</span><span style="color: #66cc66;">&#93;</span> * <a style="text-decoration: none;" href="http://www.php.net/pow"><span style="color: #000066;">pow</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$w3</span>,<span style="color: #0000ff;">$i</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$qn</span> &gt; <span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#41;</span>
      <span style="color: #b1b100;">return</span> <a style="text-decoration: none;" href="http://www.php.net/sqrt"><span style="color: #000066;">sqrt</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$w1</span> * <span style="color: #0000ff;">$w3</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #b1b100;">return</span> - <a style="text-decoration: none;" href="http://www.php.net/sqrt"><span style="color: #000066;">sqrt</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$w1</span> * <span style="color: #0000ff;">$w3</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>The function takes 3 parameters: the positive votes, total votes, and the power. The power can be adjusted, 0.10 to have a 95% chance that your lower bound is correct, 0.05 to have a 97.5% chance, etc.  Sample usage:</p>
<pre class="php">sample<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
sample<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span>,<span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span>;
sample<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span>,<span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;
sample<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1000</span>,<span style="color: #cc66cc;">500</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> sample<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$p</span>,<span style="color: #0000ff;">$n</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
  <a style="text-decoration: none;" href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> Rating::<span style="color: #006600;">ratingAverage</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$p</span>,<span style="color: #0000ff;">$p</span>+<span style="color: #0000ff;">$n</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>Output:</p>
<table border="0" cellpadding="2" cellspacing="0" border="1">
<tbody>
<tr>
<td>Positive</td>
<td>Negative</td>
<td>Score</td>
</tr>
<tr>
<td>1</td>
<td>0</td>
<td>0.20654931654388</td>
</tr>
<tr>
<td>100</td>
<td>50</td>
<td>0.58789756740385</td>
</tr>
<tr>
<td>250</td>
<td>100</td>
<td>0.6648317184611</td>
</tr>
<tr>
<td>1000</td>
<td>500</td>
<td>0.6424116916199</td>
</tr>
</tbody>
</table>
<p>When dealing with sites like Reddit, Digg, and the like  you have a certain "freshness" element.  The above solution might be a working model for the entire span of the site, but for that front page element you will need to implement some form of "gravity".  This can be done by taking the raw score and decaying it over time, like so:</p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Rating
<span style="color: #66cc66;">&#123;</span>
  ...
  <span style="color: #000000; font-weight: bold;">public</span> <a style="text-decoration: none;" href="http://www.php.net/static"><span style="color: #000066;">static</span></a> <span style="color: #000000; font-weight: bold;">function</span> gravityRating<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$positive</span>, <span style="color: #0000ff;">$total</span>, <span style="color: #0000ff;">$time</span>, <span style="color: #0000ff;">$power</span> = <span style="color: #ff0000;">'0.05'</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$total</span> == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0</span>;
    <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span>Rating::<span style="color: #006600;">ratingAverage</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$positive</span>, <span style="color: #0000ff;">$total</span>, <span style="color: #0000ff;">$power</span><span style="color: #66cc66;">&#41;</span> / <a style="text-decoration: none;" href="http://www.php.net/pow"><span style="color: #000066;">pow</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$time</span>,<span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
  ...
<span style="color: #66cc66;">&#125;</span>
&nbsp;
sample<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span>,<span style="color: #cc66cc;">50</span>,<span style="color: #ff0000;">'0.5'</span><span style="color: #66cc66;">&#41;</span>;
sample<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span>,<span style="color: #cc66cc;">50</span>,<span style="color: #ff0000;">'1'</span><span style="color: #66cc66;">&#41;</span>;
sample<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span>,<span style="color: #cc66cc;">50</span>,<span style="color: #ff0000;">'4'</span><span style="color: #66cc66;">&#41;</span>;
sample<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span>,<span style="color: #cc66cc;">50</span>,<span style="color: #ff0000;">'8'</span><span style="color: #66cc66;">&#41;</span>;
sample<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span>,<span style="color: #cc66cc;">50</span>,<span style="color: #ff0000;">'24'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> sample<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$p</span>,<span style="color: #0000ff;">$n</span>,<span style="color: #0000ff;">$time</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
  <a style="text-decoration: none;" href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> Rating::<span style="color: #006600;">gravityRating</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$p</span>,<span style="color: #0000ff;">$p</span>+<span style="color: #0000ff;">$n</span>,<span style="color: #0000ff;">$time</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>In the example above, $time represents the age (in hours) and you can see the decay in the output:</p>
<p>0.83141271310867<br />
0.58789756740385<br />
0.29394878370192<br />
0.20785317827717<br />
0.12000408843024</p>
<p>My recommendation would be to "cap" the time to stop decay after a fixed period such as 12 or 24 hours to stop the initial boost of fresh content and let it normalize quickly.  The rate of decay of course, can be adjusted as fast or as slow as you want and again the individual weighting you want to apply will vary from site to site.  Depending on the volatility of your content, a front page "freshness" that will encompass a week would not merit a 12 hour decay, but rather a week long decay.   Hopefully the above code is enough to get started with content rating and making better use of user feedback and can help lead web masters to making a more intelligent calculation of their content beyond the traditional "5-Star Rating".</p>
<p>[ c9maji2tvz ]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.derivante.com/2009/09/01/php-content-rating-confidence/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>PHP Google Analytics API</title>
		<link>http://www.derivante.com/2009/07/08/php-google-analytics-api/</link>
		<comments>http://www.derivante.com/2009/07/08/php-google-analytics-api/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 15:19:50 +0000</pubDate>
		<dc:creator>Clay vanSchalkwijk</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Technology]]></category>
		<category><![CDATA[Analytics]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://www.derivante.com/?p=707</guid>
		<description><![CDATA[GAPI 1.3 released this past month. First, read the Google Analytics Data API Reference and then read up on dimensions, metrics, and valid combinations of the two.  The quotas apply to a single web property, so each analytics profile (site1, site2, etc) are subject to their own individual quotas.   There is no per user account [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/p/gapi-google-analytics-php-interface/">GAPI 1.3</a> released this past month.  First, read the <a href="http://code.google.com/apis/analytics/docs/gdata/gdataReference.html">Google Analytics Data API Reference</a> and then read up on <a href="http://code.google.com/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.html">dimensions, metrics, and valid combinations</a> of the two.  The quotas apply to a single web property, so each analytics profile (site1, site2, etc) are subject to their own individual quotas.   There is no per user account limit for accessing the API.    If you plan on making any kind of on demand application I suggest you query in bulk and cache the results locally (analytics is not real time anyways).</p>
<p><span id="more-707"></span></p>
<p><strong>API Features</strong></p>
<ul>
<li>Supports CURL and fopen HTTP access methods, with autodetection </li>
<li>PHP arrays for Google Analytics metrics and dimensions </li>
<li>Account data object mapping - get methods for parameters </li>
<li>Report data object mapping - get methods for metrics and parameters </li>
<li>Easy filtering, use a GAPI query language for Google Analytics filters </li>
<li>Full PHP5 Object Oriented code, ready for use in your PHP application </li>
</ul>
<p><br></p>
<p><strong>Google Quotas</strong></p>
<ul>
<li>The quota applies to a <em>single web property</em></li>
<li>10,000 requests per 24 hours</li>
<li>100 requests in any given 10-second period</li>
<li>A query is also limited to pagination limits of 10,000 entries per feed,   with a default response of 1,000 entries</li>
</ul>
<p><br></p>
<p>While the broad set of data they have is extremely useful to pull down to do your own processing on, I find the custom visitor segments with the API a lot more interesting.    If you have a user based site with registration and collect information on your users, you can pull this data back out to determine a lot of information about your user.   A lot of tools are already built into Analytics for reporting but the ability to mash this data up to provide custom reporting for your users (customers) without giving them access to analytics is key to delivering metrics and performance</p>
]]></content:encoded>
			<wfw:commentRss>http://www.derivante.com/2009/07/08/php-google-analytics-api/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SOLR Filtering Performance Increase</title>
		<link>http://www.derivante.com/2009/06/23/solr-filtering-performance-increase/</link>
		<comments>http://www.derivante.com/2009/06/23/solr-filtering-performance-increase/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 15:55:44 +0000</pubDate>
		<dc:creator>Justin Leider</dc:creator>
				<category><![CDATA[SOLR]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://www.derivante.com/?p=689</guid>
		<description><![CDATA[A couple months ago I wrote about the terrible performance and a work around for SOLR / Lucene search engine. I discovered that performance would drop off a cliff while using filter queries to narrow search results for search queries on common terms in large indexes.  Although, it looks like the issue has been addressed [...]]]></description>
			<content:encoded><![CDATA[<p>A couple months ago I wrote about the <a title="100x Increase in SOLR Performance and Throughput" href="http://www.derivante.com/2009/04/27/100x-increase-in-solr-performance-and-throughput/">terrible performance and a work around</a> for SOLR / Lucene search engine. I discovered that performance would drop off a cliff while using filter queries to narrow search results for search queries on common terms in large indexes.  Although, it looks like the issue has been addressed in some of the latest nightly <a title="SOLR Search Engine" href="http://lucene.apache.org/solr/" target="_blank">SOLR</a> builds and is scheduled for official release with SOLR v1.4. Previous to this new version the filter queries were applied after the main query ran. This is all well and good but it doesn't help speed your query up like you think it should. The new version <a href="http://www.lucidimagination.com/blog/2009/05/27/filtered-query-performance-increases-for-solr-14/" target="_blank">applies the filters in parallel</a> to the main query significantly speeding up searches with common queries and query filters by 30% to 80% along with a 40% smaller memory footprint.</p>
<p>However, even with this speed improvement you still should consider how you structure your queries. There is no need to do a query across every field if you know you really want to filter everything down with a single filter query. Try moving that filter query (fq) into the actual query (q) as <field>:<filter>. You might be <a title="100x Increase in SOLR Performance and Throughput" href="http://www.derivante.com/2009/04/27/100x-increase-in-solr-performance-and-throughput/">surprised by the results</a>...</p>
]]></content:encoded>
			<wfw:commentRss>http://www.derivante.com/2009/06/23/solr-filtering-performance-increase/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SOLR Performance Benchmarks – Single vs. Multi-core Index Shards</title>
		<link>http://www.derivante.com/2009/05/05/solr-performance-benchmarks-single-vs-multi-core-index-shards/</link>
		<comments>http://www.derivante.com/2009/05/05/solr-performance-benchmarks-single-vs-multi-core-index-shards/#comments</comments>
		<pubDate>Tue, 05 May 2009 22:23:13 +0000</pubDate>
		<dc:creator>Justin Leider</dc:creator>
				<category><![CDATA[SOLR]]></category>
		<category><![CDATA[Web Technology]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[Search]]></category>
		<category><![CDATA[Shards]]></category>
		<category><![CDATA[Throughput]]></category>

		<guid isPermaLink="false">http://www.derivante.com/?p=350</guid>
		<description><![CDATA[Single vs. multi-core sharded index. Which one is the right one? There is not a whole lot of information out there, especially when it comes to hard numbers and comparisons. There are a couple reasons for this. The first one that comes to mind is the multi-core functionality offered by Apache SOLR is very nascent. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-415" title="solr_fc" src="http://www.derivante.com/wp-content/uploads/2009/05/solr_fc.jpg" alt="solr_fc" width="170" height="94" />Single vs. <a title="SOLR multi-core indexing" href="http://wiki.apache.org/solr/CoreAdmin" target="_blank">multi-core sharded index</a>. Which one is the right one? There is not a whole lot of information out there, especially when it comes to hard numbers and comparisons. There are a couple reasons for this. The first one that comes to mind is the multi-core functionality offered by <a title="SOLR Search Engine" href="http://lucene.apache.org/solr/" target="_blank">Apache SOLR</a> is very nascent. It was recently introduced with the latest SOLR v1.3 and hasn't had much time to be adopted by the SOLR community. Second, the results are dependent on your schema, index size, query types and user load. These factors can account for varying performance results. As evidenced by the following benchmarks, a multi-core SOLR index has the potential to speed up the performance of your application or cut throughput and scalability by approximately the inverse number of cores.</p>
<p style="margin-bottom: 0in; padding-left: 30px;">i.e. For n cores the maximum throughput is roughly 1/n vs. a single index.</p>
<p style="margin-bottom: 0in;">With multi-core sharded indexes the underlying assumption is that search performance improves by splitting your index into smaller chunks. These smaller shards are then faster and more efficient to search and index. However, you never get anything for free, the performance increase comes at a cost of higher CPU utilization. By breaking the index into multiple smaller pieces it makes searching and indexing on that smaller subset of the index faster, but you'll need to search each core individually for every query. Where as a single index runs one slightly slower query, a multi-core sharded query runs n queries in parallel and then combines the results.</p>
<p><span id="more-350"></span></p>
<p style="margin-bottom: 0in;">There is one problem which still needs to be worked out with the multi-core sharded index. There is no distributed IDF (inverse document frequency). This is to say, if your documents are not spread evenly across all shards then you risk a result set that is improperly ordered based on your sorts, query boosts, etc. This happens with a distributed multi-core index because the scoring of the documents takes place within each individual  core before the results are combined and the query returned.</p>
<p style="margin-bottom: 0in;">Ideally, a multi-core index is great if you need to increase the performance of your queries and can afford to sacrifice some scalability and throughput to see it through.</p>
<p style="margin-bottom: 0in;">
<p style="margin-bottom: 0in;">Below are some charts of benchmarks that I have compiled on the CitySquares SOLR index. The specifications of the machine and indexes are as follows:</p>
<p style="margin-bottom: 0in;">
<p style="margin-bottom: 0in;"><strong>Testing machine - Dell r900:</strong></p>
<ul>
<li>4x Quad Core Intel(R) Xeon(R) CPU 		E7340 @ 2.40GHz (16 physical cores)</li>
<li>24GB RAM</li>
<li>3x 15k RPM drives in RAID 0</li>
<li>Gig-Ethernet on a local LAN</li>
</ul>
<p style="margin-bottom: 0in;"><strong>Index Stats:</strong></p>
<ul>
<li>14.5 Million Documents</li>
<li>13 GB total size</li>
<li> 56 fields (indexed and/or stored 	w/ various amounts of processing)</li>
<li>Fully optimized index</li>
</ul>
<p style="margin-bottom: 0in;"><strong>Benchmarks:</strong></p>
<ul>
<li>Used Apache Bench for testing purposes from another machine on the same LAN over Gig-E.</li>
</ul>
<pre class="bash">&nbsp;
<span style="color: #808080; font-style: italic;">#!/bin/bash</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span> &gt; solr_results.log
<span style="color: #000000; font-weight: bold;">for</span> C <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000;">2</span> <span style="color: #000000;">4</span> <span style="color: #000000;">8</span> <span style="color: #000000;">16</span> <span style="color: #000000;">32</span> <span style="color: #000000;">64</span> <span style="color: #000000;">128</span> <span style="color: #000000;">256</span> <span style="color: #000000;">512</span>
<span style="color: #000000; font-weight: bold;">do</span>
<span style="color: #007800;">N=</span>$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$C</span>*<span style="color: #000000;">1000</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ab -n$N -c$C&quot;</span> &gt;&gt; solr_results.log
ab -n<span style="color: #007800;">$N</span> -c<span style="color: #007800;">$C</span> <span style="color: #ff0000;">'http://solr:8080/solr/select?q=&lt;ID&gt;&amp;qf=&lt;FIELD&gt;&amp;fq=&lt;FIELD&gt;:&lt;ID&gt;&amp;start=0&amp;rows=20'</span> &gt;&gt; solr_results.log
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;</pre>
<p style="margin-bottom: 0in;">
<p style="margin-bottom: 0in;"><strong>For the trends in red the lower the number the better.<br />
For the trends in blue the higher the number the better.</strong></p>
<p style="margin-bottom: 0in;">
<div class="mceTemp">
<dl id="attachment_356" class="wp-caption alignnone" style="width: 510px;">
<dt class="wp-caption-dt">Single index with no caching enabled <img class="size-full wp-image-356" title="single-index-no-cache" src="http://www.derivante.com/wp-content/uploads/2009/04/single-index-no-cache.jpg" alt="Single index with no caching enabled" width="500" height="400" /></dt>
</dl>
</div>
<div class="mceTemp">
<dl id="attachment_355" class="wp-caption alignnone" style="width: 510px;">
<dt class="wp-caption-dt">Single index with filterCache enabled<img class="size-full wp-image-355" title="single-index-cache" src="http://www.derivante.com/wp-content/uploads/2009/04/single-index-cache.jpg" alt="Single index with filterCache enabled" width="500" height="400" /></dt>
</dl>
</div>
<p>We can see here in the above graph that there were no results from the 512 concurrency test. This is because there was a deadlock in the Apache Tomcat server. The max number of connections was set to 512 with an overflow of 100.  This is the cause of all the cases where there are no results for the 512 test case. Ironically the Single core without the cache managed to finish but the test with fieldCache on failed.</p>
<div class="mceTemp">
<dl id="attachment_353" class="wp-caption alignnone" style="width: 510px;">
<dt class="wp-caption-dt">Multicore Index (2 Cores) with no caching enabled<img class="size-full wp-image-353" title="multicore-no-cache" src="http://www.derivante.com/wp-content/uploads/2009/04/multicore-no-cache.jpg" alt="Multicore Index (2 Cores) with no caching enabled" width="500" height="400" /></dt>
</dl>
</div>
<div class="mceTemp">
<dl id="attachment_352" class="wp-caption alignnone" style="width: 510px;">
<dt class="wp-caption-dt">Multicore Index (2 Cores) with filterCaching enabled<img class="size-full wp-image-352" title="multicore-cache" src="http://www.derivante.com/wp-content/uploads/2009/04/multicore-cache.jpg" alt="Multicore Index (2 Cores) with filterCaching enabled" width="500" height="400" /></dt>
</dl>
</div>
<p><strong>The higher the better in the following chart.</strong></p>
<div class="mceTemp">
<dl id="attachment_354" class="wp-caption alignnone" style="width: 510px;">
<dt class="wp-caption-dt">Requests per second across all benchmarks<img class="size-full wp-image-354" title="requests-per-second" src="http://www.derivante.com/wp-content/uploads/2009/04/requests-per-second.jpg" alt="Requests per second across all benchmarks" width="500" height="400" /></dt>
</dl>
</div>
<p><strong>The lower the better in the following charts.</strong></p>
<div class="mceTemp">
<dl id="attachment_357" class="wp-caption alignnone" style="width: 510px;">
<dt class="wp-caption-dt">Time per request across all benchmarks<img class="size-full wp-image-357" title="time-per-request" src="http://www.derivante.com/wp-content/uploads/2009/04/time-per-request.jpg" alt="Time per request across all benchmarks" width="500" height="400" /></dt>
</dl>
</div>
<p>The above graph shows the only test to finish successfully with 512 concurrent connections was the single index with caching disabled.</p>
<div class="mceTemp">
<dl id="attachment_362" class="wp-caption alignnone" style="width: 510px;">
<dt class="wp-caption-dt">Time per request across all benchmarks (truncated view)<img class="size-full wp-image-362" title="time-per-request-zoom" src="http://www.derivante.com/wp-content/uploads/2009/04/time-per-request-zoom.jpg" alt="Time per request across all benchmarks (truncated view)" width="500" height="400" /></dt>
</dl>
</div>
<p>This graph is the same as the one before without the last two concurrency levels so you can see whats going on at the beginning of the benchmark. Its still hard to see but the multi-core sharded indexes are a bit lower that the single indexes. Its clear however at the higher concurrencies that the single indexes beat the multi-core ones hands down.</p>
<p>Ive attached a <a title="SOLR Benchmarks" href="http://www.derivante.com/wp-content/uploads/2009/04/solr-blog-benchmarks.xls" target="_blank">spreadsheet</a> with actual numbers from the benchmarks since some of the charts are hard to read.</p>
<p>So there it is, take it as you will. There are definitely benefits to moving from a single index to a distributed multi-core sharded index. However, whether it works for your dataset and application is up in the air. After these benchmarks we decided that the multi-core index that had served us well on <a title="Limitations of scaling with EC2" href="http://www.derivante.com/2008/10/08/the-limitations-of-scaling-with-ec2/" target="_blank">Amazon's EC2</a> no longer worked well for us on our new managed hosting. We are currently running a single index at <a title="CitySquares Online -- Hyper Local Neighborhood Search" href="http://citysquares.com" target="_blank">CitySquares</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.derivante.com/2009/05/05/solr-performance-benchmarks-single-vs-multi-core-index-shards/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>100x Increase in SOLR Performance and Throughput</title>
		<link>http://www.derivante.com/2009/04/27/100x-increase-in-solr-performance-and-throughput/</link>
		<comments>http://www.derivante.com/2009/04/27/100x-increase-in-solr-performance-and-throughput/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 20:28:27 +0000</pubDate>
		<dc:creator>Justin Leider</dc:creator>
				<category><![CDATA[SOLR]]></category>
		<category><![CDATA[Web Architecture]]></category>
		<category><![CDATA[Web Technology]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[scalability]]></category>

		<guid isPermaLink="false">http://www.derivante.com/?p=341</guid>
		<description><![CDATA[Is your SOLR installation running slower than you think it should? Performance, throughput and scalability not what you are expecting or hoping? Do you constantly see that others have much higher SOLR query performance and scalability than you do? All it might take to fix your woes is a simple schema or query change. The [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" style="margin: 5px;" title="SOLR" src="http://www.derivante.com/wp-content/uploads/2009/05/solr_fc.jpg" alt="" width="170" height="94" />Is your SOLR installation running slower than you think it should? Performance, throughput and scalability not what you are expecting or hoping? Do you constantly see that others have much higher SOLR query performance and scalability than you do? All it might take to fix your woes is a simple schema or query change.</p>
<p>The following scenario I am about to describe is proof positive that you should always take the time to understand the underlying functionality of whatever operating system, programming language or application you are using. Let my oversight and 'quick fix solution' be a lesson to you, it is almost always worth the upfront cost of doing something right the first time so you don't have to keep revisiting the same issue.<br><br />
<span id="more-341"></span><br />
Before I delve into the nuances of SOLR let me first give you some background on what took place over the last half year at CitySquares. Back in the fall of last year the CitySquares website began experiencing an exponential growth in traffic. This growth was due to an expansion of its IYP (Internet Yellow Page) services into the New England and Metro New York areas. Prior to and during the beginning of the first wave of traffic growth, every business listing was powered by very large MySQL queries including a couple joins. The queries themselves weren't all that complex but they were big and unwieldy with joins on very large tables and lots of columns in the result sets. In some of the larger cities covered at the time (Manhattan, Bronx, Queens, Boston, etc) there were up to 100,000 rows of data that needed to be sorted before returning a rather small subset (20-40 rows) for each business listing page load. While this wasn't a big deal when CitySquares was still a niche Boston centric destination, it quickly became a huge burden on the MySQL servers. Some of these queries were so big the servers would run out of memory trying to crunch through a 3GB temp table and start thrashing the disks to server a request for Manhattan. We needed a better solution and quick.</p>
<p>Luckily for us we had already implemented a SOLR search engine with all the necessary data indexed from our database initially with the sole intent that search result sets shouldn't have to query the database. This worked to our advantage since it was very easy for us to modify the code base to query SOLR instead of MySQL. Both result sets were formatted as an object with the same field names and all. It was a perfect drop in replacement.</p>
<p>The SOLR solution we implemented utilized SOLR's wild card q.alt=*:* field to select all documents while applying filter query (fq) on that set to get all documents related to our filter. It was a huge win for us at the time. Not only were the queries faster than the MySQL ones, but the SOLR servers could handle more of these queries without even coming close to exhausting the server's resources. This quick and dirty solution was satisfactory for the next few months until CitySquares' next round of expansion began, where again, the queries became a burden. The second time around we didn't have another seemingly quick fix. I spent a couple days trying to figure out a better way to implement the q.alt=*:* field but to no avail I gave up and moved onto other performance optimizations.</p>
<p>Unfortunately, I didn't take the time to understand the code behind the query and I didn't understand exactly how SOLR was implementing the query in its back end process. Since I didn't understand the basis of the problem I couldn't possibly know the query could be easily re-factored. After a few weeks of high loads, 20+ on our 8 core servers, I struck up a conversation with Michael, the developer who wrote the query. We discussed how the query worked and what it needed to do and after five minutes we had discovered a much better way to structure the query. It took me only about a minute or two to re-factor the original query to produce the exact same result set. This new query was incredibly fast! I benchmarked it to be about 100x faster than the previous query and on top of that it was a simple drop in replacement!</p>
<p>From what I've deduced the original query passed a blank query string with a filter query to SOLR which in turn defaulted to the q.alt catch all first and then applied the filter on the catch all query. This is exactly the opposite of what we were expecting SOLR to do. We believed that the filter was applied first and then the q.alt was applied. However, that was not the case. while this misunderstanding wasn't ideal it wasn't too slow either with only 1.4 million documents to parse over. However once CitySquares hit the 14.5 million mark this query became unmanageable. Basically SOLR parsed over every single document in the index before applying the query filter we were using. To rectify this and regain performance and through put on our servers I simply moved the filter query statement to the query statement and specified the query field to be the same as the original filter field.</p>
<p>i.e.</p>
<p>Original query passed a blank query string with a filter query:</p>
<ul>
<li>select?q=+&amp;fq=&lt;FIELD&gt;:&lt;ID&gt;</li>
</ul>
<p>The updated query now passes the id as the query string and specifies the former filter field:</p>
<ul>
<li>select?q=&lt;ID&gt;&amp;qf=&lt;FIELD&gt;</li>
</ul>
<p>Instead of taking advantages of SOLR's and every other search engines strength of O(1) search time we were at the mercy of its worst case scenario O(n) scan time. This simple misunderstanding of how SOLR processes queries in the back end caused massive performance and throughput bottlenecks. These bottlenecks affected our short and long term infrastructure plans, and was the root cause of many performance headaches for our users, customers and IT department.</p>
<p>If this isn't proof positive that you should always take the time to understand the underlying functionality of whatever operating system, programming language or application you are using I don't know what is.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.derivante.com/2009/04/27/100x-increase-in-solr-performance-and-throughput/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PHP/KML Polyline Simplification with Douglas-Peucker</title>
		<link>http://www.derivante.com/2009/04/20/phpkml-polyline-simplification-with-douglas-peucker/</link>
		<comments>http://www.derivante.com/2009/04/20/phpkml-polyline-simplification-with-douglas-peucker/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 02:41:16 +0000</pubDate>
		<dc:creator>Clay vanSchalkwijk</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Technology]]></category>

		<guid isPermaLink="false">http://www.derivante.com/?p=331</guid>
		<description><![CDATA[Quality GIS data sometimes comes with a lot more precision than what is usable for Google Maps (or other mapping software). The problem lies in the number of points representing a polygon that you want to overlay. A county representation for a state might include 100,000 points that is not usable without some form of [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-425" style="margin: 15px;" title="php-med-trans-light" src="http://www.derivante.com/wp-content/uploads/2009/05/php-med-trans-light.gif" alt="php-med-trans-light" width="95" height="51" />Quality GIS data sometimes comes with a lot more precision than what is usable for Google Maps (or other mapping software). The problem lies in the number of points representing a polygon that you want to overlay. A county representation for a state might include 100,000 points that is not usable without some form of reduction. Luckily there is an algorithm that solves that problem, Douglas-Peucker.</p>
<p>The algorithm simplifies a polyline by removing vertices that do not contribute (sufficiently) to the overall shape. It is a recursive process which finds the most important vertices for every given reduction. First, the most basic reduction is assumed. A single segment connecting the beginning and end of the original polyline. This is when the recursion starts, the most significant vertex (the most distant) for this segment is found and, when the distance from this vertex to the segment exceeds the reduction tolerance, the segment is split into two sub-segments, each inheriting a subset of the original vertex list. Each segment continues to subdivide until none of the vertices in the local list are further away than the tolerance value.</p>
<p>There is a PHP class that does just this: <a href="http://www.fonant.com/demos/douglas_peucker/algorithm">Douglas-Peucker Polyline Simplification in PHP</a> by <a href="http://www.fonant.com/">Anthony Cartmell</a>. Based on the original quality of the data and tolerance level, I was able to achieve a 90-93% reduction in size. This reduction allows me to represent significantly more data at a reasonable performance level to clients. Keep in mind, that this reduction is removing data out of the coordinate array so the quality of your representation will go down with the tolerance and reduction being applied. I highly suggest that you play around with the tolerance until you find a good balance between data size and image quality.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.derivante.com/2009/04/20/phpkml-polyline-simplification-with-douglas-peucker/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>There and Back Again, an EC2 MySQL Cluster</title>
		<link>http://www.derivante.com/2009/01/26/there-and-back-again-an-ec2-mysql-cluster/</link>
		<comments>http://www.derivante.com/2009/01/26/there-and-back-again-an-ec2-mysql-cluster/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 04:40:20 +0000</pubDate>
		<dc:creator>Clay vanSchalkwijk</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Web Architecture]]></category>
		<category><![CDATA[Web Technology]]></category>

		<guid isPermaLink="false">http://www.derivante.com/?p=223</guid>
		<description><![CDATA[Limitations of EC2 as a web platform: Price- An m1.xlarge instance will run you ~$600 with data transfer costs. Managed hosting solutions run cheaper especially if you plan on purchasing in bulk. The grid is designed for on-demand computation and not as a cost efficient web services. Configuration- There are a limited number of options [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Limitations of EC2 as a web platform:</strong></p>
<ul style="padding-left: 20px;">
<li> <strong>Price</strong>-  An m1.xlarge instance will run you ~$600 with data transfer costs. Managed hosting solutions run cheaper especially if you plan on purchasing in bulk. The grid is designed for on-demand computation and not as a cost efficient web services.</li>
<li><strong>Configuration</strong>- There are a limited number of options and you will not be able to tailor the hardware to your application. Databases over 10GB of size will have performance issues since that is the memory cap.</li>
<li><strong>Network storage</strong>- The primary disks offers limited storage, additional volumes will need to be attached across the network and at an additional cost.</li>
<li><strong>Software</strong> - No hardware based solutions for load balancing or custom application servers.  The model is software driven so all needs must be met with a software solution.  In a managed hosting or collocation  solution you will at least have the option of adding additional hardware and having a private network.  No dedicated switching, routers, firewall, or load balancers.</li>
</ul>
<p><br><br />
<strong>EC2 might be right for you if:</strong></p>
<ul style="padding-left: 20px;">
<li><strong>Distribution Awareness</strong>-  Your application was designed to scale horizontally from the get-go and you can take advantage of grid computing.</li>
<li><strong>Research and Development</strong>- EC2 &amp; Rightscale will allow for you to bring up new servers, test configuration, and scale quickly.  If you are not sure what your hardware demands will be or the scope of the project it will allow for some flexibility to get this right before committing to rather lengthy contracts with other hosting options.</li>
<li><strong>Disaster Recovery</strong>- If you need an off-site mirror for your site that you can keep dormant and activate as needed.</li>
</ul>
<p><br><br />
Over the past several months I have been doing extensive development using Amazon's EC2 as my hardware infrastructure.  I was tasked with taking CitySquares.com from a New England area hyper-local search and business directory to a national site in a few months.   Due to the memory limitations of EC2 instances, m1.xlarge only providing 15GB the jump from a 15GB database to anything larger becomes very costly.  When everything was able to be contained in two servers in a master/slave environment we were able to provide redundancy, performance, and easy management when working with the database. The final estimations of the national roll out would put our core data at 50GB.  Far too large for any one EC2 instance.  Going to disk was not an option as everything works off of EBS attached storage and that any disk writes means traveling over the network.  An additional overhead which degrades performance even more when switching off RAM.  Then, there was also the nature of the data, which means that at any page load, any piece of data could be requested.</p>
<p>With OS overhead, index storage, and ndb overhead, each x1.mlarge instance gave about 12GB of usable storage.  Include replication, and it comes down to 6GB of storage per node.  To store a ~50GB database that I had planned on requires 8 storage nodes, two management servers, and two mysqld api servers.  This is where it became important to understand the advantages of vertical scaling versus horizontal scaling.  EC2 provided fast horizontal scaling and configuration.  Servers can be launched on demand and their configurations scripted.   While I appreciated that aspect of cloud computing and being able to bring that many servers up and configure each one relatively quickly I really just needed two decent boxes with 64GB of RAM in each and a master/slave setup.  The operations costs for the cluster was $6000/month, a hefty bill considering I could buy all the hardware needed to run the cluster in just a few months of paying for EC2.</p>
<p>Twelve servers later and a working cluster we were able to successfully roll out our MySQL Cluster with minimal performance loss.   A lot of it was due to tweaking every query top to bottom.  The site runs on a Drupal core, which meant a lot of the queries were not designed with distribution awareness both from code in house and the core.  This was another added growing pain since the network overhead of running 12 servers on shared resources, with mediocre latency, and throughput limitations was amplifying flaws in the database design and every poorly designed query and join degraded performance significantly.</p>
<p>To give credit where credit is due, EC2 did allow us to scale the site up rather quickly.  We were able to test server configurations, new applications, and have easy management.  It would not have been possible for us to push out the data, handle influx of new traffic, and expand as fast as we had without it.  Long term however, it made absolutely no sense that once we were finished scaling up, to stay on EC2.  It is a great platform for start-ups to be able to configure and launch servers for their service or application and grow rapidly.</p>
<p>As a database platform, until EC2 offers more configuration options in it's hardware and the ability to increase memory, the cap of 15GB will make EC2 problematic for any database that plans on growing past that. It is important to understand your application and database needs before considering EC2.  It is no surprise to me that even with the RightScale interface, and easy management of EC2 web sites are reluctant to switch off their own hardware or managed hosting.</p>
<p>Both Sun and Continuent are pursuing MySQL Clustering on cloud computing.  As of this post, Continuent for EC2 was still in closed beta and testing and Sun is doing their own research into offering more support for database clusters on compute clouds.    Maybe in the future this can be something to revisit, but it would require more ndb configuration options on the network layer to cope with shared bandwidth and additional hardware configurations by Amazon (someday).</p>
<p>The 6.4 release which is in beta now offers new features which would make MySQL Clustering more attractive on cloud computing architecture:</p>
<ul>
<li><em>Ability to add nodes and node groups online.</em> This will allow the database to scale up without taking the cluster down.</li>
<li><em>Data node multithreading support. </em> The m1.xlarge instance comes with 4 cores.</li>
</ul>
<p>If you are setting up a MySQL cluster, the following resources will help get you up and running quickly:</p>
<ul>
<li><a href="http://www.severalnines.com/" target="_blank">http://www.severalnines.com/</a></li>
<li><a href="http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-configuration.html" target="_blank">http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-configuration.html</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.derivante.com/2009/01/26/there-and-back-again-an-ec2-mysql-cluster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Limitations of Scaling with EC2</title>
		<link>http://www.derivante.com/2008/10/08/the-limitations-of-scaling-with-ec2/</link>
		<comments>http://www.derivante.com/2008/10/08/the-limitations-of-scaling-with-ec2/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 20:56:48 +0000</pubDate>
		<dc:creator>Justin Leider</dc:creator>
				<category><![CDATA[Web Architecture]]></category>
		<category><![CDATA[Web Technology]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[AWS Limitations]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[EC2 Limitations]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[Scaling]]></category>
		<category><![CDATA[Scaling with EC2]]></category>
		<category><![CDATA[Web Architecure]]></category>

		<guid isPermaLink="false">http://justinleider.wordpress.com/?p=45</guid>
		<description><![CDATA[Just as with any platform you choose, EC2 has its own limitations as well. These limitations are often different and harder to overcome than what you might find while running your own hardware. Without the proper planning and development, these limitations can wind up being extremely detrimental to the well being and scalability of your [...]]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom:0;">Just as with any platform you choose, EC2 has its own limitations as well. These limitations are often different and harder to overcome than what you might find while running your own hardware. Without the proper planning and development, these limitations can wind up being extremely detrimental to the well being and scalability of your website or service.</p>
<p style="margin-bottom:0;">There are quite a few blogs, articles and reviews out there that mention all the positive aspects of EC2 and I have written a few of them myself. However, I think users need to be informed of the negative aspects of a particular platform as well as the positive. I will be brief with this post as my next will focus on designing an architecture around these limitations.</p>
<p style="margin-bottom:0;">The biggest limitations of Amazon's <a href="http://aws.amazon.com/ec2" target="_blank">EC2</a> at the moment as I have experienced, are the latencies between instances, latencies between instances and storage (local, and EBS), and a lack of powerful instances with more than 15GB of RAM and 4 virtual CPUs.</p>
<p style="margin-bottom:0;">All the latency issues can all be traced back to the same root cause, a shared LAN with thousands of non localized instances all competing for bandwidth. Normally, one would think a LAN would be quick... and they generally are, especially when the servers are sitting right next to each other with a single switch sitting in between them. However, Amazon's network is much more extensive than most local LANs and chances are your packets are hitting multiple switches and routers on their way from one instance to another. Every extra node added between instances is just another few milliseconds that get added to the packet's round trip time. You can think of Amazon's LAN as a really small Internet. The layout of Amazon's LAN is very similar to that of the Internet, there is no cohesiveness or localization of instances in relation to one another. So lots of data has to go from one end of the LAN to the other, just like on the Internet. This leads to data traveling much farther than it needs to and all the congestion problems that are found on the Internet can be found on Amazon's LAN.</p>
<p style="margin-bottom:0;">For computationally intensive tasks this really isn't too big a deal but for those who rely on speedy database calls every millisecond added per request really starts adding up if you have lots of requests per page. When the CitySquares site moved from our own local servers to EC2 we noticed a 4-10x increase in query times which we attribute mainly to the high latency of the LAN. Since our servers are no longer within feet of each other, we have to contend with longer distances between instances and congestion on the LAN.</p>
<p style="margin-bottom:0;">Another thing to take into consideration is the network latency for Amazon's EBS. For applications that move around a lot of data, EBS is probably a god send as it has a high bandwidth capability. However, in CitySquares' case, we wind up doing a lot of small file transfers to and from our NFS server as well as EBS volumes. So while there is a lot of bandwidth available to us, we can't really take advantage of it, especially since we have to contend with the latency and overhead of transferring many small files. Not only are small files an issue for us but we also run our MySQL database off of an EBS volume. Swapping to disk has always been a critical issue for databases but the added overhead of network traffic can wreak havoc on your database load much more than normal disk swapping. You can think of the difference in access times from disk to disk over a network as a book on a bookcase vs a book somewhere down the hall in storage room B. Clearly the second option would take far longer to find what you are looking for and that's what you have to work with if you want to have the piece of mind of persistent storage.</p>
<p style="margin-bottom:0;">The last and most important limitation for us at <a title="CitySquares Online -- Hyper Local Neighborhood Search" href="http://citysquares.com" target="_blank">CitySquares</a> was the lack of an all powerful machine. The largest instance Amazon has to offer is one with just 15GB of ram and 4 virtual CPUs. In a day and age where you can easily find machines with 64GB of RAM and 16 CPUs, you are definitely limited by Amazon. In our case, it would be much easier for us just to throw hardware at our database to scale up but the only thing we have at our disposal is a paltry 15GB of RAM. How can this be the biggest machine they offer? Instead of dividing one of those machines in quarters just give me the whole thing. It just seems ludicrous to me that the largest machine they offer is something not much more powerful than the computer I'm using right now.</p>
<p style="margin-bottom:0;">Long story short, just because you start using Amazon's AWS doesn't mean you can scale. Make sure your architecture is tolerant of higher latencies and can scale with lots of little machines because that's all you have to work with.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">
]]></content:encoded>
			<wfw:commentRss>http://www.derivante.com/2008/10/08/the-limitations-of-scaling-with-ec2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Running your own hardware Vs EC2 and RightScale &#8212; Part 2</title>
		<link>http://www.derivante.com/2008/09/16/running-your-own-hardware-vs-ec2-and-rightscale-part-2/</link>
		<comments>http://www.derivante.com/2008/09/16/running-your-own-hardware-vs-ec2-and-rightscale-part-2/#comments</comments>
		<pubDate>Tue, 16 Sep 2008 14:33:24 +0000</pubDate>
		<dc:creator>Justin Leider</dc:creator>
				<category><![CDATA[Web Architecture]]></category>
		<category><![CDATA[Web Technology]]></category>
		<category><![CDATA[Amazon EBS]]></category>
		<category><![CDATA[Amazon EC2]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Elastic Block Storage]]></category>
		<category><![CDATA[Elastic Compute Cloud]]></category>
		<category><![CDATA[File Handling]]></category>
		<category><![CDATA[NFS]]></category>
		<category><![CDATA[Own Hardware]]></category>
		<category><![CDATA[rightscale]]></category>
		<category><![CDATA[Single Point of Failure]]></category>
		<category><![CDATA[Site Architecture]]></category>
		<category><![CDATA[Site Infrastructure]]></category>
		<category><![CDATA[Yahoo Best Practices]]></category>

		<guid isPermaLink="false">http://justinleider.com/?p=40</guid>
		<description><![CDATA[This week I've been reminded of a very important lesson... No matter how abstracted you are from your hardware, you still inherently rely on its smooth and consistent operation. This past week CitySquares' NFS server went down for the count and was completely unresponsive to any type of communication. In fact, the EC2 instance was [...]]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom:0;">This week I've been reminded of a very important lesson... No matter how <a title="Running your site on EC2 with RightScale vs running your own hardware." href="http://justinleider.com/2008/08/20/running-your-own-hardware-vs-ec2-and-rightscale/" target="_blank">abstracted</a> you are from your hardware, you still inherently rely on its smooth and consistent operation.</p>
<p style="margin-bottom:0;">This past week <a title="CitySquares Online -- Hyper Local Neighborhood Search" href="http://citysquares.com" target="_blank">CitySquares</a>' NFS server went down for the count and was completely unresponsive to any type of communication. In fact, the EC2 instance was so FUBAR we couldn't even terminate it from our RightScale dashboard. A post on Amazon's EC2 board was required to terminate it. Turns out the actual hardware our instance was running on had a catastrophic failure of some sort. Otherwise, at least so I'm told, server images are usually migrated off of machines running in a degraded state automatically.</p>
<p style="margin-bottom:0;">Needless to say, the very reasons for deciding against running our own hardware have come back to plague us. Granted we weren't responsible for replacing the hardware but we were still affected by the troublesome machine. We weren't just slightly affected by the loss of our NFS server either. Since we are running off of a heavily modified <a title="Drupal CMS" href="http://drupal.org" target="_blank">Drupal CMS</a> our web servers depend on having a writable files directory. As it turned out Apache just spun waiting for a response from the file system, our web services ground to a halt waiting on a machine that was never going to respond... ever. Talk about a <a title="Reliability engineering" href="http://en.wikipedia.org/wiki/Single_point_of_failure" target="_blank">single point of failure</a>! A non critical component, serving mainly images and photos managed to take down our entire production deployment.</p>
<p style="margin-bottom:0;">This event has prompted us to move forward with a rewrite of Drupal's core file handling functionality. The rewrite will include automatically directing file uploads to a separate domain name like csimg.com or something similar. Yahoo goes into more detail with their <a title="Yahoo Developer's best practices for website performance." href="http://developer.yahoo.com/performance/rules.html" target="_blank">performance best practices</a>. However, editing the Drupal core is generally frowned upon and heavily discouraged since it usually conflicts with the upgrade path and maintainability of the Drupal core becomes much more difficult. While we haven't stayed out of the Drupal core entirely, the changes we have made are minor and only for performance improvements. I believe it is possible to stay out of the core file handling by hooking into it with the nodeapi but it seems like more trouble than its worth.</p>
<p style="margin-bottom:0;">The idea behind the file handling rewrite is to serve our images and photos directly from our Co-Location while keeping a local files directory on each EC2 instance for non user committed things like CSS and JS aggregation caching among other simple cache related items coming from the Drupal core. This rewrite will allow us to run one less EC2 instance, saving us some money as well as remove our dependence on a catastrophic single point of failure.</p>
<p style="margin-bottom:0;">For the time being we have set up another NFS server. This time based on Amazon's new EBS product. I spoke about this in a <a title="Amazon releases the much anticipated Elastic Block Store" href="http://justinleider.com/2008/08/21/amazons-ebs-elastic-block-store/" target="_blank">previous post</a>. One of the issues we had when the last NFS server went down was the loss of user generated content. Once the instance went down all the storage associated with that instance went down with it. There was no way to recover from the loss, it was just gone. This is just one of the many possible problems you can run into with the cloud. While on the pro side, you don't have to worry about owning your own hardware, the con side is you cant recover from failures like you can with your own hardware. This is a very distinct difference and should be seriously considered before dumping your current architecture for the cloud.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">
]]></content:encoded>
			<wfw:commentRss>http://www.derivante.com/2008/09/16/running-your-own-hardware-vs-ec2-and-rightscale-part-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Nuances of EC2 and RightScale</title>
		<link>http://www.derivante.com/2008/09/05/nuances-of-ec2-and-rightscale/</link>
		<comments>http://www.derivante.com/2008/09/05/nuances-of-ec2-and-rightscale/#comments</comments>
		<pubDate>Fri, 05 Sep 2008 15:25:07 +0000</pubDate>
		<dc:creator>Justin Leider</dc:creator>
				<category><![CDATA[Web Technology]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[citysquares]]></category>
		<category><![CDATA[Development Environment]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rightscale]]></category>
		<category><![CDATA[s3]]></category>
		<category><![CDATA[Server Infrastructure]]></category>

		<guid isPermaLink="false">http://justinleider.wordpress.com/?p=36</guid>
		<description><![CDATA[So here it is, about two weeks have passed since CitySquares officially migrated its server infrastructure over to EC2 and RightScale. All in all, everything went relatively well. There were a few hiccups on the cut over day that left users with some error pages. Most of these issues were related to the DNS changeover [...]]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom:0;">So here it is, about two weeks have passed since CitySquares officially migrated its server infrastructure over to EC2 and RightScale. All in all, everything went relatively well. There were a few hiccups on the cut over day that left users with some error pages. Most of these issues were related to the DNS changeover and a little confusion over whether to set up the DNS records with Amazon's internal IPs or the elastic external IPs. Common sense said to set the DNS to the external IPs but turns out we were supposed to use the internal IPs (10.0.0.0/8 and not the elastic IPs 75.0.0.0/8) when referencing machines that are within the Amazon networks. Oops.</p>
<p style="margin-bottom:0;">Other than that, Ive spent the last couple weeks smoothing everything out  and getting things working at 100%. There were a few bugs that cropped up at first, mainly IT stuff, Apache configs, htaccess issues, HAProxy issues, making sure MySQL and our NFS server was backing up correctly. All these things took precedence but lately Ive been working on trying to increase performance. At this moment I'm not entirely sure why but, our MySQL database is running queries extremely slowly. At this point it could be anything from network latency, to slow machines, to an improperly tuned config. However, MySQL performance tuning is out of the scope of this post and will be the topic of a future entry. (If a MySQL DBA is reading this and would like the opportunity to play around with EC2 and RightScale, please get in touch with me.)</p>
<p style="margin-bottom:0;">In preparation for the tuning, not only for the MySQL server but the Apache servers as well, I have been setting up a separate development environment that is exactly identical to our production. With RightScale's clone feature I was able to easily duplicate everything from one deployment to the other. That said, let me make it clear that it will copy Everything. After changing all the necessary script inputs for the dev deployment I figured I was ready to start launching the new servers... WRONG. After booting the dev master DB server as well as our dev load balancer and dev NFS server I realized that they had stolen all the IPs from our production deployment! Bad News! Needless to say, CitySquares was down for the count for the few minutes it took me to figure out what had happened, fix the mistake and then wait for Amazon to reassign the elastic IPs. So here is a friendly reminder, check the server info tab before launching and make sure it isn't going to clobber your existing elastic IPs.</p>
<p style="margin-bottom:0;">Another somewhat annoying issue I ran into while trying to copy over our MySQL S3 backup from the production bucket to the development bucket was the lack of a decent copy function. RightScale has provided copy and move functionality on a somewhat basic level. You can move or copy files either one or many at a time. However, there is a limitation to this. Each file you copy will append its location into the URL and each directory path its somewhat long. Eventually you reach the maximum URL string limit and all the effort you put into selecting the files is for nothing. Not only do you have to select every file you want to copy, you have to manually assign it to the new location. This means lots of copy and pasting. If you have a directory that has hundreds of files in it, good luck. You are better off just uploading it to a new bucket. Either way, this could have been easily solved by having a copy bucket or directory option. Problem solved.</p>
<p style="margin-bottom:0;">While these few things are annoying, they aren't show stoppers, but they are definitely things to keep in mind when using these services. I'd like to end on a positive note so Ill mention the exceptional monitoring services that are installed and configured by default on every server image we have used so far. I am extremely impressed with the out of the box functionality of the graphs and they definitely make up for the other shortcomings. They have everything I could ever want to look at and then some. From standard CPU load to the number of I/Os p/s as well as yearly, quarterly, monthly, daily and hourly time frames in three sizes, small, medium and large. All browsable via up to date thumbnail previews.</p>
<p style="margin-bottom:0;">If you are considering cloud computing, I would recommend taking a look at RightScale and Amazon's web services.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">
]]></content:encoded>
			<wfw:commentRss>http://www.derivante.com/2008/09/05/nuances-of-ec2-and-rightscale/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Amazon&#8217;s EBS (Elastic Block Store)</title>
		<link>http://www.derivante.com/2008/08/21/amazons-ebs-elastic-block-store/</link>
		<comments>http://www.derivante.com/2008/08/21/amazons-ebs-elastic-block-store/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 14:48:55 +0000</pubDate>
		<dc:creator>Justin Leider</dc:creator>
				<category><![CDATA[Web Technology]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[EBS]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[Elastic Block Store]]></category>
		<category><![CDATA[Persistent Storage]]></category>
		<category><![CDATA[rightscale]]></category>

		<guid isPermaLink="false">http://justinleider.wordpress.com/?p=28</guid>
		<description><![CDATA[I wrote just yesterday about running your own hardware vs. using EC2 and RightScale and one of the major issues I found with EC2 was the lack of a persistent storage medium. Well, I knew the folks over at Amazon were hard at work on a new service that would allow persistent storage and turns [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote just yesterday about <a title="Roll your own hardware or side with cloud computing?" href="http://justinleider.com/2008/08/20/running-your-own-hardware-vs-ec2-and-rightscale/" target="_blank">running your own hardware vs. using EC2 and RightScale</a> and one of the major issues I found with EC2 was the lack of a persistent storage medium. Well, I knew the folks over at Amazon were hard at work on a new service that would allow persistent storage and turns out I received this email in my mailbox this morning:</p>
<blockquote><p>Dear AWS Developer,</p>
<p>We are pleased to announce the release of a significant new Amazon EC2 feature, Amazon Elastic Block Store (EBS), which provides persistent storage for your Amazon EC2 instances. With Amazon EBS, storage volumes can be programmatically created, attached to Amazon EC2 instances, and if even more durability is desired, can be backed with a snapshot to the Amazon Simple Storage Service (Amazon S3).</p>
<p>Prior to Amazon EBS, block storage within an Amazon EC2 instance was tied to the instance itself so that when the instance was terminated, the data within the instance was lost. Now with Amazon EBS, users can chose to allocate storage volumes that persist reliably and independently from Amazon EC2 instances. Amazon EBS volumes can be created in any size between 1 GB and 1 TB, and multiple volumes can be attached to a single instance. Additionally, for even more durable backups and an easy way to create new volumes, Amazon EBS provides the ability to create point-in-time, consistent snapshots of volumes that are then stored to Amazon S3.</p>
<p>Amazon EBS is well suited for databases, as well as many other applications that require running a file system or access to raw block-level storage. As Amazon EC2 instances are started and stopped, the information saved in your database or application is preserved in much the same way it is with traditional physical servers. Amazon EBS can be accessed through the latest Amazon EC2 APIs, and is now available in public beta.</p>
<p>We hope you enjoy this new feature and we look forward to your feedback.</p>
<p>Sincerely,</p>
<p>The Amazon EC2 team</p></blockquote>
<p>So this is indeed good news and removes the biggest con I mention about the EC2 platform!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.derivante.com/2008/08/21/amazons-ebs-elastic-block-store/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Running your own hardware Vs. EC2 and RightScale</title>
		<link>http://www.derivante.com/2008/08/20/running-your-own-hardware-vs-ec2-and-rightscale/</link>
		<comments>http://www.derivante.com/2008/08/20/running-your-own-hardware-vs-ec2-and-rightscale/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 20:13:52 +0000</pubDate>
		<dc:creator>Justin Leider</dc:creator>
				<category><![CDATA[Web Architecture]]></category>
		<category><![CDATA[Web Technology]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[citysquares]]></category>
		<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[Flexibility]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[IT Infrastructure]]></category>
		<category><![CDATA[rightscale]]></category>
		<category><![CDATA[s3]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Server Hardware]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Site Architecture]]></category>
		<category><![CDATA[Xen]]></category>

		<guid isPermaLink="false">http://justinleider.wordpress.com/?p=21</guid>
		<description><![CDATA[A couple weeks ago I began working with EC2 and RightScale in preparation of our big IT infrastructure change over. Ill start by giving a brief overview of our hardware infrastructure. Currently we're running the CitySquares' website on our own hardware in a Somerville co-location not too far from our headquarters in Boston's trendy South [...]]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom:0;">A couple weeks ago I began working with <a title="Amazon's Elastic Compute Cloud" href="http://aws.amazon.com/ec2" target="_blank">EC2</a> and <a title="RightScale" href="http://rightscale.com" target="_blank">RightScale</a> in preparation of our big IT infrastructure change over. Ill start by giving a brief overview of our hardware infrastructure. Currently we're running the <a title="CitySquares Online -- Hyper Local Neighborhood Search" href="http://citysquares.com" target="_blank">CitySquares'</a> website on our own hardware in a <a title="Somerville Businesses" href="http://ma.citysquares.com/somerville" target="_blank">Somerville</a> co-location not too far from our headquarters in Boston's trendy <a title="Boston's trendy South End neighborhood businesses" href="http://ma.citysquares.com/boston/south-end" target="_blank">South End</a> neighborhood.</p>
<p style="margin-bottom:0;">From the very beginning our contract IT guy set us up with a extremely robust and flexible IT infrastructure. It consists of a few machines running <a title="Xen Hypervisor" href="http://www.xen.org/" target="_blank">Xen</a> Hypervisors with <a title="Gentoo Linux" href="http://www.gentoo.org/" target="_blank">Gentoo</a> as the main host OS. Running Gentoo allows us to be as efficient as possible by specifically optimizing and compiling only the things we need. While this is a good step, it is Xen that really makes the big difference. It allows us to trade around resources as we see fit, more memory here, more virtual CPUs there, all can be done on the fly. For a startup or any company with limited resources this is rather essential. You never know where you are going to need to allocate resources in the months to come.</p>
<p style="margin-bottom:0;">While this is all well and good, we are still limited when it comes to scaling with increasing traffic or adding additional resource intensive features. We have a set amount of available hardware and adding more is an expensive upfront capital investment. Not only that but in order for us to really begin to take advantage of Xen and use it to its full potential we were presented with an expensive option, it required the purchase of a <a title="SAN Storage Area Network" href="http://en.wikipedia.org/wiki/Storage_area_network" target="_blank">SAN</a> and more servers. For those in the industry I don't think I need to mention that these get expensive in a hurry. This would have been a huge upfront cost for us, one we didn't want to budget for. The second option, which is the one we eventually went with was to drop our current hardware solution and make the plunge into cloud computing with Amazon's EC2.</p>
<p style="margin-bottom:0;">Here I am now. A couple of weeks into the switch with a lot of lessons learned. There are definitely pros and cons for each platform, either going with EC2 or rolling your own architecture. Before I get into the details I want to make clear that there are many factors involved in choosing a technology platform. I am only going to scratch the surface, touching upon the major pros and cons with respect to my own opinions with best interest for CitySquares in mind.</p>
<p style="margin-bottom:0;">Let me begin by starting with the pros for running your own hardware:</p>
<ul>
<li>
<p style="margin-bottom:0;">The biggest pro is most definitely 	persistence across reboots. I can not stress the importance of this 	one. You really take for granted the ability to edit a file and 	expect it to be there the next time the machine is restarted.</p>
<ul>
<li>
<p style="margin-bottom:0;">You only need to configure the 		software once. Once its running you don't really care what you did 		to make it work. It just works, every time you reboot.</p>
</li>
<li>UPDATE 8/21/08: <a title="Amazon releases the much anticipated Elastic Block Store" href="http://justinleider.com/2008/08/21/amazons-ebs-elastic-block-store/" target="_blank">Amazon releases persistent storage</a>.</li>
</ul>
</li>
<li>
<p style="margin-bottom:0;">Complete and utter control over 	everything that is running. This extends from the OS to the amount 	of RAM, CPU specs, hard drive specs, NICs, etc. The ability to have 	a economy or performance server is all up to you.</p>
</li>
<li>
<p style="margin-bottom:0;">Rather stable and unchanging 	architecture. Server host keys stay the same, the same number of 	servers are running today as there were yesterday and as there will 	be tomorrow.</p>
</li>
<li>
<p style="margin-bottom:0;">Reboot times. For those times when 	something is just AFU you can hit the reset button and be back up 	and running in a few minutes.</p>
</li>
<li>
<p style="margin-bottom:0;">You can physically touch it... Its 	not just in the cloud somewhere.</p>
</li>
</ul>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">Some cons for running your own hardware:</p>
<ul>
<li>
<p style="margin-bottom:0;">Companies with limited resources 	usually end up with architectures that exhibit single points of 	failure.</p>
<ul>
<li>
<p style="margin-bottom:0;">As an aside, you can be plagued 		by hardware failures at any time. This usually is accompanied by 		angry emails, texts and calls at 3am on Saturday morning.</p>
</li>
</ul>
</li>
<li>
<p style="margin-bottom:0;">Limited scalability options. For a 	rapidly expanding and growing website, the couple weeks it takes to 	order and install new hardware can be detrimental to your potential 	traffic and revenue stream.</p>
</li>
<li>
<p style="margin-bottom:0;">Management of physical pieces of 	hardware. Its a royal pain to have to go to a co-location to upgrade 	or fix anything that might need maintenance. Not to mention the 	potential down time.</p>
<ul>
<li>
<p style="margin-bottom:0;">Also, there are many hidden costs 		associated with IT maintenance.</p>
</li>
</ul>
</li>
<li>
<p style="margin-bottom:0;">Up front capital expenditures can 	be quite costly. This is especially true from a cash flow 	perspective.</p>
</li>
<li>
<p style="margin-bottom:0;">Servers and other supporting 	hardware are rendered obsolete every few years requiring the 	purchase of new equipment.</p>
</li>
</ul>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">These pros and cons for running your own hardware are pretty straight forward. Some people might mention managed hosting solutions which would mostly eliminate some of the cons related to server maintenance and hardware failures. However, this added service comes with an added price tag for the hosting. Whether it is right for you or your company is something to look into. We decided to skip this intermediary solution and go straight to the latest and greatest solution which is cloud computing. To be specific we sided with Amazon's EC2 (Elastic Compute Cloud) using RightScale as our management tool.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">Some of the pros for using EC2 in conjunction with the RightScale dashboard are as follows:</p>
<ul>
<li>
<p style="margin-bottom:0;">Near infinite resources (Server 	instances, Amazon's S3 Storage, etc) available nearly 	instantaneously. No more Slashdot DoS attacks if everything is 	properly configured and set to introduce more servers automatically. 	(RightScale Benefit)</p>
</li>
<li>
<p style="margin-bottom:0;">No upfront costs, everything is 	usage based. In the middle of the night if you are only utilizing 	one server thats all you pay for. Likewise, if during peak hours 	you're running twenty servers you pay for those twenty servers. 	(Amazon Benefit, RightScale is a monthly service)</p>
</li>
<li>
<p style="margin-bottom:0;">No hardware to think of. If fifty 	servers go down at Amazon we wont even know about it. No more angry 	calls at 3am. (Amazon Benefit)</p>
</li>
<li>
<p style="margin-bottom:0;">Multiple availability zones. This 	allows us to run our master database in one zone which is completely 	separate from our slave database. So if there is an actual fire or 	power outage in one zone the others will theoretically be 	unaffected. The single points of failure mentioned before are a 	thing of the past and this is just one example. (Amazon Benefit)</p>
</li>
<li>
<p style="margin-bottom:0;">Ability to clone whole deployments 	to create testing and development environments that exactly mirror 	the current production when you need them. (RightScale Benefit)</p>
</li>
<li>
<p style="margin-bottom:0;">Security updates are taken care of 	for the most part. RightScale provides base server images which are 	customized upon boot with the latest software updates. (RightScale 	Benefit)</p>
</li>
<li>
<p style="margin-bottom:0;">Monitoring and alerting tools are 	very good and highly customizable. (RightScale Benefit)</p>
</li>
</ul>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">Some of the cons for using EC2 and RightScale:</p>
<ul>
<li>
<p style="margin-bottom:0;">No persistence after reboot. I 	can't stress this one enough! All local changes will be wiped and 	you'll start with a blank slate!</p>
<ul>
<li>
<p style="margin-bottom:0;">All user contributed changes must 		be backed up to a persistent storage medium or they will be lost! 		We back up incrementally every 15 minutes with a full backup every 		night.</p>
</li>
<li>UPDATE 8/21/08: <a title="Amazon releases the much anticipated Elastic Block Store" href="http://justinleider.com/2008/08/21/amazons-ebs-elastic-block-store/" target="_blank">Amazon releases persistent storage</a>.</li>
</ul>
</li>
<li>
<p style="margin-bottom:0;">Writing scripts to configure 	everything upon boot is a time consuming and tedious process 	requiring a lot of trial and error.</p>
</li>
<li>
<p style="margin-bottom:0;">Every reboot takes approximately 	10-20 minutes depending on the number and complexity of packages 	installed on boot. Making the previous bullet point even that much 	more painful.</p>
</li>
<li>
<p style="margin-bottom:0;">A few of the pre-configured 	scripts are written quite well. The one for MySQL is as good as they 	get. You upload a config file complete with special tags for easy on the 	fly regular expression customization. The Apache scripts on 	the other hand are about as bad as they get. Everything must be 	configured after the fact.</p>
<ul>
<li>
<p style="margin-bottom:0;">With Apache however, you'll be writing regular expressions to 		match other regular expressions. Needless to say is a royal pain and you usually end up with unreadable gibberish.</p>
</li>
</ul>
</li>
</ul>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">So there you have it, take it as you wish. For CitySquares, EC2 and RightScale were the best options. It allows us to scale nearly effortlessly once configured. It is also a much cheaper option up front where as owning your own hardware is generally cheaper in the long run. We did trade a lot of the pros of owning your own hardware to get the scalability and hardware abstraction of EC2. It was a tough decision for us to switch away from our current architecture but in the end it will most likely be the best decision we've made. The flexibility and scalability of the EC2 and RightScale platform are by far the biggest advantages to switching and in the end its what <a title="CitySquares Online -- Hyper Local Neighborhood Search" href="http://citysquares.com" target="_blank">CitySquares</a> needs.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">
]]></content:encoded>
			<wfw:commentRss>http://www.derivante.com/2008/08/20/running-your-own-hardware-vs-ec2-and-rightscale/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Digging into HAProxy</title>
		<link>http://www.derivante.com/2008/08/13/digging-into-haproxy/</link>
		<comments>http://www.derivante.com/2008/08/13/digging-into-haproxy/#comments</comments>
		<pubDate>Wed, 13 Aug 2008 22:59:08 +0000</pubDate>
		<dc:creator>Justin Leider</dc:creator>
				<category><![CDATA[Web Architecture]]></category>
		<category><![CDATA[Web Technology]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[HAProxy]]></category>
		<category><![CDATA[high availability]]></category>
		<category><![CDATA[Load Balancing]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[reliability]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://justinleider.wordpress.com/?p=19</guid>
		<description><![CDATA[Well its been a few weeks since my last posting here and there is certainly a good reason for that. Every once in a while I just need to completely unplug from technology. So it only made sense for me to go away on vacation to the middle of no where up in Maine's great [...]]]></description>
			<content:encoded><![CDATA[<p>Well its been a few weeks since my last posting here and there is certainly a good reason for that. Every once in a while I just need to completely unplug from technology. So it only made sense for me to go away on vacation to the middle of no where up in Maine's great north woods for a couple of weeks. No computers, no cellphones, no towns, no people, just dirt logging roads, lakes, rivers, wildlife and trees. Now that I'm back and caught up I will begin to start posting regularly again.</p>
<p style="margin-bottom:0;">Getting back to reality, as the title states, this post will focus on the reasons behind using <a title="HA Proxy -- Load Balancing " href="http://http://haproxy.1wt.eu/">HAProxy</a> as well as a little bit on <a title="Hyper-Local Search Portal" href="http://citysquares.com">CitySquare's</a> implementation of the load balancer. Let me start by quoting a description of HAProxy from their website:</p>
<blockquote>
<p style="margin-bottom:0;">“HAProxy is a free, <em><strong>very</strong></em> fast and reliable solution offering <a href="http://en.wikipedia.org/wiki/High_availability">high availability</a>, <a href="http://en.wikipedia.org/wiki/Load_balancer">load balancing</a>, and proxying for TCP and HTTP-based applications. It is particularly suited for web sites crawling under very high loads while needing persistence or Layer7 processing. Supporting <strong>tens of thousands</strong> of connections is clearly realistic with todays hardware. “</p>
</blockquote>
<p style="margin-bottom:0;">While the high availability aspect of HAProxy is all well and good, everything is expected to be high availability these days. Any sort of downtime has become unacceptable even in the middle of the night. This is especially true when relying on search engine driven traffic. I've noticed that search engines like Google and Yahoo to name a couple, really ramp up their crawl rate in the wee hours of the morning. The crawl rate is boosted more so on weekend nights when even fewer people are searching the web and the search engines can allocate more of its resources towards web crawls. CitySquares has certainly been subject to DoS attacks by GoogleBot on Friday nights.</p>
<p style="margin-bottom:0;">This is where the load balancing aspect of HAProxy comes into play, it is one of the main reasons for choosing it as our front facing service.  With just a couple HAProxy servers we can maintain redundancy while having a nearly unlimited pool of Apache web servers to hand off requests to. We don't need any special front facing, load balancing hardware to act as a single point of failure. We can also keep some money in our pocket at the same time by utilizing a software solution. Luckily, HAProxy is open source and free to the world, licensed under the <a title="GPL v2 License Terms" href="http://www.opensource.org/licenses/gpl-2.0.php">GPL v2</a>.</p>
<p style="margin-bottom:0;">Not only does HAProxy handle our load balancing but it also serves as a central access point for DNS purposes. This solution is certainly much better than our current DNS round robin which is limited in its own right. Is this common sense? Probably, but I figured it was worth pointing out.</p>
<p style="margin-bottom:0;">Lastly, security is always a concern for heavily trafficked and high profile sites. The developer behind HAProxy has been very proactive with the program architecture and coding practices and as such HAProxy can claim it's never had a single known vulnerability in over five years. Since all front facing applications are subject to attacks from so many different sources these days, having a stable and secure application is a godsend when it comes to any sort of security related IT maintenance.</p>
<p style="margin-bottom:0;">As far as implementation goes, I suspect that eventually we might need to move the HAProxy instances onto their own dedicated servers as traffic increases. In the meantime, with EC2, we are running them in parallel with Apache on the same servers. This is purely a cost savings measure as every server instance  started with EC2 results in more cash out the door. As it is, HAProxy is incredibly fast and lean and really doesn't consume much in the way of system resources, either CPU load or memory utilization.</p>
<p style="margin-bottom:0;">There are certainly other reasons for choosing HAProxy but they are past of the scope of this post. I encourage everyone to take a serious look at HAProxy when spec'ing out a load balancer or proxy.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">
]]></content:encoded>
			<wfw:commentRss>http://www.derivante.com/2008/08/13/digging-into-haproxy/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Part 2: An Architecture Overview &#8212; Apache, MySQL, Memcached, SQLite</title>
		<link>http://www.derivante.com/2008/07/24/an-architecture-overview-apache-mysql-memcached-sqlite/</link>
		<comments>http://www.derivante.com/2008/07/24/an-architecture-overview-apache-mysql-memcached-sqlite/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 19:56:41 +0000</pubDate>
		<dc:creator>Justin Leider</dc:creator>
				<category><![CDATA[Web Architecture]]></category>
		<category><![CDATA[Web Technology]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[citysquares]]></category>
		<category><![CDATA[horizontal architecture]]></category>
		<category><![CDATA[horizontal database]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[SOLR]]></category>
		<category><![CDATA[sqlite]]></category>
		<category><![CDATA[xcache]]></category>

		<guid isPermaLink="false">http://justinleider.wordpress.com/?p=11</guid>
		<description><![CDATA[In my last post I mentioned the numerous technologies which were on tap for the upcoming version of CitySquares. This installment will continue to define an overview of the underlying architecture and begin to dig a little deeper into the actual implementation of the technologies. The idea and focus of this new architecture is aimed [...]]]></description>
			<content:encoded><![CDATA[<p><!-- 		@page { size: 8.5in 11in; margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom:0;">In my last post I mentioned the numerous technologies which were on tap for the upcoming version of <a title="CitySquares Online -- Hyper Local Neighborhood Search" href="http://citysquares.com" target="_blank">CitySquares</a>. This installment will continue to define an overview of the underlying architecture and begin to dig a little deeper into the actual implementation of the technologies. The idea and focus of this new architecture is aimed at creating a much more stable and scalable platform for us to work with. Before I get into the details you'll see Ive provided a graphic representation of how the architecture will be laid out.</p>
<p style="margin-bottom:0;">
<div id="attachment_12" class="wp-caption aligncenter" style="width: 430px"><a href="http://justinleider.files.wordpress.com/2008/07/architecture-overview.jpg"><img class="size-full wp-image-12" src="http://justinleider.files.wordpress.com/2008/07/architecture-overview.jpg" alt="A visual representation of a horizontal web architecture." width="420" height="300" /></a><p class="wp-caption-text">A visual representation of a horizontal web architecture.</p></div>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">Bear with me as I explain the work flow behind this graphic as it is not 100% clear from the visual representation. First off, I run <a title="Ubuntu Linux" href="http://www.ubuntu.com/" target="_blank">Ubuntu Linux</a> which is great for just about everything I need, except for creating any sort of graphics, so I apologize in advance for the lackluster graphic. As you can see, there are a few different layers: users, <a title="HA Proxy -- Load Balancing " href="http://haproxy.1wt.eu/" target="_blank">HA Proxy</a>, Apache, <a title="High performance caching system" href="http://www.danga.com/memcached/" target="_blank">Memcached</a>, <a title="SQLite -- A small fast file based database" href="http://www.sqlite.org/" target="_blank">SQLite</a> and finally MySQL labeled as databases.</p>
<p style="margin-bottom:0;">First and foremost are our beloved users, which whom without we would have no need for a website. Starting from the beginning, the users request a page from CitySquares, from there their request is passed through one of two HA Proxy servers. The sole purpose of these two machines is to load balance the incoming requests among all our Apache web servers and serve as a failsafe for one another. Once the user's request has been accepted and forwarded along to Apache we actually begin to process the request.</p>
<p style="margin-bottom:0;">The Apache servers run PHP and XCache modules. The PHP part I feel is fairly straight forward and out of the scope of this post so I will skip that part of the architecture. XCache however, is used in conjunction with and is an enhancement to PHP. More specifically XCache is an opcode optimizer and cache. It works by removing the compilation time of PHP scripts by caching the compiled and optimized state of the PHP scripts directly in the shared memory of the Apache server. This compiled version can increase page generation times by up to 500%, speeding up overall response time and reducing server load.</p>
<p style="margin-bottom:0;">Just as with all dynamic websites most if not all the actual data is stored in databases. Gone are the days of flat files with near zero processing required. Databases are the new workhorses of the web world and as such usually become the bottle neck of the overall system. CitySquares is in a somewhat unique position, nearly all our page loads have quite a bit of location and distance based processing and nearly all of this is done in our MySQL database. So while our Apache servers are sitting idle waiting for responses from their queries, the DB is preforming the brunt of the work calculating distances between objects and the like.</p>
<p style="margin-bottom:0;">We can reduce this bottleneck in a couple of different ways, the first of which is object caching. We will use Memcached to cache objects returned from the database. Say for example, we know the distance between two businesses. We know with a fair amount of certainty that those two businesses are going to be in the same place they were an hour ago, just as they were a week ago and as they will be a day from now. So we can cache this information with an expiration time of a couple days, thus saving ourselves the expense of calculating the distance between them on every page load. Of course if a user comes by and changes the location of one of these businesses, we can expire the object in cache and replace it with a newly calculated object straight from the database on the subsequent page load. These expensive queries require large table scans and mathematical formulas calculations on every row. These query results can be cached to free up the database and allow it to do what it does best. Store and retrieve data.</p>
<p style="margin-bottom:0;">In the case where we cant find the data in Memcached, either because it doesn't yet exist or has expired we will turn to our databases. We must first query a SQLite instance which is the gate keeper between Apache and the numerous databases we have. By having a separate lookup table we can essentially divide and parcel out our data sets on a table by table basis even down to an entry by entry basis. Depending on the type of data we are requesting SQLite will provide us with the location of one database or another to query for our data.</p>
<p style="margin-bottom:0;">One could argue that this just adds another layer of latency and they would be correct. However, as scalability becomes an issue you will find that adding database replication generally results in diminishing returns.  As new servers are brought online the overhead associated with replicating writes across all the replicated servers becomes choking and creates its own bottleneck. On the other hand, with a lookup table and a horizontal database architecture we don't have to worry about database replication nearly as much. You can just as easily divide your data sets into different databases. Now how you go about this varies greatly depending on your data. For CitySquares the solution turns out to be rather simple. Everything we do is location specific so it only makes sense that each data set is only as big as its parent city. Theoretically every city and all the data related to said city could reside in its own database. As you can probably guess we are only performance limited by the biggest cities, <a title="Manhattan on CitySquares" href="http://ny.citysquares.com/manhattan" target="_blank">Manhattan</a>, <a title="Brooklyn on CitySquares" href="http://ny.citysquares.com/brooklyn" target="_blank">Brooklyn</a>, etc. In these few cases we can always fall back to bigger and better servers and or replication if necessary.</p>
<p style="margin-bottom:0;">Just as our database has become a bottleneck in our current site, our search engine is also one as well, just to a lesser extent. We can take the lessons learned from our horizontal database architecture and apply it to the search engine architecture as well. By dividing our data sets into logical partitions we can keep our data from getting too large and unwieldy;  And with these smaller data sets we can reduce or remove all together the overhead associated with replicating data over multiple machines.</p>
<p style="margin-bottom:0;">While this solution sounds great, it won't be worth the effort if every time a programmer wanted to access some data they would be required to check Memcached, then SQLite and then finally MySQL for every query. In order for this to be feasible from a programmers standpoint the programmer should never have to think about this underlying architecture. This of course I will discuss in greater detail in the upcoming installments. Stay Tuned.</p>
<p style="margin-bottom:0;">
]]></content:encoded>
			<wfw:commentRss>http://www.derivante.com/2008/07/24/an-architecture-overview-apache-mysql-memcached-sqlite/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Part 1: A Technology Overview</title>
		<link>http://www.derivante.com/2008/07/21/a-technology-overview/</link>
		<comments>http://www.derivante.com/2008/07/21/a-technology-overview/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 20:21:28 +0000</pubDate>
		<dc:creator>Justin Leider</dc:creator>
				<category><![CDATA[Framework]]></category>
		<category><![CDATA[Web Technology]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[rightscale]]></category>
		<category><![CDATA[s3]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://justinleider.wordpress.com/?p=5</guid>
		<description><![CDATA[This will be the first post in a multi-part series, each of the following installations will detail the technologies and implementations of the upcoming CitySquares revision. I hope to cover the entire page generation process, starting with the user's first request to the resulting dynamically generated HTML, CSS, JS, etc. Before I dive too deep [...]]]></description>
			<content:encoded><![CDATA[<p><!-- 		@page { size: 8.5in 11in; margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom:0;">This will be the first post in a multi-part series, each of the following installations will detail the technologies and implementations of the upcoming <a title="CitySquares Online" href="http://citysquares.com" target="_blank">CitySquares</a> revision. I hope to cover the entire page generation process, starting with the user's first request to the resulting dynamically generated HTML, CSS, JS, etc. Before I dive too deep into the technical aspect of things I would like to give a brief overview of what is to come.</p>
<p style="margin-bottom:0;">For starters, CitySquares currently owns and operates its own servers in a co-location not far from our headquarters. This will be the first thing to go as we switch to Amazon's EC2 and S3 in conjunction with <a title="RightScale" href="http://rightscale.com" target="_blank">RightScale</a>. By switching off of our own hardware we will absolve ourselves of this oft troublesome and physically limiting layer. By using RightScale's server templates and management scripts we can control the precise number of servers in operation. Coping with increased or decreased load will be handled autonomously throught the RightScale interface, no more DoS by SlashDot and more more wasted cycles during off peak hours. Our server deployment will contain a few different types, each one specially tuned and selected for its specific purpose. Without getting into too much detail here, our deployment will consist of the following:</p>
<ul>
<li>
<p style="margin-bottom:0;">HA Proxy for load balancing</p>
</li>
<li>
<p style="margin-bottom:0;">Apache with PHP and <a title="XCache Opcode cahce and optimizer" href="http://xcache.lighttpd.net" target="_blank">XCache</a></p>
</li>
<li>
<p style="margin-bottom:0;"><a title="High performance caching system" href="http://www.danga.com/memcached/" target="_blank">Memcached</a></p>
</li>
<li>
<p style="margin-bottom:0;">MySQL master/slave configuration</p>
</li>
<li>
<p style="margin-bottom:0;">File server with automated 	revisioning, concatenation and minimization of css, js, etc</p>
</li>
<li>
<p style="margin-bottom:0;">Tomcat with <a title="SOLR Search Engine" href="http://lucene.apache.org/solr/" target="_blank">SOLR</a> search engine</p>
</li>
</ul>
<p>Once setup, most of the overhead associated with operating our own IT infrastructure will be removed from the equation.</p>
<p style="margin-bottom:0;">Not only will our IT situation improve but our coding environment will change dramatically as we move away from Drupal's more primitive procedural style coding practice and towards <a title="Symfony Framework" href="http://www.symfony-project.org" target="_blank">Symfony</a>'s OOP style.  Symfony is a PHP based MVC (Model, View Controller) framework. It is loosely based on RoR's (Ruby on Rails) best practices for codability and maintainability.  We will be using it with the Doctrine ORM (Object Relational Mapping) and Smarty templating engine. These architectural and IT changes will work to promote a cleaner, more efficient and maintainable coding practice. In the end all these disruptive changes will be justified, allowing us to focus on what we do best, provide users with <a title="An article describing hyper-local" href="http://searchenginewatch.com/showPage.html?page=3625971" target="_blank">hyper-local</a> search results.</p>
<p style="margin-bottom:0;">
]]></content:encoded>
			<wfw:commentRss>http://www.derivante.com/2008/07/21/a-technology-overview/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->