Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get EC2 load balancing properly set up to allow for real time file syncing?

I'm new to EC2. I have read a lot about it, watched many videos and tutorial and pretty much familiar with how everything work. I still have few question that I can't seem to find direct answers to.

If I have 3 instances (linux) with load balancing all serving the same site and the site is a dynamic php/mysql driven where users post files forum threads every second, how is the database and files synced to all 3 instances in real time.

  1. Do I need to have the database on RDS where every instance simply points to it.
  2. How about user files. If a user uploaded a file to the site, then this file should be available immediately on all instances immediately, how is this possible. I don't think having 3 copies on 3 instances is very practical.
  3. If I modify the site, let's say change the something in the CSS file, how do I sync the changes to all instances.
  4. How do EBS or S3 play a role in all of this.
like image 928
Hussein Avatar asked Mar 06 '12 20:03

Hussein


1 Answers

Do I need to have the database on RDS where every instance simply points to it.

That is one option, or you can boot up another instance to sit behind the app servers, put MySQL on it and have them all connect to that instance. One thing to note, make sure to connect over the internal network using the private ip and make sure all your security is tight.

How about user files. If a user uploaded a file to the site, then this file should be available immediately on all instances immediately, how is this possible. I don't think having 3 copies on 3 instances is very practical.

No that is not practical. You could upload it to that backend db instance that they all have access to, but really you should probably upload it to S3 in a bucket that all your instances can use with s3tools or something.

If i modify the site, let's say change the something in the CSS file, how do i sync the changes to all instances.

Git. (or svn) But you could use cloudfront for your JS and CSS files.... not a bad idea. And use a S3 bucket as your source...

How do EBS or S3 play a role in all of this.

Your database should always be on ebs volumes so you dont lose it. S3 can be used to share and store files cheaply and easily across your entire environment.

like image 185
chantheman Avatar answered Sep 28 '22 15:09

chantheman