Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load balancing web servers + keeping content synced

I'm considering implementing EC2's Elastic Load Balancing features, but I'm running a web application (on the LAMP stack) that has frequent changes and wondering what the most common strategy is for keeping the application in sync between the servers that are load balanced. The database would live elsewhere, so I'm only worried (at this point) about keeping the actual scripts in sync when I make changes.

like image 219
Matthew Avatar asked Jan 19 '23 10:01

Matthew


2 Answers

It depends how frequently you're going to update the scripts:

  • The most common solution is to store your shared components in an EBS volume, create a snapshot and then mount that from the instances - either as the root device (allowing you to keep the entire code state in sync across all instances) or as a secondary volume (containing just your code, allowing you to use AMIs built by other users, like Canonical)
  • With frequent updates a simple solution like rsync is likely the winner, alternatively you could keep them on S3 and use the S3 fuse module to mount the scripts directly from S3 (with this solution you may end up spending slightly more on the number of S3 GET requests depending on how S3 fuse caches).
like image 146
Peter Avatar answered Jan 21 '23 23:01

Peter


The one way of addressing this problem is using a continuous integration which can transfer your files with rsync and build the project on the servers, this is not just yet.

There are quite a bunch of plugins available (PHPUnit, Code Coverage, Code Analysis, etc):

Jenkins

How:

  1. Install Jenkins
  2. Configure your project (probably you code should be in some code-version-system) with Jenkins
    1. Configure the servers, project-path, pre-job, post-job, etc.
  3. Schedule the work/job.
  4. That's it, done.

Reference:

  1. Configuration:
    1. configuring - ex.1
    2. Initial configuration
      1. Configuring the jobs
  2. http://agile.dzone.com/news/continuous-integration-php
like image 22
Rakesh Sankar Avatar answered Jan 22 '23 01:01

Rakesh Sankar