Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
What's a simple way for limiting runtime of an Amazon EC2 instance? I'm getting runaway instances now and then which don't shutdown for various reasons. These can cost a fortune. Is there some sort of commandline flag which says the equivalent of "shut this instance down after 5 hours"?
AFAIK the Auto-Scaling service doesn't have this ability directly.
EDIT: Although if you wanted you could create a group for auto-scaling, and set it to zero instances at a scheduled time - that way once that time is reached, all instances in the group would be shut down.
But if you have any kind of automation involved for starting and stopping these instances, you can use a cron job, Windows scheduled task, or add a delay in whatever script you're using to launch these instances to execute the ec2 instance shutdown command after a specified time period:
PROMPT> ec2-stop-instances i-10a64379
or equivalently construct an HTTP request of the form:
https://ec2.amazonaws.com/?Action=StopInstances&InstanceId.1=i-10a64379&AUTHPARAMS
Another option you have would be to create the task on the AMI itself, so that whenever the instance was started it would shut itself down after 5 hours - this might be cleaner than an outside computer being responsible for it.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
How can I get exact status of AWS EC2 instance?
The instance status tells ok but actually I can't login the server (via SSH).
And Cloudwatch result is like this.
This is the period of when the server is gone.
The server didn't come back until I only stop/restart instance. (reboot didn't make server working)
How and where can I check the status of instance?
And what is the reason of this?
Thank you in advance.
you can use aws cli to see the current status of your EC2 instance using the command:
aws ec2 describe-instance-status --instance-id i-1234567890abcdef0
Because cloudwatch is showing break in graph which means instance was not sending CPU utilization to it for that period of time. Generally happens when there is some load on the applications running on EC2 instance, consumes whole available memory of the instance to halt all the instance processes.
Actual instance status sometimes takes time to reflect on UI when things goes wrong with it.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Let's assume the standard data engineering problem:
every day at 3.00 AM connect to an API
download data
store them in a data lake
Let's say there is a python script that does the API hit and storage, but that is not that important.
Ideally I would like to have some service that comes alive, runs this script and kills itself... So far, I thought about those possibilities (using AWS services):
(AWS) Lambda - FaaS, ideal match for the usecase. But there is a problem: bandwith of the function (limited RAM/CPU) and timeout of 5 mins.
(AWS) Lambda + Step Functions + range requests: fire multiple Lambdas in parallel, each downloading a part of the file. Coordination via Step Functions. It solves the issue of 1) but it feels very complicated.
(AWS EC2) Static VM: classic approach: I have a VM, I have a python interpreter, I have a cron -> every night I run the script. Or every night, I can trigger a build of new EC2 machine using CloudFormation, run the script and then kill it. Problems: feels very old-school - like there has to be a better way to do it.
(AWS ECS) Docker: I have very little experience with docker. Probably similar to the VM case, but feels more versatile/controllable. I don't know if there is a good orchestrator for this kind of job and how easy it is (firing docker and killing it)
How I see it:
Exactly what I would like to have, but it is not good for downloading big data because of the resource constrains.
Complicated workaround for 1)
Feels very oldschool, additional devops expenses
Don't know a lot about this topic, feels like the current state-of-art
My question is: what is the current state-of-art for this kind of job? What services are useful and what are the experiences with them?
A variation on #3... Launch a Linux Amazon EC2 instance with a User Data script, with Shutdown Behavior set to Terminate.
The User Data script performs the download and copies the data to Amazon S3. It then executes sudo shutdown -h to turn off the instance. (Or, if the script is complex, the User Data script can download a program from an S3 bucket, then execute it.)
Linux EC2 instances are now charged per-second, so think of it like a larger version of Lambda that has more disk space and does not have a 5-minute limit.
There is no need to use CloudFormation to launch the instance because then you'd just need to delete the CloudFormation stack. Instead, just launch the instance directly with the necessary parameters. You could even create a Launch Template with the parameters and then simply launch an instance using the Launch Template.
You could even add a few smarts to the process and launch the instance using Spot Pricing (set the bid price to normal On-Demand pricing, since worst case you'll just pay the normal price). If the Spot Instance won't launch due to insufficient spare capacity, then launch an On-Demand instance instead.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
Details: I have a web app on Elastic Beanstalk (web server) and I need several cronjobs to be executed. These cronjobs must connect to AWS RDS. For this, I created an Elastic Beanstalk Worker but I must pay for the worker instance to be available all day when cronjobs only need some minutes.
You can use AWS Lamda with scheduled events for this. To connect to RDS you need to place the Lambda function inside the VPC which RDS resides with required network accessibility.
This will work for short running jobs which does not exceed 5 minutes, which is the AWS Lambda maximum execution time limit.
For long running jobs you can start and stop a EC2 with AWS Lambda scheduled events, using AWS EC2 SDK.
Alternatively you can also use AWS batch scheduled with EC2 spot instances to lower the costs.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
I'm hosting several websites on AWS and got the charge of On Demand Linux t2.micro Instance Hour for 690hrs. I've totally no idea about when I asked for this on demand instance. Is it like my free tier instance has used up so it automatically cost the on demand instance?
Also another question is how can I know which website/ec2 instance actually cost me the on demand instance hour. I strongly believe that none of my website has large traffic.
Complete information about your billing in details you may receive on a page https://console.aws.amazon.com/billing/home
Also, check the following - have you launched one more t2.micro instance? You have possibility to use free t2.micro instance for 750 hours per month, it means that you may have only one non-stop working instance per month.
Please, check, maybe you have set up autoscaling group that launched one more instance for you and forgot to disable it?
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I have terminated all my instances in AWS, but didn't receive any information that my service of the
m1.small
was shut down.
I was wondering if I will still be charged by the AWS?
You will be charged for the time that those instances were up.
You won't be charged any more for those instances if you have terminated them.
If you want to be absolutely certain and will not need the AWS services anymore, you can always close your AWS account.
Pricing is per instance-hour consumed for each instance, from the time an instance is launched until it is terminated or stopped. Each partial instance-hour consumed will be billed as a full hour.
Amazon Pricing Details
When it is terminated or stopped, there will be no charge.