Page cover

Auto-Scaling and Load Balancing

1.1 Overview

In this section, we outline the setup and configuration of auto-scaling and load-balancing for CapsureLabs cloud infrastructure using AWS and Google Cloud Platform (GCP). These configurations ensure the platform's scalability and high availability by dynamically adjusting resources based on traffic and workload demands.


1.2 Auto-Scaling on AWS

1.2.1 Launch Configuration for Auto-Scaling Group

aws autoscaling create-launch-configuration \
  --launch-configuration-name capsurelabs-lc \
  --image-id ami-1234567890abcdef0 \
  --instance-type t2.medium \
  --security-groups sg-12345678 \
  --key-name capsurelabs-key

1.2.2 Auto-Scaling Group Setup

aws autoscaling create-auto-scaling-group \
  --auto-scaling-group-name capsurelabs-asg \
  --launch-configuration-name capsurelabs-lc \
  --min-size 2 \
  --max-size 10 \
  --desired-capacity 2 \
  --vpc-zone-identifier "subnet-12345678,subnet-87654321"

1.2.3 Scaling Policy

aws autoscaling put-scaling-policy \
  --auto-scaling-group-name capsurelabs-asg \
  --policy-name scale-out-policy \
  --scaling-adjustment 2 \
  --adjustment-type ChangeInCapacity \
  --cooldown 300

1.3 Load Balancing on AWS with Elastic Load Balancing

1.3.1 Create an Application Load Balancer

aws elbv2 create-load-balancer \
  --name capsurelabs-alb \
  --subnets subnet-12345678 subnet-87654321 \
  --security-groups sg-12345678

1.3.2 Target Group Creation

aws elbv2 create-target-group \
  --name capsurelabs-target-group \
  --protocol HTTP \
  --port 80 \
  --vpc-id vpc-12345678 \
  --health-check-protocol HTTP \
  --health-check-path /health

1.3.3 Register Targets and Configure Listener

aws elbv2 register-targets --target-group-arn <target-group-arn> --targets Id=<instance-id>
aws elbv2 create-listener \
  --load-balancer-arn <alb-arn> \
  --protocol HTTP \
  --port 80 \
  --default-actions Type=forward,TargetGroupArn=<target-group-arn>

1.4 Auto-Scaling and Load Balancing on Google Cloud Platform

1.4.1 Instance Template

gcloud compute instance-templates create capsurelabs-template \
  --machine-type e2-medium \
  --network default \
  --subnet default \
  --image-family debian-10 \
  --image-project debian-cloud

1.4.2 Managed Instance Group with Auto-Scaling

gcloud compute instance-groups managed create capsurelabs-group \
  --base-instance-name capsurelabs-instance \
  --template capsurelabs-template \
  --size 1 \
  --zone us-central1-a

gcloud compute instance-groups managed set-autoscaling capsurelabs-group \
  --max-num-replicas 10 \
  --min-num-replicas 2 \
  --target-cpu-utilization 0.75 \
  --cool-down-period 90

1.4.3 Load Balancing with Cloud Load Balancer

gcloud compute health-checks create http http-basic-check \
  --port 80 --request-path /health

gcloud compute backend-services create capsurelabs-backend \
  --protocol HTTP \
  --port-name http \
  --health-checks http-basic-check \
  --global

gcloud compute url-maps create capsurelabs-map \
  --default-service capsurelabs-backend

gcloud compute target-http-proxies create http-lb-proxy \
  --url-map capsurelabs-map

gcloud compute forwarding-rules create http-content-rule \
  --global \
  --target-http-proxy http-lb-proxy \
  --ports 80

Last updated