Questions tagged with Amazon EC2 Auto Scaling
Content language: English
Sort by most recent
I'm using AWS CDK and am trying to enable the associatePublicIpAddress property for an AutoScalingGroup that's using a launch template.
My first attempt was to just set `associatePublicIpAddress: true`, but I get this error (https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts#L1526-L1528)
```typescript
// first attempt
new asg.AutoScalingGroup(this, 'ASG', {
associatePublicIpAddress: true, // here
minCapacity: 1,
maxCapacity: 1,
vpc,
vpcSubnets: {
subnetType: SubnetType.PUBLIC,
onePerAz: true,
availabilityZones: [availabilityZone],
},
mixedInstancesPolicy: {
instancesDistribution: {
spotMaxPrice: '1.00',
onDemandPercentageAboveBaseCapacity: 0,
},
launchTemplate: new LaunchTemplate(this, 'LaunchTemplate', {
securityGroup: this._securityGroup,
role,
instanceType
machineImage,
userData: UserData.forLinux(),
}),
launchTemplateOverrides: [
{
instanceType: InstanceType.of(
InstanceClass.T4G,
InstanceSize.NANO
),
},
],
},
keyName,
})
```
```typescript
// I hit this error from the CDK
if (props.associatePublicIpAddress) {
throw new Error('Setting \'associatePublicIpAddress\' must not be set when \'launchTemplate\' or \'mixedInstancesPolicy\' is set');
}
```
My second attempt was to not set `associatePublicIpAddress` and see if it gets set automatically because the AutoScalingGroup is in a public availablity zone with an internet gateway. However, it still doesn't provision a public ip address.
Has anyone been able to create an autoscaling group with a mix instance policy and an associated public ip?
Hi,
I am trying to open port 5060 in EC2 security group
But even if I add it
it's still closed
Custom UDP UDP 5060 0.0.0.0/0 –
– IPv4 Custom UDP UDP 5160 - 5161 0.0.0.0/0 –
– IPv4 Custom UDP UDP 1194 0.0.0.0/0 –
– IPv4 Custom UDP UDP 10000 - 20000 0.0.0.0/0 –
– IPv4 Custom UDP UDP 5060 - 5061
I am creating an ASG which will have a classical load balancer . The desired number of instances is 5 , I am starting the asg creation using a userdata but even after experimenting multiple times the load balancer shows unhealthy hosts,i changed the subnet type of the vpc as public but the number of healthy host for the elb remains 0 . Below is the code segment
```
Vpc vpc=new Vpc(this,"MyVPC");
AutoScalingGroup asg = AutoScalingGroup.Builder.create(this,"AutoScalingGroup").vpcSubnets(SubnetSelection.builder()
.subnetType(SubnetType.PUBLIC)
.build()).vpc(vpc).instanceType(InstanceType.of(InstanceClass.BURSTABLE2, InstanceSize.MICRO))
.machineImage(new AmazonLinuxImage()).minCapacity(1).desiredCapacity(5).maxCapacity(10).build();
asg.addUserData("#!/bin/bash\n" +
"# Use this for your user data (script from top to bottom)\n" +
"# install httpd (Linux 2 version)\n" +
"yum update -y\n" +
"yum install -y httpd\n" +
"systemctl start httpd\n" +
"systemctl enable httpd\n" +
"echo \"<h1>Hello World from $(hostname -f)</h1>\" > /var/www/html/index.html");
LoadBalancer loadbalancer=LoadBalancer.Builder.create(this,"ElasticLoadBalancer").vpc(vpc).internetFacing(Boolean.TRUE).healthCheck(software.amazon.awscdk.services.elasticloadbalancing.HealthCheck.builder().port(80).build())
.build();
loadbalancer.addTarget(asg);
ListenerPort listenerPort = loadbalancer.addListener(LoadBalancerListener.builder().externalPort(80).build());
```
Also the instances those are created by default via ASG cannot be accessed on the web(by hitting their public IP) even after changing the security groups or making them all in a public subnet they are not accessible from instance connect,neither the load balancer shows these hosts healthy
Hello,
I am working with AWS ECS capacity providers to scale out instances for jobs we run. Those jobs have a large variation in the amount of memory that is needed per ECS task. Those memory needs are set at the task and container level. We have a capacity provider that is connected to an EC2 auto scaling group (asg). The asg has the instance selection so that we specify instance attributes. Here we gave it a large range for memory and cpu, and it shows hundreds of possible instances.
When we run a small job (1GB of memory) it scales up a `m5.large` and `m6i.large` instance and the job runs. This is great because our task runs but the instance it selected is much larger than our needs. We then let the asg scale back down to 0. We then run a large job (16GB) and it begins scaling up. But it starts the same instance types as before. The instance types have 8GB of memory when our task needs double that on a single instance.
In the case of the small job I would have expected the capacity provider to scale up only 1 instance that was closer in size to the memory needs to the job (1GB). And for the larger job I would have expected the capacity provider to scale up only 1 instance that had more than 16GB of memory to accommodate the job (16GB).
Questions:
* Is there a way to get capacity providers and autoscaling groups to be more responsive to the resource needs of the pending tasks?
* Are there any configs I might have wrong?
* Am I understanding something incorrectly? Are there any resources you would point me towards?
* Is there a better approach to accomplish what I want with ECS?
* Is the behavior I outlined actually to be expected?
Thank you
Hello,
I have an ECS cluster. That has a capacity provider defined. That capacity provider was set up with an EC2 auto-scaling group that has an AWS ECS AMI. When I add a task to the cluster it recognizes it and the status is set to `PROVISIONING`. The auto-scaling group then scales up. The capacity provider shows that it scaled up in the `Current Size` column. But the instances never get listed as part of the cluster and the ECS task never gets assigned.
Does anyone have thoughts on what might be wrong such that the instances are never added to the cluster so the tasks can't utilize the instances?
Thanks
I have an EC2-backed ECS cluster which contains a ASG (using Cluster Auto Scaling) that is allowed to scale between 1 and 5 EC2 instances. There is also a service defined on this cluster which is also set to scale between 1 and 5 tasks with each task reserving almost the full resources of a single instance.
I have configured the service to scale it's desired task count depending on the size of various queues within an Amazon MQ instance which is all handled by CloudWatch alarms. The scaling of the desired task count works as expected but the ASG doesn't provision new EC2 instances to fit the amount of desired tasks unless I manually go in and change the desired capacity of the ASG. This means the new tasks never get deployed as ECS cant find any suitable instances to deploy them too.
I dont know if i'm missing something but all the doumentation I have found on ECS Auto Scaling Groups is that it should scale instances to fit the total resources requested by the desired amount of tasks.
If I manually increase the desired capacity in the ASG and add an additional task that gets deployed on that new instance then the `CapacityProviderReservation` still remains at 100%. If I then remove that second task then after a while the ASG will scale in and remove the instance that no longer has any tasks running on it which is the expected behaviour.
Any pointers would be greatly appreciated.
As a side note this is all setup using the Python CDK.
Edit: Clarified that the ASG is currently using CAS (as far as I can tell) and added details about scaling in working as expected
Many thanks
Tom
I currently have an unmanaged node group consisting of 2 worker nodes. Node1 has pods running and has enough CPU capacity to run node2's pods.
Is there a way in AWS to automatically migrate pods from node2 to node1 and scale down node2? So whenever a worker node has sufficient CPU capacity, it will be filled and the other node will be scaled down to optimize the costs of an unnecessary node?
Hi, community members,
I am new to AWS cloud service, and I want to use spot GPU instances to train DL models.
I wonder can I know the size of spot capacity pools at any time?
Since preemption may occurs due to capcaity reason, I want to know whether the change of capacity is available to users.
Thanks a lot!
Hello,
We have a application running on elasticbeanstalk that listens for client request and returns a stream segment.
We have some requirements for application:
1) Client session should be sticky (all request for some session should go to same EC2) for specified time without any changes on client side. (we can't add cookie sending via client).
As per my understanding application load balancer supports that and i enabled stickiness in load balancer.
As per my understanding load balancer generated cookie are managed by load balancer and we do not need to send cookie through client side.
2) Based on CPU utilisation we need to auto scale instances, (when CPU load > 80%) we need to scale instances +1.
Problem:-
1) When i request from multiple clients from same IP address. CPU load goes above 80% and new instance is launched.
But after sometime i see CPU load going down . does this mean that 1 of these client are now connected to new instance and load is shared.
That means stickiness is not working. Though It is not clear how to test it properly.
However sometimes when i tried to stop new instance manually . No client has got any errors.
When I stop first instance all client gets 404 error for sometime.
How to check whether stickiness is working properly ?
2) If i get stickiness to work. As per my understanding Load will not be shared by new instance. So Average CPU usage will be same.
So autoscaling will keep on launching new instance until max limit. How do i set stickiness with autoscaling feature.
I set stickiness seconds to 86400 sec (24 hours) for safe side.
Can someone please guide me how to configure stickiness and autoscaling proper way ?
I've setup SNS notifications for my auto scaling group for all events. The SNS topic is configured to the following endpoints 1) Email in JSON format to me 2) A lambda function that sends the message to Microsoft Teams Webhook.
When the notification was initially setup from Auto Scaling Group's activity notifications page, I've received the test notification on both Email and Microsoft Teams, proving that the Lambda function had executed properly. However, when I tried increasing the desired capacity of the auto scaling group to test the notification as per the guidance of [this AWS article](https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-sns-notifications.html), I did not receive any notifications even after verifying that the instance is running and passing all health checks. Consequently, when I triggered instance termination by decreasing the auto scaling group's desired capacity, I did not receive a notification on both email or Microsoft Teams.
Does anyone know why this is happening and how to troubleshoot?
I have registered SNS in AutoScalingGroup Activity notifications to receive notifications through messenger.
If 4 instances are scaled-out, 4 alarms are generated through SNS.
But I just want to know that it is scale-out. That is, I want to receive an alert only once.
How can I change the configuration?
Hi,
We have a 2TB volume m5.2xlarge instance, the root volume limit is 2TB and cannot increase the size because of size limit of it being MBR partion.
Model: Amazon Elastic Block Store (nvme)
Disk /dev/nvme0n1: 2147GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
The only way out seems https://aws.amazon.com/premiumsupport/knowledge-center/ec2-ubuntu-convert-mbr-to-gpt/
Is that the only way out here, is there a better way of increasing the limit without data loss?