1 00:00:06,730 --> 00:00:10,470 - Now let's review Amazon EC2 Billing Options. 2 00:00:10,470 --> 00:00:13,240 Within Amazon EC2 we have a number 3 00:00:13,240 --> 00:00:16,250 of different billing options to choose from. 4 00:00:16,250 --> 00:00:19,090 In this particular table as we can see 5 00:00:19,090 --> 00:00:21,683 we have the On-Demand billing model. 6 00:00:22,640 --> 00:00:25,050 And On-Demand essentially says that 7 00:00:25,050 --> 00:00:28,290 it follows what we might call the MSRP. 8 00:00:28,290 --> 00:00:32,720 If AWS advertises a particular type of machine 9 00:00:32,720 --> 00:00:35,590 to cost say 20 cents an hour 10 00:00:35,590 --> 00:00:38,780 then launching it with the On-Demand billing model 11 00:00:38,780 --> 00:00:41,550 we will pay the 20 cents an hour. 12 00:00:41,550 --> 00:00:45,363 Or per second if we're using per second billing. 13 00:00:46,200 --> 00:00:50,160 Now if we need a discount, if we wanted to be able 14 00:00:50,160 --> 00:00:52,550 to run applications and lower our cost 15 00:00:52,550 --> 00:00:54,550 and gain access to discounts. 16 00:00:54,550 --> 00:00:59,400 Then we have the reserved instance billing model 17 00:01:00,400 --> 00:01:04,350 and we also have Spot Instance billing model. 18 00:01:04,350 --> 00:01:06,220 And we're gonna talk about those in detail 19 00:01:06,220 --> 00:01:08,250 here in just a moment. 20 00:01:08,250 --> 00:01:11,040 Now the biggest thing that I wanna draw your attention to 21 00:01:11,040 --> 00:01:13,670 on this table, you can always pause the video 22 00:01:13,670 --> 00:01:17,170 and review this, but the biggest thing 23 00:01:17,170 --> 00:01:20,600 that I want to draw your attention to is the Availability. 24 00:01:20,600 --> 00:01:24,590 And I want to highlight the fact that with On-Demand 25 00:01:26,060 --> 00:01:30,770 and with the Spot Market, Availability 26 00:01:30,770 --> 00:01:32,623 is not guaranteed. 27 00:01:33,620 --> 00:01:38,010 And so AWS, we have to keep in mind that AWS 28 00:01:38,010 --> 00:01:43,010 does have an unimaginably large capacity 29 00:01:43,110 --> 00:01:44,600 for compute power. 30 00:01:44,600 --> 00:01:48,200 In fact at one time Gartner reported that AWS 31 00:01:48,200 --> 00:01:52,020 had several times the amount of compute power 32 00:01:52,020 --> 00:01:55,130 as the other cloud providers combined. 33 00:01:55,130 --> 00:01:58,010 And so I think we would have a hard time even imagining 34 00:01:58,010 --> 00:02:01,710 how much compute capacity AWS has. 35 00:02:01,710 --> 00:02:05,300 But and it's constantly growing, AWS is constantly 36 00:02:05,300 --> 00:02:08,850 adding machines to that and growing that capacity 37 00:02:08,850 --> 00:02:10,633 in any particular region. 38 00:02:11,480 --> 00:02:15,710 But at any one time, at the time we launched an instance 39 00:02:15,710 --> 00:02:18,420 in that moment there is a finite capacity. 40 00:02:18,420 --> 00:02:22,850 And so it is possible that using the On-Demand 41 00:02:22,850 --> 00:02:27,170 or the Spot billing models, it is possible 42 00:02:27,170 --> 00:02:31,620 that we could ask for a particular type of EC2 instance 43 00:02:31,620 --> 00:02:35,370 and then the API come back and say sorry we don't 44 00:02:35,370 --> 00:02:38,920 have capacity for that type machine 45 00:02:38,920 --> 00:02:42,010 in that availability zone please try again later 46 00:02:42,010 --> 00:02:44,020 or try a different size machine 47 00:02:44,020 --> 00:02:47,330 or try a different availability zone right? 48 00:02:47,330 --> 00:02:49,250 So keep that in mind that and of course 49 00:02:49,250 --> 00:02:52,860 I've been using AWS for almost 10 years 50 00:02:52,860 --> 00:02:57,350 and I have only ever seen that happen maybe four times. 51 00:02:57,350 --> 00:03:00,200 So it is rare but it is possible. 52 00:03:00,200 --> 00:03:04,900 Now with Reserved Instances, there may or may not be 53 00:03:04,900 --> 00:03:06,470 an upfront payment, it all depends 54 00:03:06,470 --> 00:03:08,670 on how we want to approach it. 55 00:03:08,670 --> 00:03:13,670 Generally the more we pay upfront the more discount we get. 56 00:03:13,840 --> 00:03:18,160 And so we can choose to purchase a Reserved Instance 57 00:03:18,160 --> 00:03:20,470 by making no upfront payment. 58 00:03:20,470 --> 00:03:23,750 That means that there's no capital expenditure 59 00:03:23,750 --> 00:03:25,730 we get to keep more money in our pocket 60 00:03:25,730 --> 00:03:29,160 but we are getting the least amount of discount right? 61 00:03:29,160 --> 00:03:32,800 So the more we pay upfront the more discount we get. 62 00:03:32,800 --> 00:03:35,920 We could choose to pay a little bit, we could choose to pay 63 00:03:35,920 --> 00:03:38,130 make a full upfront payment right? 64 00:03:38,130 --> 00:03:40,310 So by making a full upfront payment 65 00:03:40,310 --> 00:03:43,210 what we are essentially doing is saying that 66 00:03:43,210 --> 00:03:45,980 for the term they're available in either a one 67 00:03:45,980 --> 00:03:47,670 or a three-year term. 68 00:03:47,670 --> 00:03:50,470 For that term if I make a full upfront payment, 69 00:03:50,470 --> 00:03:54,610 I am paying for every hour of every month 70 00:03:54,610 --> 00:03:57,330 for that one or three year term. 71 00:03:57,330 --> 00:04:00,810 And in doing so and making a full payment upfront 72 00:04:00,810 --> 00:04:05,060 I get the most discount on that particular instance. 73 00:04:05,060 --> 00:04:08,040 And so the thing to keep in mind with a Reserved Instance 74 00:04:08,040 --> 00:04:12,030 is that, and that this may be a little bit challenging 75 00:04:12,030 --> 00:04:14,800 to understand at first but it will become clearer 76 00:04:14,800 --> 00:04:17,180 as you actually get in there and start using it. 77 00:04:17,180 --> 00:04:19,870 With Reserved Instances, it's one thing 78 00:04:19,870 --> 00:04:23,230 to purchase a Reserved Instance and it's another thing 79 00:04:23,230 --> 00:04:25,860 to actually launch an instance right? 80 00:04:25,860 --> 00:04:28,210 Purchasing a Reserved Instance and launching an instance 81 00:04:28,210 --> 00:04:31,170 are two completely different things. 82 00:04:31,170 --> 00:04:34,010 Just because you purchased a Reserved Instance 83 00:04:34,010 --> 00:04:36,000 doesn't mean you launched one. 84 00:04:36,000 --> 00:04:38,170 And just because you launched one doesn't mean 85 00:04:38,170 --> 00:04:39,970 it qualifies for the discount 86 00:04:39,970 --> 00:04:42,160 of the Reserved Instance right? 87 00:04:42,160 --> 00:04:45,510 And so if you were to purchase a Reserved Instance 88 00:04:45,510 --> 00:04:49,810 with no upfront payment or a partial upfront payment 89 00:04:49,810 --> 00:04:54,810 then you are essentially committing to paying every hour 90 00:04:55,110 --> 00:04:58,910 of every month even if you don't actually launch 91 00:04:58,910 --> 00:05:00,130 an instance right? 92 00:05:00,130 --> 00:05:02,770 You're gonna pay that fee regardless 93 00:05:02,770 --> 00:05:05,200 of how many instances you're running. 94 00:05:05,200 --> 00:05:08,800 And so when you purchase a Reserved Instance 95 00:05:08,800 --> 00:05:11,400 and then what that essentially what that does 96 00:05:11,400 --> 00:05:15,110 is create a like a billing reconciliation model. 97 00:05:15,110 --> 00:05:17,810 It creates a line in the billing that says 98 00:05:17,810 --> 00:05:21,100 you qualify for a discount on any instances 99 00:05:21,100 --> 00:05:23,000 that you run right? 100 00:05:23,000 --> 00:05:25,770 And then when you launch an instance 101 00:05:25,770 --> 00:05:27,380 they have to match right? 102 00:05:27,380 --> 00:05:30,660 So if you purchase a Reserved Instance for a particular 103 00:05:32,110 --> 00:05:35,570 type of machine in a particular availability zone, 104 00:05:35,570 --> 00:05:39,620 if you launch that same thing that same size machine 105 00:05:39,620 --> 00:05:43,690 in that same AZ the billing reconciliation will apply 106 00:05:43,690 --> 00:05:45,463 to the instance that you launch. 107 00:05:47,020 --> 00:05:51,693 And so it's possible to gain a guaranteed availability. 108 00:05:52,580 --> 00:05:54,780 This is one of the options you don't have to 109 00:05:55,970 --> 00:05:58,440 when you purchase the Reserved Instance 110 00:05:58,440 --> 00:06:02,570 if we choose the availability zone, then AWS 111 00:06:02,570 --> 00:06:05,280 will reserve availability for us 112 00:06:05,280 --> 00:06:08,140 and that's partly why we call it a Reserved Instance 113 00:06:08,140 --> 00:06:10,470 because capacity is being reserved. 114 00:06:10,470 --> 00:06:13,450 It means that when we actually launch the instance 115 00:06:13,450 --> 00:06:15,583 we have a guarantee that we will get one. 116 00:06:17,210 --> 00:06:20,810 And of course the benefit of Reserved Instances 117 00:06:20,810 --> 00:06:23,770 are that we gain a significant discount 118 00:06:23,770 --> 00:06:26,010 versus the On-Demand price. 119 00:06:26,010 --> 00:06:28,810 So Reserved Instances are generally best 120 00:06:28,810 --> 00:06:33,800 for Constant applications or a Databases. 121 00:06:33,800 --> 00:06:36,280 When you look at the application that's running 122 00:06:36,280 --> 00:06:38,760 and if you determine that, that application, 123 00:06:38,760 --> 00:06:43,760 it will be running for more than 55 124 00:06:43,920 --> 00:06:46,000 to 60% of the month. 125 00:06:46,000 --> 00:06:49,800 Then that's generally where the threshold is. 126 00:06:49,800 --> 00:06:54,130 Beyond 55 to 60% of the month is when you would see 127 00:06:54,130 --> 00:06:58,260 a savings by using Reserved Instances as opposed 128 00:06:58,260 --> 00:07:00,230 to using On-Demand. 129 00:07:00,230 --> 00:07:01,840 The other billing model that we have 130 00:07:01,840 --> 00:07:03,593 would be Spot Instances. 131 00:07:04,480 --> 00:07:09,390 Now with the Spot, what we call the Spot Market, the fee 132 00:07:09,390 --> 00:07:11,600 is based on supply and demand. 133 00:07:11,600 --> 00:07:14,370 I mentioned earlier that AWS has 134 00:07:14,370 --> 00:07:18,600 an enormous unimaginable capacity for generally 135 00:07:18,600 --> 00:07:22,570 any type of machine in any given availability zone. 136 00:07:22,570 --> 00:07:27,080 And so what AWS does is they look at the supply 137 00:07:27,080 --> 00:07:29,620 that they have, the capacity that they have 138 00:07:29,620 --> 00:07:31,810 for a particular size machine 139 00:07:31,810 --> 00:07:34,990 and the actual demand for that machine. 140 00:07:34,990 --> 00:07:37,880 And the Spot Market is essentially a way 141 00:07:37,880 --> 00:07:41,550 of selling unused capacity 142 00:07:41,550 --> 00:07:43,630 or giving us the ability to gain 143 00:07:45,100 --> 00:07:47,750 those resources at a lower price. 144 00:07:47,750 --> 00:07:52,750 And so we can see with the Spot Market 145 00:07:53,040 --> 00:07:54,500 our hourly fees 146 00:07:54,500 --> 00:07:58,210 be an absolute fraction of the On-Demand price. 147 00:07:58,210 --> 00:08:01,690 We can save upwards of 80 maybe even 90% 148 00:08:01,690 --> 00:08:03,343 as opposed to On-Demand. 149 00:08:06,390 --> 00:08:09,740 And so the way that we approach the Spot Market 150 00:08:09,740 --> 00:08:12,230 is that when we launch an EC2 instance and we say 151 00:08:12,230 --> 00:08:15,480 I want to use a Spot Instance, keep in mind that 152 00:08:15,480 --> 00:08:16,890 there's no functional difference 153 00:08:16,890 --> 00:08:19,963 between On-Demand, Reserved and Spot. 154 00:08:20,900 --> 00:08:24,170 These are all EC2 instances there's no functional difference 155 00:08:24,170 --> 00:08:27,480 between them, the only difference is how we actually pay 156 00:08:27,480 --> 00:08:29,640 for them, how we are charged right? 157 00:08:29,640 --> 00:08:32,370 And so when we launch an EC2 instance 158 00:08:32,370 --> 00:08:36,630 and if we want to gain access to the Spot Market discounts, 159 00:08:36,630 --> 00:08:40,970 we choose that we want it as a Spot Instance 160 00:08:40,970 --> 00:08:43,250 and we specify our maximum spend. 161 00:08:43,250 --> 00:08:44,940 How much are we willing to spend 162 00:08:44,940 --> 00:08:46,513 on that particular instance? 163 00:08:47,440 --> 00:08:52,440 Now if the current market rate 164 00:08:52,760 --> 00:08:54,573 according to supply and demand. 165 00:08:55,480 --> 00:08:59,370 If the current market rate rises above 166 00:08:59,370 --> 00:09:03,410 our maximum spend then the instance can be terminated 167 00:09:03,410 --> 00:09:06,170 by AWS and essentially given to someone 168 00:09:06,170 --> 00:09:08,020 who's willing to spend more money. 169 00:09:08,020 --> 00:09:10,340 Now of course we do get a two-minute warning 170 00:09:10,340 --> 00:09:12,730 and that's it made available to the instance 171 00:09:12,730 --> 00:09:14,340 our application can poll 172 00:09:14,340 --> 00:09:17,710 for that inquiry the instance metadata service 173 00:09:17,710 --> 00:09:20,800 looking for that warning and when it sees that warning 174 00:09:20,800 --> 00:09:24,780 it can record some kind of a checkpoint save its work 175 00:09:24,780 --> 00:09:26,060 that way it can come back 176 00:09:26,060 --> 00:09:31,060 and resume that work later when the market price lowers. 177 00:09:33,100 --> 00:09:38,100 And so the Spot Market is generally best for Temporary work. 178 00:09:38,810 --> 00:09:42,330 Work that can be interrupted like Batch Processing, 179 00:09:42,330 --> 00:09:45,640 Testing and Experimentation, Billing 180 00:09:45,640 --> 00:09:47,060 and Sales reports right? 181 00:09:47,060 --> 00:09:51,140 Any kind of work that can be done quickly and work 182 00:09:51,140 --> 00:09:55,880 that is easy to essentially checkpoint and save 183 00:09:55,880 --> 00:09:58,010 and come back to you later. 184 00:09:58,010 --> 00:10:00,990 The really important thing about the Spot Instances 185 00:10:00,990 --> 00:10:02,390 and I think I've already mentioned this, 186 00:10:02,390 --> 00:10:06,520 is that apps need to tolerate interruption. 187 00:10:06,520 --> 00:10:11,520 If your application cannot tolerate interruption whatsoever 188 00:10:11,600 --> 00:10:13,980 then the Spot Market is the wrong choice, 189 00:10:13,980 --> 00:10:17,220 we would definitely want to look to either On-Demand 190 00:10:17,220 --> 00:10:18,440 or Reserved right? 191 00:10:18,440 --> 00:10:21,060 So let's keep those billing models in mind 192 00:10:21,060 --> 00:10:25,410 as we move forward using EC2 and if we want to create 193 00:10:26,990 --> 00:10:30,020 an environment that is cost-effective. 194 00:10:30,020 --> 00:10:32,330 It's very important that we be aware 195 00:10:32,330 --> 00:10:35,000 of the billing models that are available; 196 00:10:35,000 --> 00:10:38,820 On-Demand, Reserved and Spot and determine which one 197 00:10:38,820 --> 00:10:41,620 is most appropriate for that particular type 198 00:10:41,620 --> 00:10:42,870 of work that we're doing.