Are EC2 instances charged when starting/stopping? - amazon-web-services

I am trying to host an application on AWS. I am comparing hosting it on Lambda and on EC2, and was thinking about "sides costs".
Indeed with lambda I am charged for cold starts, and I was wondering if when starting/stopping an EC2 instance you're charged for this time, since my instance will take something between 1 or 2 minutes to start and stop.
Since I plan to start and shut down quite a lot of instances frequently it would represent a non negligible cost for me if I am charged for this period.

You pay when the instance is in RUNNING state. From docs:
If your instance is billed by the second, then you're billed for a minimum of 60 seconds each time a new instance is started—that is, when the instance enters the running state.
This is independent of your application on the instance.

Related

How does AWS know to apply reserved instances price to the EC2 running 24/7 and not part time?

Our organization has many EC2 on-demand instances. We never looked at the reserved instance pricing because we thought we had to pay up-front. But I see that now there are reserved instance with no up-front costs, but monthly.
This looks like what we need to keep costs down, but I am unclear as to how the reserved instance pricing is applied.
For example, we have 10 t3.medium ec2 instance. Let's say that there are 6 always running 24/7, but the other 4 are not running 24/7, they are turned off when not in use.
If I buy a reserved instance for t3.medium, how does AWS know to apply it to the instances running 24/7 and not part time?
For example, we have 10 t3.medium ec2 instance. Let's say that there
are 6 always running 24/7, but the other 4 are not running 24/7, they
are turned off when not in use.
If I buy a reserved instance for t3.medium, how does AWS know to apply
it to the instances running 24/7 and not part time?
Amazon doesn't apply reserved pricing to a specific instance at all. It basically just applies reserved pricing to your bill. It's like a discount at the time your bill is processed. If you have reserved pricing for N instances, and you have at least N instances running 24/7 reflected in your bill, then the reserved pricing gets applied to those N instances.
Amazon doesn't really care if you are running a single specific instance 24/7, or deleting and recreating instances once a minute. In the end it's just the total number of seconds you have a specific type of instance running each month that they care about, and bill you for.
Be aware that when you setup instance reservations it is actually a capacity reservation. You are telling Amazon you are committing to running this type of instance 24/7 for either 1 year or 3 years. By letting Amazon know this, it helps with their capacity planning, and in return they give you a cost discount. But it also means that they are going to charge you for that reserved capacity even if you don't actually have that instance running 24/7.

Difference between STOP instance and SUSPEND instance in Google Cloud Platform

I was created an instance in Google Cloud Platform. I use this instance 2 to 4 days in a week. So, I want to close my instance for rest of the days to save my billing charges. So, what is best option for me. Stop the instance or Suspend the instance? What is the difference between them?
Please have a look at the documentation Suspending and resuming an instance:
Suspending an instance differs from stopping an instance in the following ways:
Suspended instances preserve the guest OS memory, device state, and application state.
Google charges for the storage necessary to save instance memory.
You can only suspend an instance for up to 60 days. After 60 days, the instance is automatically moved to the TERMINATED state.
and at the article Stopping and starting an instance:
Instances that are in a TERMINATED state are not charged for
per-second usage and do not count toward your regional CPU quota, so
you can choose to stop instances that you are not using, saving you
from being charged for instances that aren't active. After you are
ready, you can come back and start the same instances again, with the
same instance properties, metadata, and resources.
Your instances are not charged for per-second usage while in the
TERMINATED state but any resources attached to the virtual machine,
such as static IPs and persistent disks, are charged until they are
deleted.
As a result, it's better to stop your VM instance, to avoid extra changes for keeping instance's memory.
In addition, please have a look at the article Save money by stopping and starting Compute Engine instances on schedule.

Can multiple AWS Data Pipelines share an EC2 resource?

I have 10 pipelines that run at least twice per hour each and use an EC2 resource to copy data from an external MySQL server to S3.
My preference is to let the pipelines launch their own resources (as opposed to use a long-running instance launched manually), but I don't want 10 EC2 instances running continuously (EC2 instances are billed per hour) just to perform a 1-minute job twice an hour. Is there a way to have the pipelines share a launched instance?
You could have a long running EC2 instance combined with Task runner.
[...] In this pattern, you assume almost complete control over which
resources are used and how they are managed [...].
Also, EC2 instances are not billed per hour: https://aws.amazon.com/blogs/aws/new-per-second-billing-for-ec2-instances-and-ebs-volumes/
Not to be that guy lol but Google offers per minute charges (actually first 10 minutes are billed, then per minute)

AWS spot instances - charged for self-terminated partial hours?

I want to start a micro instance to run a really small task (less than 5 minutes long) and then terminate itself. I plan to use spot instances (because it's cheaper), but I'm open to other alternatives.
If I do that, will I be charged for the fraction of the hour? Or will I be charged as if the instance was used for the entire hour?
Also, will I be charged for the boot and termination time? or only for the time the instance was active?
I found on AWS FAQs a question that says:
- Will I be charged if my Spot Instance is terminated by Amazon EC2 before the hour is up?-
No. If the Spot Instance is terminated by Amazon EC2, you will not be charged for a partial hour of usage. However, if you terminate the instance yourself, you will be charged for any hour in which the instance ran.
In my case, the instance will be terminated by me, so I'm not sure what they meant by saying "if you terminate the instance yourself, you will be charged for any hour in which the instance ran".
Yes if you terminate the instance in fraction of hour you will be charged for whole hour. Let me give you an example.
Lets say you are using a instance for 1 Hr 20 Min.
So if AWS terminates that instance you will be charged only for 1 Hr.
But if you terminate that instance you will be charged for 2 hrs.

What does it cost to start and immediately terminate an Amazon EC2 instance?

For example the list price for a nano instance is $0.0065 per Hour.
If I start and immediately terminate a nano instance, did it cost me $0.0065?
The reason this question relates to programming is because I am programmatically launching instances and I want to know if it's going to cost alot or be a trivial expense if my code does live launching as I'm testing.
For "on demand" EC2
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.
See https://aws.amazon.com/ec2/pricing/
This used to be the case...but now (as of Oct 2021)
Each partial instance-hour consumed is billed per-second for instances launched in Linux, Windows, or Windows with SQL Enterprise, SQL Standard, or SQL Web instances
If your instance is billed by the second, then you're billed for a minimum of 60 seconds each time a new instance is started—that is, when the instance enters the running state
Some instances do still have a minimum charge period of one hour, but in the case of the OP's question the answwer is now 1 minute minimum
See https://aws.amazon.com/premiumsupport/knowledge-center/ec2-instance-hour-billing/