- Now let's review Amazon EC2 Billing Options.
Within Amazon EC2 we have a number
of different billing options to choose from.
In this particular table as we can see
we have the On-Demand billing model.
And On-Demand essentially says that
it follows what we might call the MSRP.
If AWS advertises a particular type of machine
to cost say 20 cents an hour
then launching it with the On-Demand billing model
we will pay the 20 cents an hour.
Or per second if we're using per second billing.
Now if we need a discount, if we wanted to be able
to run applications and lower our cost
and gain access to discounts.
Then we have the reserved instance billing model
and we also have Spot Instance billing model.
And we're gonna talk about those in detail
here in just a moment.
Now the biggest thing that I wanna draw your attention to
on this table, you can always pause the video
and review this, but the biggest thing
that I want to draw your attention to is the Availability.
And I want to highlight the fact that with On-Demand
and with the Spot Market, Availability
is not guaranteed.
And so AWS, we have to keep in mind that AWS
does have an unimaginably large capacity
for compute power.
In fact at one time Gartner reported that AWS
had several times the amount of compute power
as the other cloud providers combined.
And so I think we would have a hard time even imagining
how much compute capacity AWS has.
But and it's constantly growing, AWS is constantly
adding machines to that and growing that capacity
in any particular region.
But at any one time, at the time we launched an instance
in that moment there is a finite capacity.
And so it is possible that using the On-Demand
or the Spot billing models, it is possible
that we could ask for a particular type of EC2 instance
and then the API come back and say sorry we don't
have capacity for that type machine
in that availability zone please try again later
or try a different size machine
or try a different availability zone right?
So keep that in mind that and of course
I've been using AWS for almost 10 years
and I have only ever seen that happen maybe four times.
So it is rare but it is possible.
Now with Reserved Instances, there may or may not be
an upfront payment, it all depends
on how we want to approach it.
Generally the more we pay upfront the more discount we get.
And so we can choose to purchase a Reserved Instance
by making no upfront payment.
That means that there's no capital expenditure
we get to keep more money in our pocket
but we are getting the least amount of discount right?
So the more we pay upfront the more discount we get.
We could choose to pay a little bit, we could choose to pay
make a full upfront payment right?
So by making a full upfront payment
what we are essentially doing is saying that
for the term they're available in either a one
or a three-year term.
For that term if I make a full upfront payment,
I am paying for every hour of every month
for that one or three year term.
And in doing so and making a full payment upfront
I get the most discount on that particular instance.
And so the thing to keep in mind with a Reserved Instance
is that, and that this may be a little bit challenging
to understand at first but it will become clearer
as you actually get in there and start using it.
With Reserved Instances, it's one thing
to purchase a Reserved Instance and it's another thing
to actually launch an instance right?
Purchasing a Reserved Instance and launching an instance
are two completely different things.
Just because you purchased a Reserved Instance
doesn't mean you launched one.
And just because you launched one doesn't mean
it qualifies for the discount
of the Reserved Instance right?
And so if you were to purchase a Reserved Instance
with no upfront payment or a partial upfront payment
then you are essentially committing to paying every hour
of every month even if you don't actually launch
an instance right?
You're gonna pay that fee regardless
of how many instances you're running.
And so when you purchase a Reserved Instance
and then what that essentially what that does
is create a like a billing reconciliation model.
It creates a line in the billing that says
you qualify for a discount on any instances
that you run right?
And then when you launch an instance
they have to match right?
So if you purchase a Reserved Instance for a particular
type of machine in a particular availability zone,
if you launch that same thing that same size machine
in that same AZ the billing reconciliation will apply
to the instance that you launch.
And so it's possible to gain a guaranteed availability.
This is one of the options you don't have to
when you purchase the Reserved Instance
if we choose the availability zone, then AWS
will reserve availability for us
and that's partly why we call it a Reserved Instance
because capacity is being reserved.
It means that when we actually launch the instance
we have a guarantee that we will get one.
And of course the benefit of Reserved Instances
are that we gain a significant discount
versus the On-Demand price.
So Reserved Instances are generally best
for Constant applications or a Databases.
When you look at the application that's running
and if you determine that, that application,
it will be running for more than 55
to 60% of the month.
Then that's generally where the threshold is.
Beyond 55 to 60% of the month is when you would see
a savings by using Reserved Instances as opposed
to using On-Demand.
The other billing model that we have
would be Spot Instances.
Now with the Spot, what we call the Spot Market, the fee
is based on supply and demand.
I mentioned earlier that AWS has
an enormous unimaginable capacity for generally
any type of machine in any given availability zone.
And so what AWS does is they look at the supply
that they have, the capacity that they have
for a particular size machine
and the actual demand for that machine.
And the Spot Market is essentially a way
of selling unused capacity
or giving us the ability to gain
those resources at a lower price.
And so we can see with the Spot Market
our hourly fees
be an absolute fraction of the On-Demand price.
We can save upwards of 80 maybe even 90%
as opposed to On-Demand.
And so the way that we approach the Spot Market
is that when we launch an EC2 instance and we say
I want to use a Spot Instance, keep in mind that
there's no functional difference
between On-Demand, Reserved and Spot.
These are all EC2 instances there's no functional difference
between them, the only difference is how we actually pay
for them, how we are charged right?
And so when we launch an EC2 instance
and if we want to gain access to the Spot Market discounts,
we choose that we want it as a Spot Instance
and we specify our maximum spend.
How much are we willing to spend
on that particular instance?
Now if the current market rate
according to supply and demand.
If the current market rate rises above
our maximum spend then the instance can be terminated
by AWS and essentially given to someone
who's willing to spend more money.
Now of course we do get a two-minute warning
and that's it made available to the instance
our application can poll
for that inquiry the instance metadata service
looking for that warning and when it sees that warning
it can record some kind of a checkpoint save its work
that way it can come back
and resume that work later when the market price lowers.
And so the Spot Market is generally best for Temporary work.
Work that can be interrupted like Batch Processing,
Testing and Experimentation, Billing
and Sales reports right?
Any kind of work that can be done quickly and work
that is easy to essentially checkpoint and save
and come back to you later.
The really important thing about the Spot Instances
and I think I've already mentioned this,
is that apps need to tolerate interruption.
If your application cannot tolerate interruption whatsoever
then the Spot Market is the wrong choice,
we would definitely want to look to either On-Demand
or Reserved right?
So let's keep those billing models in mind
as we move forward using EC2 and if we want to create
an environment that is cost-effective.
It's very important that we be aware
of the billing models that are available;
On-Demand, Reserved and Spot and determine which one
is most appropriate for that particular type
of work that we're doing.