☁️ Cloud

Elastic

Elastic

A cloud characteristic of automatically scaling resources up and down with demand. Cost efficiency.

Detailed Explanation

Elastic (elasticity) is one of the core characteristics of cloud computing, referring to the ability to automatically expand (Scale Out/Up) or reduce (Scale In/Down) computing resources according to workload demand. This makes it possible to optimize costs while maintaining performance.

Two approaches to elasticity:

  • Horizontal Scaling / Scale Out: Increasing the number of instances. Example: 3 EC2 instances → 10
  • Vertical Scaling / Scale Up: Increasing the instance specifications. Example: t3.small → t3.xlarge

Services that implement elasticity in the cloud:

  • AWS Auto Scaling: Automatic scaling for EC2, ECS, DynamoDB, etc.
  • Kubernetes HPA/VPA: Horizontal/vertical automatic scaling of Pods
  • Serverless: Lambda and Cloud Functions scale automatically per request
  • Managed services: Automatic capacity adjustment for RDS, Aurora, DynamoDB, etc.

When "Elastic" appears in an AWS service name (EC2, ELB, EBS, EKS, etc.), it means the service offers this elasticity as a core characteristic.

Code Example

# AWS Auto Scaling Group 생성 aws autoscaling create-auto-scaling-group \ --auto-scaling-group-name my-asg \ --launch-template LaunchTemplateId=lt-0123456789abcdef0 \ --min-size 2 \ --max-size 10 \ --desired-capacity 3 \ --vpc-zone-identifier "subnet-1234,subnet-5678" \ --target-group-arns arn:aws:elasticloadbalancing:region:account:targetgroup/my-tg/xxx # CPU 기반 Target Tracking 정책 (자동 Scale In/Out) aws autoscaling put-scaling-policy \ --auto-scaling-group-name my-asg \ --policy-name cpu-target-tracking \ --policy-type TargetTrackingScaling \ --target-tracking-configuration '{ "PredefinedMetricSpecification": { "PredefinedMetricType": "ASGAverageCPUUtilization" }, "TargetValue": 50.0 }' # 예약 스케일링 (야간 축소) aws autoscaling put-scheduled-action \ --auto-scaling-group-name my-asg \ --scheduled-action-name scale-down-night \ --recurrence "0 22 * * *" \ --min-size 1 \ --max-size 2 \ --desired-capacity 1 # 주간 확장 aws autoscaling put-scheduled-action \ --auto-scaling-group-name my-asg \ --scheduled-action-name scale-up-day \ --recurrence "0 8 * * 1-5" \ --min-size 2 \ --max-size 10 \ --desired-capacity 3 # DynamoDB 테이블 자동 스케일링 aws application-autoscaling register-scalable-target \ --service-namespace dynamodb \ --resource-id "table/my-table" \ --scalable-dimension "dynamodb:table:ReadCapacityUnits" \ --min-capacity 5 \ --max-capacity 100
# Kubernetes Horizontal Pod Autoscaler (HPA) # CPU 기반 자동 스케일링 apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: my-app-hpa spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: my-app minReplicas: 2 maxReplicas: 20 metrics: # CPU 50% 기준 - type: Resource resource: name: cpu target: type: Utilization averageUtilization: 50 # 메모리 70% 기준 - type: Resource resource: name: memory target: type: Utilization averageUtilization: 70 behavior: # 빠른 Scale Up scaleUp: stabilizationWindowSeconds: 0 policies: - type: Percent value: 100 periodSeconds: 15 # 느린 Scale Down (안정성) scaleDown: stabilizationWindowSeconds: 300 policies: - type: Percent value: 10 periodSeconds: 60 --- # Vertical Pod Autoscaler (VPA) - 리소스 요청량 자동 조정 apiVersion: autoscaling.k8s.io/v1 kind: VerticalPodAutoscaler metadata: name: my-app-vpa spec: targetRef: apiVersion: apps/v1 kind: Deployment name: my-app updatePolicy: updateMode: "Auto" # 자동 Pod 재시작하며 조정 resourcePolicy: containerPolicies: - containerName: "*" minAllowed: cpu: 100m memory: 128Mi maxAllowed: cpu: 4 memory: 8Gi --- # KEDA - 이벤트 기반 스케일링 (Kafka, SQS 등) apiVersion: keda.sh/v1alpha1 kind: ScaledObject metadata: name: kafka-consumer-scaler spec: scaleTargetRef: name: kafka-consumer minReplicaCount: 1 maxReplicaCount: 50 triggers: - type: kafka metadata: bootstrapServers: kafka:9092 consumerGroup: my-group topic: my-topic lagThreshold: "100" # 메시지 지연 100개당 스케일
# Terraform으로 탄력적 인프라 구성 # Auto Scaling Group resource "aws_autoscaling_group" "web" { name = "web-asg" vpc_zone_identifier = var.private_subnets target_group_arns = [aws_lb_target_group.web.arn] min_size = 2 max_size = 20 desired_capacity = 3 # 혼합 인스턴스 정책 (온디맨드 + 스팟) mixed_instances_policy { instances_distribution { on_demand_base_capacity = 2 # 최소 2개 온디맨드 on_demand_percentage_above_base_capacity = 25 # 나머지 25% 온디맨드 spot_allocation_strategy = "capacity-optimized" } launch_template { launch_template_specification { launch_template_id = aws_launch_template.web.id version = "$Latest" } override { instance_type = "t3.medium" } override { instance_type = "t3a.medium" } override { instance_type = "m5.large" } } } # 인스턴스 새로고침 (무중단 배포) instance_refresh { strategy = "Rolling" preferences { min_healthy_percentage = 75 } } } # Target Tracking 스케일링 정책 resource "aws_autoscaling_policy" "cpu_policy" { name = "cpu-target-tracking" autoscaling_group_name = aws_autoscaling_group.web.name policy_type = "TargetTrackingScaling" target_tracking_configuration { predefined_metric_specification { predefined_metric_type = "ASGAverageCPUUtilization" } target_value = 50.0 } } # 예약 스케일링 (비용 최적화) resource "aws_autoscaling_schedule" "night" { scheduled_action_name = "scale-down-night" autoscaling_group_name = aws_autoscaling_group.web.name min_size = 1 max_size = 5 desired_capacity = 2 recurrence = "0 22 * * *" # 매일 22시 } # Aurora Serverless v2 (자동 용량 조절) resource "aws_rds_cluster" "aurora" { cluster_identifier = "my-aurora" engine = "aurora-mysql" engine_mode = "provisioned" serverlessv2_scaling_configuration { min_capacity = 0.5 # 최소 0.5 ACU max_capacity = 64 # 최대 64 ACU } } # DynamoDB 자동 스케일링 resource "aws_appautoscaling_target" "dynamodb_read" { max_capacity = 100 min_capacity = 5 resource_id = "table/${aws_dynamodb_table.main.name}" scalable_dimension = "dynamodb:table:ReadCapacityUnits" service_namespace = "dynamodb" }

Practical Conversation Example

Architecture Design Meeting
"What should we do to design for elasticity?" "First, make the application stateless. Store sessions in Redis and files in S3, and configure the DB connection pool appropriately. That way, you can freely increase and decrease instances. Put an Auto Scaling Group behind an ALB and set a Target Tracking policy based on 50% CPU."
Cost Optimization Discussion
"Doesn't using Auto Scaling end up costing more?" "It can if it's configured incorrectly, but if used properly, it actually saves money. If you Scale Out only during peak hours and Scale In at night and on weekends, the average number of instances goes down. Our service's average traffic is 30% of peak, so after applying elasticity, costs went down by 40%."
Incident Response Meeting
"Traffic suddenly spiked, but scaling didn't happen." "There are a few things we need to check. Whether the EC2 service limit has been exceeded, whether the AMI is valid, whether the subnet IPs are exhausted. Also, if the scaling cooldown time is too long, the response will be slow. To prepare for emergencies, secure a Capacity Reservation or a minimum number of On-Demand instances."
Interview Question
"What is the difference between Elasticity and Scalability?" "Scalability refers to the system's ability itself to handle increased load, and Elasticity refers to that expansion/reduction being carried out automatically according to demand. For example, if you can manually add 10 EC2 instances, it is Scalable, and if it is adjusted automatically by Auto Scaling, it is Elastic."

Take a mock interview on this topic → WIA SOOM AI Interview · Start for free

Cautions

⚠️
Stateful applications: If sessions are stored in local memory, sessions are lost on Scale Out. Use Redis, Memcached, or Sticky Session.
⚠️
Scaling delay: It takes several minutes for EC2 to boot, the application to start, and the health check to pass. If a traffic surge is expected, scale out in advance with Scheduled Scaling.
⚠️
Flapping: If the scaling threshold is configured incorrectly, Scale Out → Scale In repeats. Prevent it with the Cooldown time setting and the stabilization window.
⚠️
DB bottleneck: Even if only the application is scaled out, you can hit the DB connection limit. Consider Connection Pooling (PgBouncer, ProxySQL) or Aurora Serverless.

Related Terms

Learn More