title: Server architecture for a scalable web application
body: <p>we're planing to deploy a web-application with Amazon OpsWork and I just wanted to check with you, if our architecture might have any design flaws.</p>
  
  <p>We've 4 components:</p>
  
  <ol>
  <li>A load balanacer (Amazon preferably)</li>
  <li>Express based on Node.js</li>
  <li>MongoDB</li>
  <li>ElasticSearch</li>
  </ol>
  
  <p>Here's a communication diagram of our components:</p>
  
  <p><img src="https://dl.dropboxusercontent.com/u/6441314/components.png" alt="components communication diagram"></p>
  
  <p>At the front is a load balancer which distributes http requests to multiple web servers.</p>
  
  <p>The web server is stateless and therefore can be cloned each time the load requires it. All web server instances are equal. Session information is saved in the MongoDB.</p>
  
  <p>In the "backend" we're planing to use the build-in cluster functionalities from MongoDB and ElasticSearch. Therefore each web server instance only connects to a single MongoDB and ElasticSearch master instance. MongoDB and ElasticSearch are then scaling accordingly. Furthermore the the ElasticSearch master speaks to the MongoDB master to retrieve data for building the index.</p>
  
  <p>How we see it, the most challenging task to setup such a system, is to configure OpsWorks with the MongoDB and ElasticSearch cluster.</p>
  
  <p>Many thanks in advance!</p>