title: How to get your code ready for Loadbalancing
body: <p>As we did this in the past, i'd like to gather useful information for everyone moving to loadbalancing, as there <em>are</em> issues which your code must be aware of.</p>
  
  <p>We moved from one apache server to squid as reverse proxy/loadbalancer with three apache servers behind.</p>
  
  <p>We are using PHP/MySQL, so issues may differ.</p>
  
  <h2>Things we had to solve:</h2>
  
  <h3>Sessions</h3>
  
  <p>We moved from "default" php sessions (files) to distributed memcached-sessions. Simple solution, has to be done. This way, you also don't need "sticky sessions" on your loadbalancer.</p>
  
  <h3>Caching</h3>
  
  <p>To our non-distributed apc-cache per webserver, we added anoter memcached-layer for distributed object caching, and replaced all old/outdated filecaching systems with it.</p>
  
  <h3>Uploads</h3>
  
  <p>Uploads go to a shared (nfs) folder.</p>
  
  <h2>Things we optimized for speed:</h2>
  
  <h3>Static Files</h3>
  
  <p>Our main NFS runs a lighttpd, serving (also user-uploaded) images. Squid is aware of that and never queries our apache-nodes for images, which gave a nice performance boost. Squid is also configured to cache those files in ram.</p>
  
  <p><strong>What did you do to get your code/project ready for loadbalancing, any other concerns for people thinking about this move, and which platform/language are you using?</strong></p>