The right way to create multiple instances for Load Balancer (EC2)

Mara Ang

I installed Wordpress using EC2. I created a Load Balancer by creating image (AMI) then adding both Wordpress1 and Wordpress2 on Load Balancer. But I'm still getting database error and have to restart the instances. If I'd like to make 4 instances as Load balancer, are the steps the same? because I saw a "Number of Instances" option when I launched an AMI. Default value is 1. I'm not sure if I should enter 3 or 4 to create multiple instances in one click.

Also, if I update on Wordpress1 instance, will the updates show if the domain will load Wordpress2 instance?

Justus Krapp

If you want to launch multiple instances and a database etc, you should consider using AWS CloudFormation. CloudFormation is just a big json string that contains the configuration of your environment, including the servers, autoscaling, access, register with the loadbalancer, etc.

See http://aws.amazon.com/en/cloudformation/ for more details.

There is already an example template for wordpress including a database and autoscaling groups (example wordpress template)

However like datasage mentioned you will need to make adjustments to wordpress to make it working in a multiserver environment.

The "problem" with multiserver environments is that if you upload a file or in your case upgrade wordpress, it will only happen on one server, which could be terminated at any point. Furthermore the upgrade could contain changes in the database structure and then its getting complicated.

If you are building something in the cloud you should always keep in mind that every service you build, in you case the frontend webservers and the database should be allowed to fail without interrupting your service.

Another point is, that you should avoid doing stuff by hand, automation is the key. An environment where you need to link your server by hand to a loadbalancer is not very useful in the cloud where servers are continuously terminated, rebooted and exchanged.

For you webservers you can use "autoscaling groups" to get this behavior. If you are using autoscaling groups and a server is terminated or considered unhealthy, a new one will be started automatically and registered with the loadbalancer as soon as it is considered as healthy.

For your database amazon offers for rds multi AZ environments which provide a automatic failover.

Applying upgrades in the cloud can be a tricky and there are different ways to do this. for example using a shared NFS mount with the code base, git deployments or the way you already started: creating a new AMI for every upgrade and then replacing the servers. There are a lot options and they all have their benefits and drawbacks.

As far as i understand you use-case the cloud is maybe not the right choice at the moment.

Normally hosting a small business in the cloud is much more expensive than using a single server. You will only save money if you need like 20 servers in the evening and only 2 or 3 for the rest of the day. Of course there are a lot more points to consider but that would be to much.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

504 Gateway Timeout - Two EC2 instances with load balancer

From Dev

EC2 instances removed from load balancer

From Dev

Web Deploy to EC2 instances behind AWS Elastic Load Balancer

From Dev

Setup of a load balancer of 2 play framework instances

From Dev

Ansible: Trying to create multiple EC2 instances in multiple regions in one shot

From Dev

How to create and run multiple ec2 instances with same configurations and software installed?

From Dev

Launch multiple EC2 instances in parallel

From Dev

Run script on multiple ec2 instances

From Dev

connecting to multiple instances of EC2 with ssh

From Dev

Provision of multiple EC2 instances with Ansible

From Java

Redirecting EC2 Elastic Load Balancer from HTTP to HTTPS

From Dev

Requests going through EC2 load balancer hangs

From Dev

HTTP redirect to HTTPS AWS EC2 with Load Balancer

From Dev

HTTP redirect to HTTPS AWS EC2 with Load Balancer

From Dev

ec2 load balancer determine which instance got request

From Dev

Configuration Errors: Elastic Load Balancer + EC2 + Route 53

From Dev

Security Group Linking EC2 - Load Balancer - RDS

From Dev

How to synchronize a common resource in Java when the application is deployed on multiple instances behind a load balancer

From Dev

Is google load balancer awaking sleeping instances?

From Dev

Is there an easy way to connect to EC2 instances using their Name tag?

From Dev

Best way to launch aws ec2 instances with ansible

From Dev

Is there an easy way to connect to EC2 instances using their Name tag?

From Dev

Limiting number of AWS EC2 instances a user can create

From Dev

Create EC2 container service instances using cloudformation

From Dev

Shared File Systems between multiple AWS EC2 instances

From Dev

Remotely execute program in multiple EC2 instances and wait for results

From Dev

Launch multiple EC2 instances with name convention

From Dev

Same Kinesis Consumer running on multiple EC2 instances

From Java

Install AWS SSL Certificate to EC2 instance without load balancer

Related Related

  1. 1

    504 Gateway Timeout - Two EC2 instances with load balancer

  2. 2

    EC2 instances removed from load balancer

  3. 3

    Web Deploy to EC2 instances behind AWS Elastic Load Balancer

  4. 4

    Setup of a load balancer of 2 play framework instances

  5. 5

    Ansible: Trying to create multiple EC2 instances in multiple regions in one shot

  6. 6

    How to create and run multiple ec2 instances with same configurations and software installed?

  7. 7

    Launch multiple EC2 instances in parallel

  8. 8

    Run script on multiple ec2 instances

  9. 9

    connecting to multiple instances of EC2 with ssh

  10. 10

    Provision of multiple EC2 instances with Ansible

  11. 11

    Redirecting EC2 Elastic Load Balancer from HTTP to HTTPS

  12. 12

    Requests going through EC2 load balancer hangs

  13. 13

    HTTP redirect to HTTPS AWS EC2 with Load Balancer

  14. 14

    HTTP redirect to HTTPS AWS EC2 with Load Balancer

  15. 15

    ec2 load balancer determine which instance got request

  16. 16

    Configuration Errors: Elastic Load Balancer + EC2 + Route 53

  17. 17

    Security Group Linking EC2 - Load Balancer - RDS

  18. 18

    How to synchronize a common resource in Java when the application is deployed on multiple instances behind a load balancer

  19. 19

    Is google load balancer awaking sleeping instances?

  20. 20

    Is there an easy way to connect to EC2 instances using their Name tag?

  21. 21

    Best way to launch aws ec2 instances with ansible

  22. 22

    Is there an easy way to connect to EC2 instances using their Name tag?

  23. 23

    Limiting number of AWS EC2 instances a user can create

  24. 24

    Create EC2 container service instances using cloudformation

  25. 25

    Shared File Systems between multiple AWS EC2 instances

  26. 26

    Remotely execute program in multiple EC2 instances and wait for results

  27. 27

    Launch multiple EC2 instances with name convention

  28. 28

    Same Kinesis Consumer running on multiple EC2 instances

  29. 29

    Install AWS SSL Certificate to EC2 instance without load balancer

HotTag

Archive