AWS Classroomnotes 24/Feb/2023

AWS EC2 contd…

Horizontal vs Vertical Scaling

  • Differences
    Preview
  • Vertical scaling in AWS is possible by changing instance type.
  • When we change the instance type the ec2 instance should be in stopped state
  • Changing instance type in AWS. Shutdown the ec2 instance
    Preview
    Preview
    Preview
    Preview
  • start the ec2 instance
  • Horizontal scaling:

    • This can be done manually by adding ec2 instances with the same AMI.
  • Consider the below architecture
    Preview
  • As number of parallel users increase, load on web, orders and catalog increases which might lead to performance bottleneck.
  • During the peaks or when in need we need aws to automatically increase number of ec2 instances running the corresponding application.
  • It is better to create an AMI for
    • web
    • orders
    • catalog
  • AWS has an option to perform auto scaling which is referred as Auto scaling group.

Auto Scaling Groups

  • AWS EC2 Auto Scaling Groups give us two broader options

    • fixed scaling:
      • In Fixed scaling the fixed count is maintained by AWS
      • For eg: you have give fixed scaling count to 5, it creates 5 ec2 instances in chosen subnets (AZ’s). By any chance if the ec2 instance is down, aws will create one more to maintain count of 5
    • auto scaling:
      • In this case we specify
        • min ec2 instances
        • max ec2 instances
        • desired count
      • We also specify when the ec2 instance count should be increased (scaled out) and decrease (scaled in)
      • desired count will be dynamic depending on situation.
  • To Create Autoscaling group

    • AMI: Create AMI with Applications pre installed
    • Decide which metrics to use when your ec2 has to be scaled out or in
    • Choose the AZ’s (subnets) where scaling has to happned
    • Choose the scaling methodologies

Experiments

  • Create an ec2 instance with phpinfo and stress
#!/bin/bash
apt update
apt install apache2 stress -y
apt install php libapache2-mod-php php-mysql -y
echo '<?php phpinfo(); ?>' > /var/www/html/info.php
systemctl restart apache2
  • Navigate to monitoring on AWS Console
    Preview
  • ssh into ec2 and execute
stress --cpu 10 --io 40 --vm-bytes 256M --timeout 10m -v
  • observe the metrics on the AWS Console for next 10 minutes
    Preview
  • Generally in servers like apache the load on cpu increases as number of requests to websit increases, so cpu utilization should be a decent metric to start scaling
    Preview

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube