Ips
Ips

Reputation: 45

Apache PHP API & MySQL AWS Load balancing

I am building a app and website that has PHP REST API on Apache with MySQl on AWS EC2.

I want to do load balancing, I know I can use two or more EC2 but how MySQL is going to work (How two EC2 will share database)?

Upvotes: 0

Views: 355

Answers (1)

Solution 1

If you want to have a load balancing feature, it has to be on the web layer and below is the solution for it. Here you have to manage the EC2 and if this goes down then will run into errors in DB layer, hence the solution 2

AWS ALB --> EC2 ( Apache, PHP, AZ1 ) --> EC2 ( Mysql )
     \                                  /
      \----> EC2 ( Apache, PHP, AZ2 )  /  

Solution 2

If you go with the RDS with MultiAZ then below is the option for no single point of failure

AWS ALB --> EC2 ( Apache, PHP, AZ1 ) --> RDS ( Mysql ) --> with Standby in another AZ
     \                                  /
      \----> EC2 ( Apache, PHP, AZ2 )  /  

AZ = Availability Zone

Upvotes: 1

Related Questions