<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>clog: Tag Database</title>
    <link>http://blog.chrispcritter.com/articles/tag/database</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Why I Converted to Search Servers</title>
      <description>&lt;p&gt;Many who have worked with me in the past know that I always resisted including search servers (ferret/lucene/solr) into my projects.  I argued that they added unnecessary complexity and didn&amp;#8217;t provide much that some fancy database searching couldn&amp;#8217;t do.&lt;/p&gt;

&lt;p&gt;I was wrong.&lt;/p&gt;

&lt;p&gt;While I suppose that I still consider the above arguments to be valid, there is one more important argument on the side of using search servers - scalability.  I share many rubyists&amp;#8217; disdain for the &amp;#8220;S&amp;#8221; word.  It gets thrown around a lot and typically results in overbloated software that still doesn&amp;#8217;t perform well even when &amp;#8220;scaled.&amp;#8221;  There really isn&amp;#8217;t a better word in this case though.  &lt;/p&gt;

&lt;p&gt;HTTP is incredible.  As the recent RESTful advocates have pointed out, the protocol is infinitely scalable, simple, and is (in a large way) responsible for the explosive growth of the web.  Web servers getting bogged down?  No problem, just add another (as long as you&amp;#8217;re not trying to do any - or at least not much - state tracking).  You can keep adding servers to your heart&amp;#8217;s content.  A good admin can have this process down to a five minute setup.&lt;/p&gt;

&lt;p&gt;Eventually all of those database calls add up though and your database starts straining under load.  What do you do now?  You can start optimizing your queries, do some fancy caching, add a slave database and keep a read-only connection open to it or (the mother of all evils) create a database cluster.&lt;/p&gt;

&lt;p&gt;All of these options suck.&lt;/p&gt;

&lt;p&gt;All of that beloved simplicity and scalability of HTTP is gone and replaced by infrastructure that&amp;#8217;s extremely expensive and hard to maintain.  Sometimes you just can&amp;#8217;t get around the database cluster - but it should be a weapon of last resort.  Query optimization isn&amp;#8217;t so bad if done correctly, but it will only get you so far.  Query optimization can also take nice clean code and turn it into a mangled nightmare.  Caching is also good in moderation, but too much of it is also a code mangler and can make your application&amp;#8217;s usability suffer (waiting 10 minutes for a user&amp;#8217;s change to appear is often not usable).  Database slaves are fine as failover/backup options but reading from one db and writing to the other also produces mangled code.&lt;/p&gt;

&lt;p&gt;The solution?  Search servers.  Search servers can grow infinitely.  You can run one on each web server or you can also have a centralized search server if you prefer.  Whenever you pull results from the search server your database has avoided the blow.  You&amp;#8217;ll still probably need to hit the database occasionally, but your load will be dramatically lower.  The load is on the web server end and can be shared across the web cluster without any fancy configuration.  Once your search server is in place, use it for as much querying as you possibly can.  The growth of your database load will be a nice slowly climbing linear line that will probably keep pace with processor speeds.  If done right, you can avoid the extreme overhead involved with a database cluster.&lt;/p&gt;</description>
      <pubDate>Mon, 10 Dec 2007 06:08:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:e32d19af-5d6a-4684-a664-4930bc7460bf</guid>
      <author>chrisp</author>
      <link>http://blog.chrispcritter.com/articles/2007/12/10/why-i-converted-to-search-servers</link>
      <category>Development</category>
      <category>Ruby and RubyOnRails</category>
      <category>Development</category>
      <category>Database</category>
      <category>SearchServer</category>
      <category>Ferret</category>
      <category>Lucene</category>
      <category>Solr</category>
      <category>Ruby</category>
      <category>RubyOnRails</category>
      <category>HTTP</category>
      <category>REST</category>
      <trackback:ping>http://blog.chrispcritter.com/articles/trackback/50</trackback:ping>
    </item>
  </channel>
</rss>
