Skip to content

AWS Batch with EC2 SPOT instaces charges me for a full hour even if the instance runs for 3min

0

Hi,

I've set up a system where users upload videos(I get around 70 videos a day), triggering an AWS Batch job for each video that launches an EC2 SPOT instance. The instance processes the video and then terminates automatically.

I've noticed that I'm consistently being charged for a full hour even when the actual runtime is only about 7 minutes. I've attached details of the SPOT instances for reference.

My understanding was that SPOT instances are billed per minute, not hourly. Here an attachement that shows an instance that ran for 6mins, and it shows 0.16$, Note that the on-Demand pricing for r4.xlarge instace is 0.3201 USD per Hour

Could someone please help clarify what's going on ? Thanks!

Enter image description here

asked a year ago503 views

2 Answers
1

I apologize, but there seems to be a misunderstanding in your observation. EC2 Spot Instances, like On-Demand instances, are indeed billed per second with a minimum of 60 seconds. They are not billed for a full hour if they run for less time.

Based on the information you've provided, it appears that you're looking at the total cost for the instance, not the actual billed duration. The $0.16 charge you're seeing for a 6-minute run of an r4.xlarge Spot Instance is actually consistent with per-second billing, not hourly billing.

Let's break it down:

  1. The On-Demand price for an r4.xlarge instance is $0.3201 per hour.
  2. Spot Instances typically offer significant discounts, often up to 90% off the On-Demand price.
  3. If we assume a 50% discount (which is conservative), the Spot price would be around $0.16 per hour.
  4. For a 6-minute run, that would be approximately (6/60) * $0.16 = $0.016

The $0.16 you're seeing is likely the maximum possible hourly rate for that Spot Instance, not what you were actually charged for the 6-minute run.

To verify this, I recommend checking your detailed billing report or Cost Explorer, which will show the actual runtime and charges for each instance. You should see that you're only being charged for the actual runtime, not for a full hour.

If you're still concerned, you might want to:

  1. Double-check your AWS Batch configuration to ensure it's set up to use Spot Instances correctly.
  2. Verify in your billing details that you're actually being charged for full hours and not just seeing the potential maximum hourly rate.
  3. Contact AWS Support if you find any discrepancies in your actual billing.

Remember, AWS Batch is designed to work well with Spot Instances, and when configured correctly, it should take advantage of the per-second billing to optimize your costs.
Sources
Billing on Ec2 instance for a particular time | AWS re:Post
Billing for interrupted Spot Instances - Amazon Elastic Compute Cloud

answered a year ago

EXPERT

reviewed a year ago

0

Yes, spot instances are not charged hourly, it's billed by seconds after the first 60 seconds. Spot savings summary may not show the actual data. It is better if you can confirm the actual charges from Cost Explorer. If the EC2 is tagged or if you have only a few EC2s, you can easily identify the actual cost incurred by this EC2 in the Cost Explorer.

EXPERT

answered a year ago

EXPERT

reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.