{"id":"l-aws-3-1","courseId":"aws-cloud-foundations","lang":"en","kind":"lesson","summary":"Read an EC2 instance type name, pick a purchasing option for a workload’s shape, and decide when AWS Lambda’s per-request model beats a server that runs all month.","html":"<p>Lantern’s old server did everything: served pages, handled RSVPs, resized posters, ran a nightly export. On AWS each of those jobs can run on the compute model that fits its shape. The two you will use most are <strong>Amazon EC2</strong>, virtual servers you rent by the second, and <strong>AWS Lambda</strong>, functions that run only when something calls them.</p>\n<h2 id=\"sec-1\" tabindex=\"-1\">Amazon EC2: a server, rented</h2>\n<p>An EC2 <strong>instance</strong> is a virtual machine. You choose an operating system image (an AMI, such as Amazon Linux 2023), an <strong>instance type</strong>, a network and storage, and AWS starts it in the Availability Zone you pick. Everything above the hypervisor is yours: OS patches, the runtime, the app, and scaling.</p>\n<h3 id=\"sec-2\" tabindex=\"-1\">Reading an instance type</h3>\n<p>Instance type names are dense but regular. Take <code dir=\"ltr\">m7g.large</code>:</p>\n<div class=\"table-wrap\" role=\"region\" aria-label=\"Scrollable table\" tabindex=\"0\"><table><thead>\n<tr>\n<th>Part</th>\n<th>Meaning</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code dir=\"ltr\">m</code></td>\n<td>family: general purpose</td>\n</tr>\n<tr>\n<td><code dir=\"ltr\">7</code></td>\n<td>generation: newer is usually better value</td>\n</tr>\n<tr>\n<td><code dir=\"ltr\">g</code></td>\n<td>extra capability: AWS Graviton (Arm) processor</td>\n</tr>\n<tr>\n<td><code dir=\"ltr\">large</code></td>\n<td>size</td>\n</tr>\n</tbody>\n</table></div><p>Common families: <code dir=\"ltr\">t</code> (burstable, cheap for spiky low use), <code dir=\"ltr\">m</code> (balanced), <code dir=\"ltr\">c</code> (compute-heavy), <code dir=\"ltr\">r</code> (memory-heavy). Other suffixes include <code dir=\"ltr\">i</code> (Intel), <code dir=\"ltr\">a</code> (AMD) and <code dir=\"ltr\">d</code> (local NVMe disk). Each size step, from <code dir=\"ltr\">large</code> to <code dir=\"ltr\">xlarge</code> to <code dir=\"ltr\">2xlarge</code>, roughly doubles vCPUs, memory and price. Graviton instances usually give better price-performance if your software runs on Arm, which Node.js and Python do without changes.</p>\n<h3 id=\"sec-3\" tabindex=\"-1\">How you pay</h3>\n<p>The instance is the same; the commitment changes the price.</p>\n<ul>\n<li><strong>On-Demand</strong>: pay per second (Linux, with a 60-second minimum), no commitment. Right for anything short-lived, new or unpredictable.</li>\n<li><strong>Savings Plans</strong>: commit to a fixed amount of compute spend per hour for one or three years, for a significant discount. Right for the baseline you know will run all year. (The older <strong>Reserved Instances</strong> model still exists and works similarly.)</li>\n<li><strong>Spot Instances</strong>: spare AWS capacity at a deep discount, but AWS can reclaim it with a two-minute warning. Right for batch work that can restart.</li>\n<li><strong>Dedicated Hosts</strong> and <strong>Capacity Reservations</strong> cover licensing and guaranteed-capacity needs you are unlikely to have yet.</li>\n</ul>\n<p>Commitments are not available on the Free account plan; another reason Lantern’s production account is on the Paid plan.</p>\n<aside class=\"callout callout-mistake\" role=\"note\"><p class=\"callout-title\"><svg class=\"icon \" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\"/><path d=\"M12 9v4\"/><path d=\"M12 17h.01\"/></svg><span><span class=\"callout-kind\">Common mistake</span><span class=\"callout-sep\" aria-hidden=\"true\"> · </span>Thinking “stopped” means “free”</span></p>\n<p>Stopping an instance stops the compute charge. Its EBS volumes keep billing because the data is still stored. An auto-assigned public IP is released when the instance stops, but an Elastic IP address stays allocated and keeps billing, because AWS charges for every public IPv4 address by the hour, in use or not. Terminate what you don’t need, and release Elastic IP addresses you aren’t using.</p>\n</aside>\n<h2 id=\"sec-4\" tabindex=\"-1\">AWS Lambda: code that runs on events</h2>\n<p>With Lambda you upload a function and say what triggers it: an HTTP request through API Gateway, a file landing in S3, a schedule, a message on a queue. Lambda runs as many copies as there are concurrent events, and <strong>none</strong> when there are none.</p>\n<p>Here is Lantern’s thumbnail function. S3 calls it with an event describing the uploaded poster:</p>\n<div class=\"code-block\" dir=\"ltr\" data-lang=\"js\" data-index=\"0\"><div class=\"code-head\"><span class=\"code-title\">thumbnail/index.mjs</span><span class=\"code-actions\"><button type=\"button\" class=\"code-btn\" data-action=\"copy\" aria-label=\"Copy code\"><svg class=\"icon \" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"/></svg><span>Copy</span></button></span></div><pre class=\"shiki\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#CF222E;--shiki-dark:#FF7B72\">export</span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\"> const</span><span style=\"color:#8250DF;--shiki-dark:#D2A8FF\"> handler</span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\"> =</span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\"> async</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\"> (</span><span style=\"color:#953800;--shiki-dark:#FFA657\">event</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">) </span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\">=></span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\"> {</span></span>\n<span class=\"line\"><span style=\"color:#CF222E;--shiki-dark:#FF7B72\">  const</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\"> { </span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\">bucket</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">, </span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\">object</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\"> } </span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\">=</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\"> event.Records[</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\">0</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">].s3;</span></span>\n<span class=\"line\"><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">  console.</span><span style=\"color:#8250DF;--shiki-dark:#D2A8FF\">log</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">(</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\">`New poster: s3://${</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">bucket</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\">.</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">name</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\">}/${</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">object</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\">.</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">key</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\">}`</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">);</span></span>\n<span class=\"line\"><span style=\"color:#6E7781;--shiki-dark:#8B949E\">  // …download, resize, upload to thumbnails/</span></span>\n<span class=\"line\"><span style=\"color:#CF222E;--shiki-dark:#FF7B72\">  return</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\"> { resized: object.key };</span></span>\n<span class=\"line\"><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">};</span></span></code></pre></div>\n<p>And you create it with the CLI, choosing the runtime, Arm architecture, memory and timeout:</p>\n<div class=\"code-block\" dir=\"ltr\" data-lang=\"bash\" data-index=\"1\"><div class=\"code-head\"><span class=\"code-title\">Terminal</span><span class=\"code-actions\"><button type=\"button\" class=\"code-btn\" data-action=\"copy\" aria-label=\"Copy code\"><svg class=\"icon \" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"/></svg><span>Copy</span></button></span></div><pre class=\"shiki\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#953800;--shiki-dark:#FFA657\">aws</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\"> lambda</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\"> create-function</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> --function-name</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\"> lantern-thumbnail</span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\"> \\</span></span>\n<span class=\"line\"><span style=\"color:#0550AE;--shiki-dark:#79C0FF\">  --runtime</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\"> nodejs24.x</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> --architectures</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\"> arm64</span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\"> \\</span></span>\n<span class=\"line\"><span style=\"color:#0550AE;--shiki-dark:#79C0FF\">  --handler</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\"> index.handler</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> --zip-file</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\"> fileb://thumbnail.zip</span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\"> \\</span></span>\n<span class=\"line\"><span style=\"color:#0550AE;--shiki-dark:#79C0FF\">  --role</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\"> arn:aws:iam::111122223333:role/lantern-thumbnail-role</span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\"> \\</span></span>\n<span class=\"line\"><span style=\"color:#0550AE;--shiki-dark:#79C0FF\">  --memory-size</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> 512</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> --timeout</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> 30</span></span></code></pre></div>\n<p>The role is the execution role from last section: it can read <code dir=\"ltr\">uploads/</code> and write <code dir=\"ltr\">thumbnails/</code>, nothing else.</p>\n<h3 id=\"sec-5\" tabindex=\"-1\">The Lambda cost model</h3>\n<p>You pay per <strong>request</strong> and per <strong>GB-second</strong>: memory size in GB multiplied by run time in seconds, measured to the millisecond. CPU power scales with the memory you allocate (128 MB to 10,240 MB), and one invocation can run for at most 15 minutes. Work out Lantern’s thumbnail usage:</p>\n<div class=\"code-block\" dir=\"ltr\" data-lang=\"js\" data-run=\"js\" data-index=\"2\"><div class=\"code-head\"><span class=\"code-title\">JavaScript</span><span class=\"code-actions\"><button type=\"button\" class=\"code-btn code-run\" data-action=\"run\" data-lang=\"js\" data-index=\"2\" aria-label=\"Run this example\"><svg class=\"icon \" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z\"/></svg><span>Run</span></button><button type=\"button\" class=\"code-btn\" data-action=\"copy\" aria-label=\"Copy code\"><svg class=\"icon \" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"/></svg><span>Copy</span></button></span></div><pre class=\"shiki\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#CF222E;--shiki-dark:#FF7B72\">const</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> postersPerMonth</span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\"> =</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> 3000</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">;</span></span>\n<span class=\"line\"><span style=\"color:#CF222E;--shiki-dark:#FF7B72\">const</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> avgSeconds</span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\"> =</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> 0.8</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">;    </span><span style=\"color:#6E7781;--shiki-dark:#8B949E\">// measured from CloudWatch logs</span></span>\n<span class=\"line\"><span style=\"color:#CF222E;--shiki-dark:#FF7B72\">const</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> memoryGb</span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\"> =</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> 512</span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\"> /</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> 1024</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">;</span></span>\n<span class=\"line\"></span>\n<span class=\"line\"><span style=\"color:#CF222E;--shiki-dark:#FF7B72\">const</span><span style=\"color:#0550AE;--shiki-dark:#79C0FF\"> gbSeconds</span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\"> =</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\"> postersPerMonth </span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\">*</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\"> avgSeconds </span><span style=\"color:#CF222E;--shiki-dark:#FF7B72\">*</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\"> memoryGb;</span></span>\n<span class=\"line\"><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">console.</span><span style=\"color:#8250DF;--shiki-dark:#D2A8FF\">log</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">(</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\">`Requests: ${</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">postersPerMonth</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\">}`</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">);</span></span>\n<span class=\"line\"><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">console.</span><span style=\"color:#8250DF;--shiki-dark:#D2A8FF\">log</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">(</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\">`GB-seconds: ${</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">gbSeconds</span><span style=\"color:#0A3069;--shiki-dark:#A5D6FF\">}`</span><span style=\"color:#1F2328;--shiki-dark:#E6EDF3\">);</span></span></code></pre><div class=\"run-output\" data-run-output=\"2\" hidden></div></div>\n<p>1,200 GB-seconds and 3,000 requests a month sit far inside Lambda’s always-free monthly allowance, which at the time of writing is 1 million requests and 400,000 GB-seconds. An EC2 instance doing the same job would bill every second of the month, busy or idle.</p>\n<h2 id=\"sec-6\" tabindex=\"-1\">Choosing between them</h2>\n<div class=\"table-wrap\" role=\"region\" aria-label=\"Scrollable table\" tabindex=\"0\"><table><thead>\n<tr>\n<th>Lantern job</th>\n<th>Pick</th>\n<th>Why</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>RSVP API</td>\n<td>Lambda</td>\n<td>Spiky traffic, short requests, idle most of the night</td>\n</tr>\n<tr>\n<td>Poster thumbnails</td>\n<td>Lambda</td>\n<td>Triggered by S3 uploads, seconds of work</td>\n</tr>\n<tr>\n<td>Nightly 40-minute archive</td>\n<td>EC2 On-Demand or Spot</td>\n<td>Too long for one invocation; runs briefly each day</td>\n</tr>\n<tr>\n<td>Old Node.js app during migration</td>\n<td>EC2</td>\n<td>Needs to run unchanged until it is retired</td>\n</tr>\n</tbody>\n</table></div><p>A good default for a team of Lantern’s size: <strong>Lambda for event-driven pieces, EC2 only when something needs a long-running process, OS-level control or steady heavy load.</strong> Containers on Amazon ECS with AWS Fargate sit between the two, and are worth a look once you package apps as images.</p>\n<aside class=\"callout callout-tip\" role=\"note\"><p class=\"callout-title\"><svg class=\"icon \" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5\"/><path d=\"M9 18h6\"/><path d=\"M10 22h4\"/></svg><span><span class=\"callout-kind\">Tip</span><span class=\"callout-sep\" aria-hidden=\"true\"> · </span>Memory is a speed knob</span></p>\n<p>Because CPU scales with memory, doubling a function’s memory often halves its run time, so the GB-second cost stays about the same while users wait less. Measure before and after; don’t guess.</p>\n</aside>\n<p>Compute needs somewhere to keep files. Next: Amazon S3 for objects, and EBS and EFS for disks.</p>\n","toc":[{"id":"sec-1","text":"Amazon EC2: a server, rented","level":2},{"id":"sec-2","text":"Reading an instance type","level":3},{"id":"sec-3","text":"How you pay","level":3},{"id":"sec-4","text":"AWS Lambda: code that runs on events","level":2},{"id":"sec-5","text":"The Lambda cost model","level":3},{"id":"sec-6","text":"Choosing between them","level":2}],"takeaways":["An instance type such as m7g.large encodes family, generation, extra capabilities and size, and each size step roughly doubles vCPUs and memory.","On-Demand suits short or unpredictable use, Savings Plans suit steady use you can commit to, and Spot suits interruptible work at a deep discount.","A stopped EC2 instance stops compute charges, but its EBS volumes and any Elastic IP address kept on it keep billing.","Lambda charges per request and per GB-second of run time, scales to zero, and suits event-driven work that finishes within 15 minutes.","Choose Lambda by default for small event-driven jobs, and EC2 when you need long-running processes, full OS control or steady heavy load."],"further":[{"title":"Amazon EC2 instance types","url":"https://docs.aws.amazon.com/ec2/latest/instancetypes/instance-types.html"},{"title":"Amazon EC2 billing and purchasing options","url":"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-purchasing-options.html"},{"title":"How Lambda works","url":"https://docs.aws.amazon.com/lambda/latest/dg/concepts-basics.html"},{"title":"AWS Lambda pricing","url":"https://aws.amazon.com/lambda/pricing/"}],"quiz":[{"q":"<p>What does <code dir=\"ltr\">c7g.xlarge</code> tell you compared with <code dir=\"ltr\">c7g.large</code>?</p>","options":[{"text":"Same compute-optimised Graviton family and generation, with roughly twice the vCPUs and memory.","why":"Correct. The letters and number stay the same, and the size suffix steps up, which roughly doubles resources and price."},{"text":"A newer generation of the same family with the same resources.","why":"Generation is the digit (7 in both). The difference here is only the size."},{"text":"The same instance with an extra GPU attached.","why":"GPUs come from GPU families such as g and p. The size suffix never adds hardware types."},{"text":"An x86 version of the Graviton instance.","why":"The <code dir=\"ltr\">g</code> in <code dir=\"ltr\">c7g</code> means Graviton (Arm) in both names. An x86 equivalent would drop the <code dir=\"ltr\">g</code>, for example <code dir=\"ltr\">c7i</code>."}],"answer":0},{"q":"<p>Lantern runs a nightly poster-archive job that takes 40 minutes and can safely restart if interrupted. Which option fits best?</p>","options":[{"text":"AWS Lambda, because it is always the cheapest compute.","why":"A single Lambda invocation can run for at most 15 minutes, so a 40-minute job does not fit without splitting it up."},{"text":"A 3-year Savings Plan on a large instance that runs all day.","why":"A commitment for 24 hours a day to cover 40 minutes of work pays for 23 idle hours."},{"text":"An On-Demand instance that runs only for the job, or a Spot Instance since interruptions are acceptable.","why":"Correct. Paying only while the job runs fits a short daily task, and Spot’s discount suits work that can restart."}],"answer":2},{"q":"<p>You stop Lantern’s old migration server for the weekend. Which charges continue?</p>","options":[{"text":"None; a stopped instance is free.","why":"Only the compute charge stops. Attached storage and Elastic IP addresses are separate resources with their own billing."},{"text":"The instance’s hourly compute rate, at a reduced weekend price.","why":"AWS has no weekend pricing, and a stopped instance does not accrue compute charges."},{"text":"Data transfer for the traffic the server would have received.","why":"A stopped server receives no traffic, so there is no data transfer to bill."},{"text":"Its EBS volumes and any public IPv4 address that stays allocated to it.","why":"Correct. Storage persists while stopped, and AWS charges for public IPv4 addresses by the hour whether or not they are in use."}],"answer":3}],"exercise":{"kind":"choice","multiple":true,"options":["spot-batch","sp-steady","lambda-long","ondemand-trial","spot-db","ec2-idle-api"],"correct":["spot-batch","sp-steady","ondemand-trial"],"title":"Match workloads to compute and pricing","prompt":"<p>A cost review of Lantern lists six proposals. Select every proposal that is a <strong>sensible</strong> match between the workload’s shape and the compute or purchasing option.</p>\n","hints":["Ask three questions per proposal: how long does it run, how steady is it, and what happens if it is interrupted?","Spot is cheap because it can disappear with two minutes’ notice. Which workloads tolerate that?","A Lambda invocation has a hard 15-minute limit."],"explanation":"<p>Spot suits the archive job because it restarts safely, and the discount is large. A Savings Plan suits the baseline that runs every hour of the year, because a commitment is only good value when it is fully used. On-Demand is right for a three-week trial: no commitment for something that may not last. A 40-minute job cannot run in one Lambda invocation. A primary database on Spot would go down whenever AWS reclaims the capacity. And an always-on instance for an API that is idle most of the time pays for idle hours that Lambda would not charge for.</p>\n","checkLabels":{},"optionText":{"spot-batch":{"text":"Run the nightly 40-minute poster archive, which can restart from a checkpoint, on Spot Instances.","why":"Sensible. Interruptible batch work is exactly what Spot is for, and a restart costs only a few minutes."},"sp-steady":{"text":"Cover the always-on migration server, which will run all year at steady load, with a one-year Compute Savings Plan.","why":"Sensible. Steady, predictable use is where a commitment pays off, because every committed hour is used."},"lambda-long":{"text":"Move the 40-minute archive job into a single Lambda invocation to stop paying for a server.","why":"Not sensible. One Lambda invocation can run for at most 15 minutes, so the job would time out every night."},"ondemand-trial":{"text":"Run a three-week trial of a new search feature on On-Demand instances.","why":"Sensible. Short and uncertain usage should not carry a one- or three-year commitment."},"spot-db":{"text":"Host the primary PostgreSQL database on a Spot Instance to save money.","why":"Not sensible. A database must not disappear on two minutes’ notice; reclaimed capacity means an outage and possibly lost writes."},"ec2-idle-api":{"text":"Run the RSVP API, idle most nights and busy during big events, on a large always-on instance.","why":"Not sensible. You pay for idle hours and still risk running out of capacity in a spike. Lambda scales with requests and charges nothing when idle."}}},"words":781,"readMinutes":4}