📜 ⬆️ ⬇️

AWS Insight: Reservations for EC2 - how it works

Hello! image

As you know, one of the basic rules for using cloud services is to optimize everything, and especially the financial side of the issue. Amazon Web Services has 3 basic methods for optimizing service costs:

Today I will talk about reservations in EC2, how, what and why it must be done.

Reservation is a prepayment of server capacity, which allows to significantly reduce the cost of these same capacities. There are 3 types of reservations:

The reservation is bought once a year or 3 years, i.e. reservation is:

Economic justification


The basic principle of choosing the desired reservation: the longer the server works, the more expensive the reservation is for it to buy. Let's do an experiment. Take one server size M1.XLarge and run it. Depending on the number of hours per day that the server will work, we can calculate the amount that will need to be paid for it for 1 year and 3 years. So, pricing for today:
Usage model1 year3 years
PrepaymentHourlyPrepaymentHourly
On-demand$ 0.52$ 0.52
Light Utilization Reservation$ 552$ 0.392$ 850.40$ 0.312
Medium Utilization Reservation$ 1280$ 0.248$ 2000$ 0.20
Hard Utilization Reservation$ 1,560$ 0.20$ 2400$ 0.16

Annual test

The annual cost is calculated by the following formula:
')
HS = H * 365 * C + P , where

HS - Annual Cost
H - the number of hours per day that the machine is running.
C - cost per hour
- reservation cost

Take the “1 year” column from pricing and build a table of prices depending on the hours that the instance was launched:
One year, $
Hours per dayOn demandLightMediumHard
one189.80665.881,350.081,606.72
2379.60779.761,420.161,653.44
3569.40893.641,490.241,700.16
four759.201,007.521,560.321,746.88
five949.001,121.401,630.401,793.60
61,138.801,235.281,700.481,840.32
71,328.601,349.161,770.561,887.04
eight1,518.401,463.041,840.641,933.76
91,708.201,576.921,910.721,980.48
ten1,898.001,690.801,980.802,027.20
eleven2,087.801,804.682,050.882,073.92
122,277.601,918.562,120.962,120.64
132,467.402,032.442,191.042,167.36
142,657.202,146.322,261.122,214.08
152,847.002,260.202,331.202,260.80
sixteen3,036.802,374.082,401.282,307.52
173,226.602,487.962,471.362,354.24
183,416.402,601.842,541.442,400.96
nineteen3,606.202,715.722,611.522,447.68
203,796.002,829.602,681.602,494.40
213,985.802,943.482,751.682,541.12
224,175.603,057.362,821.762,587.84
234,365.403,171.242,891.842,634.56
244,555.203,285.122,961.922,681.28

Based on this table, we construct a graph:
image

As you can see, up to 7 hours a day, inclusive, the cheapest option is On-Demand, i.e. no prepayments. If the server is used more than eight, then it makes sense to buy Light Utilization Reservation.

Before this research, I thought that everything has its place, but notice that after the 15th hour it is more advantageous to use Hard Utilization Reservation , and Medium - neither there nor here. UPD at the bottom of the post.

Conclusion

When using the machine from one to 7 hours a day, it is better not to make prepayments . From 7 to 15 - use Light Utilization Reservation . If the car runs more than 15 hours a day, then it will be better to buy Hard Utilization Reservation .

Three year test

The same test, only a three-year reservation. Table of expenses:
Three Years, $
Hours per dayOn demandLightMediumHard
one569.401,121.962,166.442,513.88
21,138.801,393.522,332.882,627.76
31,708.201,665.082,499.322,741.64
four2,277.601,936.642,665.762,855.52
five2,847.002,208.202,832.202,969.40
63,416.402,479.762,998.643,083.28
73,985.802,751.323,165.083,197.16
eight4,555.203,022.883,331.523,311.04
95,124.603,294.443,497.963,424.92
ten5,694.003,566.003,664.403,538.80
eleven6,263.403,837.563,830.843,652.68
126,832.804,109.123,997.283,766.56
137,402.204,380.684,163.723,880.44
147,971.604,652.244,330.163,994.32
158,541.004,923.804,496.604,108.20
sixteen9,110.405,195.364,663.044,222.08
179,679.805,466.924,829.484,335.96
1810,249.205,738.484,995.924,449.84
nineteen10,818.606,010.045,162.364,563.72
2011,388.006,281.605,328.804,677.60
2111,957.406,553.165,495.244,791.48
2212,526.806,824.725,661.684,905.36
2313,096.207,096.285,828.125,019.24
2413,665.607,367.845,994.565,133.12

Chart by table:
image

findings

In the three-year period, the use of reservations is not justified if the instance works up to 3 hours per day. From 3 to 10 - it is better to use Light , after 10 hours a day - Hard Utilization Reservation .

Apparently, Medium is an average option in both cases, when it is more profitable than Light, but on singe pores it is cheaper than Hard reservations. It seems to be her only purpose.

Conclusion


So, looking at the results of calculations, it is clearly visible that the reason for using the reservation is simply necessary! With continuous use of the machine for one year in our example, you save:

($ 4,555.20 - $ 2,681.28) / $ 4,555.20 * 100% = 41%

For 3 years:

($ 13,665.60 - $ 5,133.12) / $ 13,665.60 * 100% = 62%

Impressive numbers, right?

UPD: Thanks to m_z and his comment .

It turns out that by choosing Heavy Utilization Reservation we will pay for the instance cost, even if it doesn't work, i.e. its price per year will be direct:
image

Well, the logic takes its own way: at first it's cheaper to have On-Demand instances, then Light Reservation, Medium Reservation and Heavy.

It is recommended that you create a template in the spreadsheet editor and for each type of instance you use to work out a profitable reservation policy.

Source: https://habr.com/ru/post/162345/


All Articles