Module 8 · Information Systems · Lesson 12 · Week 10

Instruction session · Wednesday, December 16, 2026 · one hour of demonstration, one hour in groups

Cloud Infrastructure Pricing

The DataApp of Lesson 7 runs in forty seconds a day. This session measures that workload, describes five ways to run it on AWS, prices each one with the AWS Pricing Calculator and with the public Price List, and chooses the cheapest configuration that still meets the requirements.

Billing dimensionsOn-demand · commitments · SpotAWS Pricing CalculatorRight-sizingRegionBrowser lab

Project ritual

Daily · 15 minutes

Each group reports the progress of its deliverables, the work planned for this session and the blockers that require a decision.

15:00
What I didWhat I will doBlockersProgress
Agenda · two hours
One hour pricing tcg-dataapp, one hour pricing your DataApp

In the first hour the professor prices the package of Lesson 7 in four steps, with a coding agent, the AWS Pricing Calculator and the lab of the session. In the second hour each group repeats the four steps over its own DataApp.

0:25 · step 01WorkloadAgent: docs/workload.mdWhat is measured and what is decided
0:33 · step 02ArchitecturesAgent: docs/architectures.mdFive architectures and what each service counts
0:43 · step 03EstimateCalculator and labcalculator.aws, the Price List and a cost model in code
0:55 · step 04OptimiseAgent: docs/cost_optimisation.mdSize, schedule, commitment, Spot and region
1:05 · groupsYour architectureEach groupEstimate, compare and optimise, delivered by pull request
Where the work happensIn the terminal with the coding agent, in calculator.aws and in the lab of the session, which prices the five architectures in the browser with the prices of the AWS Price List consulted on 08/11/2026.
0:15 · Cost factors
Every line of a bill is a quantity times a unit price

AWS does not sell servers by the month: each service counts one or more billing dimensions, and the bill multiplies each counted quantity by its unit price. Estimating a cost is therefore estimating the quantities of the workload first.

ServiceWhat is countedUnitUnit price, us-east-1Driven by
EC2 t4g.smalltime the instance is runninghour$0.0168hours on, not hours of work
EBS gp3provisioned volumeGB-month$0.08size, even with the instance stopped
Public IPv4address in usehour$0.005hours the address is attached
Lambda, ARMcomputeGB-second$0.0000133334runs × duration × memory
Fargate, ARMvCPU and memory of the taskvCPU-hour, GB-hour$0.03238 · $0.00356runs × billed duration × size
S3 Standardstored data, requestsGB-month, request$0.023 · PUT $0.000005data kept, files written and read
Data transfer outbytes sent to the internetGB$0.09readers; data coming in is free
Source of every priceAWS Price List, the public Bulk API that needs no account, consulted on 08/11/2026. The lab shows the offer and the usage type of each price.
0:20 · Pricing models
The same hour of t4g.small at four prices

The unit price depends on how the capacity is bought. A commitment lowers the rate in exchange for paying it every hour of the year, used or not; Spot lowers it further in exchange for the right of AWS to reclaim the instance.

Modelt4g.small, us-east-1, per hourCondition
On-demand$0.0168no commitment, billed per second with a minimum of one minute
Compute Savings Plan, 1 year, no upfront$0.0121a commitment in USD per hour, valid for EC2, Fargate and Lambda in any region
Reserved Instance or EC2 Instance Savings Plan, 1 year, no upfront$0.0105tied to the instance family and the region
Spotabout $0.007257% below on-demand on average, by the Spot Instance Advisor; interruption with two minutes of notice
Free allowances

Lambda: 1 million requests and 400,000 GB-seconds per month. Scheduler: 14 million invocations. Egress: 100 GB per month, across the account.

Break-even

A commitment of $0.0105 against $0.0168 pays only if the instance runs more than 0.0105 / 0.0168 = 62.5% of the hours.

Region

The same t4g.small costs $0.0268 per hour in São Paulo, 1.6 times the price in Virginia.

Step 01 · 0:25 · Workload

Measure before pricing

The first step measures the run of tcg-dataapp and writes down the quantities that are decided by the group, so that every number of the estimate has an origin.

Files

scripts/measure_run.sh, docs/workload.md.

Review before moving on
  • Is each quantity marked as measured, assumption or decision?
  • Is the peak memory recorded, and not the average?
  • Are the bytes downloaded per run recorded, although ingress is free?
Prompt 01 · CREATE
[C] Character
You are the engineer responsible for the costs of the DataApp tcg-dataapp,
the package of Lesson 7. Before any price is looked up, the workload that
will be paid for must be measured, because every line of a cloud bill is a
quantity of the workload multiplied by a unit price.

[R] Request
1. scripts/measure_run.sh: runs `tcg-dataapp run` once under
   `/usr/bin/time -v` with TCG_DB_PATH and TCG_OUT_DIR in a temporary
   folder, and prints the wall time, the user and system CPU time, the
   peak resident memory (MB), the size of warehouse/tcg.duckdb, the size of
   out/ and the number of files written.
2. docs/workload.md: one table with the measured quantities and the
   quantities that are decided, not measured (runs per month, readers and
   their downloads, egress in GB per month), each one with its origin:
   "measured on <date>", "assumption" or "decision of the group".
3. The bytes downloaded per run: the five price archives of tcgcsv and the
   catalogue (HEAD requests are enough for the archives).

Facts measured on 08/11/2026 (confirm before use):
- wall time 25.6 s (Lesson 7 reference: about 40 s), CPU 10.8 s user and
  1.1 s system, peak memory 392 MB;
- warehouse/tcg.duckdb 1.85 MB, out/ 0.09 MB (report.md and three
  Parquet files);
- downloaded per run: 19.8 MB of archives and 1.8 MB of catalogue.

[E] Example
| quantity            | value  | unit      | origin                 |
|---------------------|--------|-----------|------------------------|
| wall time of a run  | 25.6   | s         | measured on 08/11/2026 |
| runs per month      | 30     | runs      | decision: one per day  |

[A] Adjustments
- Data entering AWS from the internet is not charged; record it anyway,
  because it decides the duration of the run.
- Peak memory, not average, decides the size of the machine.
- Do not round the measures; round only in the conclusions.

[T] Type of output
The script, docs/workload.md and the output of one measured run.

[E] Extras
Show the plan before editing. Record this prompt in docs/prompts.md.
Stop at the end.
Step 01 · Result
Forty seconds of work in a month of 730 hours

The run measured on 08/11/2026 with /usr/bin/time -v. Thirty daily runs of forty seconds add up to twenty minutes, so the DataApp works during 0.05% of the month and is idle for the rest of it.

QuantityValueOrigin
wall time of a run25.6 smeasured; Lesson 7 reference 40 s
CPU time, user + system10.8 + 1.1 smeasured
peak resident memory392 MBmeasured
warehouse/tcg.duckdb1.85 MBmeasured
out/ (report and three Parquet files)0.09 MBmeasured
downloaded per run21.6 MBmeasured: 19.8 archives + 1.8 catalogue
runs per month30decision: one per day
egress to readers1 GBassumption
0.05%of the month with the DataApp working
392 MBpeak memory: the size of the machine follows it
What the numbers sayThe run uses less CPU time than wall time, because most of it waits for the downloads. A bigger machine would not make it much faster.

Step 02 · 0:33 · Architectures

Five ways to run the same package

The second step describes the candidate architectures by what each one bills. The diagram shows the parts; the table of billing dimensions shows which quantity of the workload each part turns into cost.

Files

docs/architectures.md, with Mermaid diagrams.

Review before moving on
  • Does each architecture list every billed resource, including volume and address?
  • Is the run inside the 15-minute limit of Lambda?
  • Is the idle time of each architecture stated?
Prompt 02 · CREATE
[C] Character
You are the same engineer. The workload is measured; now the architectures
that could run it on AWS are described by what each one bills.

[R] Request
docs/architectures.md with five candidate architectures for tcg-dataapp,
each one with a Mermaid diagram (scheduler, compute, storage, readers) and
a table of its billing dimensions (service, what is counted, unit, and the
quantity of the workload of docs/workload.md that drives it):
A. EC2 instance always on, with an EBS gp3 volume and a public IPv4.
B. The same instance started for each run and stopped after it, by
   EventBridge Scheduler.
C. AWS Lambda (ARM) started by EventBridge Scheduler, with tcg.duckdb and
   the marts in S3.
D. An ECS Fargate task (ARM) started by EventBridge Scheduler, with the
   image in ECR and the data in S3.
E. D plus an RDS for PostgreSQL db.t4g.micro that serves the gold layer.
Close with a paragraph on the time that each architecture keeps a resource
billed while the DataApp is idle.

[E] Example
| service | counted        | unit       | driver                       |
|---------|----------------|------------|------------------------------|
| Lambda  | compute        | GB-second  | runs x duration x memory     |
| S3      | PUT requests   | request    | runs x files written per run |

[A] Adjustments
- Lambda stops a run at 15 minutes; say whether the measured run fits.
- Fargate bills per second, from the image pull to the end of the task,
  with a minimum of one minute; EC2 Linux also bills per second with a
  minimum of one minute.
- An EBS volume is billed while the instance is stopped; a public IPv4 is
  billed only while it is in use.

[T] Type of output
docs/architectures.md, with the diagrams rendered in the preview.

[E] Extras
Show the plan before editing. Record this prompt in docs/prompts.md.
Stop at the end.
Step 02 · Theory
What each architecture keeps billed while idle

The architectures differ less in the price of a working minute than in what they keep billed during the 99.95% of the month in which nothing runs.

ArchitectureBilled while workingBilled while idle
A · EC2 always oninstance hoursthe instance, the volume and the public IPv4, 730 hours
B · EC2 started for each runinstance and IPv4 for the run and the bootthe EBS volume only
C · Lambda + Scheduler + S3GB-seconds and one request per run; S3 requeststhe bytes kept in S3
D · Fargate task + Scheduler + S3vCPU and memory from the image pull to the end, minimum one minutethe image in ECR and the bytes in S3
E · D + RDS for PostgreSQLas Dthe database instance and its storage, 730 hours
Two limits that decide the choiceLambda stops any run at 15 minutes, which the 40 s of tcg-dataapp respect. Fargate and EC2 have no such limit, so a DataApp whose run grows past it needs one of them.

Step 03 · 0:43 · Estimate

The price of each architecture

The third step fills the AWS Pricing Calculator for two architectures in two regions and writes a cost model in code, which gives the same lines and can be rerun when the workload changes.

Files

docs/pricing_calculator.md, estimates/*.csv, costs/cost_model.py, costs/prices.json, tests/test_cost_model.py.

Review before moving on
  • Does every unit price have a source and a date?
  • Do the calculator and the code agree for B and D, or is the difference explained?
  • Is the estimate saved with a share link?
Prompt 03 · CREATE
[C] Character
You are the same engineer. The architectures are described; now each one
receives a price, first in the AWS Pricing Calculator and then in code that
can be rerun when the workload changes.

[R] Request
1. A guide, docs/pricing_calculator.md, with the exact fields to fill in
   https://calculator.aws for architectures B and D in the region
   South America (Sao Paulo) and in US East (N. Virginia): service, region,
   configuration and the quantities of docs/workload.md. The group fills
   the calculator by hand, saves the estimate, copies the share link and
   exports it as CSV to estimates/<architecture>-<region>.csv.
2. costs/cost_model.py: the five architectures as functions of the
   workload and of a price table in costs/prices.json, with one line per
   billing dimension (item, quantity, unit, unit price, cost) and the
   monthly total; options for region, pricing model (on-demand, 1-year
   commitment, Spot) and the free allowances.
3. costs/prices.json: every unit price with its source (AWS Price List
   offer and usage type) and the date of consultation; nothing typed
   from memory.
4. tests/test_cost_model.py: the always-on total equals the sum of its
   lines computed by hand; Fargate bills at least one minute per run.
5. docs/cost_estimate.md: the monthly total of each architecture in both
   regions, next to the total of the calculator for B and D, and the
   explanation of any difference.

[E] Example
| line                 | quantity | unit  | unit price | cost  |
|----------------------|----------|-------|------------|-------|
| EC2 t4g.small        | 730      | hours | 0.0168     | 12.26 |
| Public IPv4 address  | 730      | hours | 0.005      | 3.65  |

[A] Adjustments
- The AWS Price List is public and needs no key:
  https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/index.json.
  The EC2 file of a region has about 480 MB; read the CSV in a stream and
  keep only the instance types used.
- A month has 730 hours in the calculator; use the same.
- Prices in USD, without taxes.

[T] Type of output
The files, the output of pytest and the table of docs/cost_estimate.md.

[E] Extras
Show the plan before editing. Record this prompt in docs/prompts.md.
Stop at the end.
Step 03 · Theory
Two sources of prices for one estimate

The AWS Pricing Calculator is the reference that AWS offers to customers and the format that a manager receives. The Price List is the same catalogue in machine-readable files, which a program can read again whenever the estimate must be repeated.

calculator.aws

An estimate to share

Service by service, with the region and the configuration chosen in forms; the total per month and per year, a share link and the export in CSV and PDF. Estimates for one group of services are kept together in one link.

AWS Price List

The catalogue as data

One JSON or CSV file per service and region at pricing.us-east-1.amazonaws.com, without a key. Each price has an offer, a usage type such as BoxUsage:t4g.small, a unit and the date of publication. The EC2 file of a region has about 480 MB.

The lab of the sessionThe lab prices the five architectures in the browser from a 17 KB snapshot of the Price List. The same rules are in cost_model.py, and a test proves that the page and Python agree on 180 totals.
Step 03 · Result
From $16.55 to less than one cent per month

The five architectures for thirty daily runs in us-east-1, on-demand, with the free allowances of the account. The largest line of each total shows where its money goes.

ArchitectureUSD per monthLargest line
A · EC2 always on16.55t4g.small, 730 h: $12.26; the public IPv4 alone adds $3.65
E · Fargate task + RDS PostgreSQL14.03db.t4g.micro, 730 h: $11.68
B · EC2 started for each run0.66the 8 GB volume kept while stopped: $0.64
D · Fargate task + Scheduler + S30.05the image in ECR: $0.03
C · Lambda + Scheduler + S3< 0.01150 S3 PUT requests: $0.0008; compute inside the free allowance
Without the free allowancesC costs $0.11 and D $0.14 per month. The allowances belong to the account and are shared by every workload in it, so an estimate shows the total both with and without them.

Step 04 · 0:55 · Optimise

The cheapest configuration that still works

The last step applies the levers of cost one at a time, measures the saving of each in USD per month and closes with one recommendation and the condition that would change it.

Files

docs/cost_optimisation.md.

Review before moving on
  • Is every saving given in USD per month and in percent?
  • Is the utilisation of break-even of each commitment computed?
  • Does the recommendation state when it stops being valid?
Prompt 04 · CREATE
[C] Character
You are the same engineer. Every architecture has a price; now the
cheapest configuration that still meets the requirements of the DataApp
is chosen, and the choice is justified with numbers.

[R] Request
docs/cost_optimisation.md, using costs/cost_model.py:
1. Right-sizing: the smallest instance, Lambda memory and Fargate task
   that fit the measured peak memory with a margin of 30%, and the saving
   against the size first chosen.
2. Scheduling: the saving of B over A, and the share of the month in which
   A is billed while idle.
3. Commitments: for A and E, the saving of a 1-year commitment and the
   utilisation below which it costs more than on-demand
   (commitment rate divided by on-demand rate).
4. Spot: whether a run interrupted in the middle is acceptable for this
   DataApp, given the idempotent load of Lesson 7.
5. Region: the ratio between Sao Paulo and Virginia for each architecture,
   and the requirements that may still demand Sao Paulo (latency of the
   readers, data residency asked by the partner).
6. Sensitivity: the ranking of the five architectures with 30, 720 and
   8,640 runs per month, and with ten times the data.
7. The recommendation in one paragraph: architecture, size, region,
   pricing model and monthly total, with the condition that would change it.

[E] Example
| runs per month | A     | B    | C    | D    | E     | cheapest |
|----------------|-------|------|------|------|-------|----------|
| 30             | 16.55 | 0.66 | 0.00 | 0.05 | 14.03 | C        |

[A] Adjustments
- Compare monthly totals of the same workload; a saving is always in
  USD per month and in percent.
- A commitment is paid whether the resource is used or not.
- Free allowances belong to the account, not to the DataApp: show every
  total with and without them.

[T] Type of output
docs/cost_optimisation.md with the tables and the recommendation.

[E] Extras
Show the plan before editing. Record this prompt in docs/prompts.md.
Stop at the end.
Step 04 · Theory
Five levers of cost, measured on the same workload

Each lever changes one quantity or one unit price of the bill. Measured one at a time over architecture A, in us-east-1, they show which decision moves the total and which one only moves cents.

LeverChangeUSD per monthCondition
noneA, t4g.small, on-demand16.55the starting point
right-sizingt4g.small (2 GiB) → t4g.micro (1 GiB)10.42peak of 392 MB plus 30% fits in 1 GiB
commitmentt4g.small reserved 1 year, no upfront11.96pays above 62.5% of the hours in use
Spott4g.small on Spot9.56a run may be interrupted; the idempotent load of Lesson 7 allows a retry
schedulingB: started only for each run0.66the 96% saving comes from not paying for the idle hours
regionA in São Paulo24.431.48 times Virginia; a requirement of residency or latency can justify it
A trap of storage classesS3 Standard-IA has a lower price per GB, but bills at least 128 KB per object and 30 days per object, and charges each GB read. The marts of tcg-dataapp have files smaller than 128 KB and are read every day, so Standard-IA would cost more.
Step 04 · Result
The ranking depends on the frequency of the runs

The same workload with 30, 720 and 8,640 runs per month, on-demand, in Virginia and in São Paulo. An always-on resource costs the same at any frequency; a resource billed per use grows with the runs.

Architecture30 runs720 runs8,640 runsSão Paulo, 30 runs
A · EC2 always on16.5516.5516.5524.43
B · EC2 started for each run0.661.085.871.24
C · Lambda + Scheduler + S3< 0.010.020.22< 0.01
D · Fargate task + Scheduler + S30.050.394.410.05
E · Fargate task + RDS PostgreSQL14.0314.3718.3929.25
The recommendation for tcg-dataappC, Lambda on ARM with 1 GB, started daily by EventBridge Scheduler, with the DuckDB file and the marts in S3 Standard, in us-east-1 or in São Paulo: less than one cent per month with the free allowances and $0.11 without them. It stops being valid when a run approaches the 15 minutes of Lambda, and then D is the next choice.
1:05 · Second hour · groups
Your architecture, estimated, compared and optimised

Each group repeats the four steps over its own DataApp with the fifth prompt, using its measured workload and the AWS Pricing Calculator. The partner receives a recommendation with its monthly total and the condition that would change it.

What to produce
  • docs/workload.md, with the origin of each quantity
  • docs/architectures.md, at least three architectures
  • the estimates of calculator.aws in São Paulo and Virginia, as share links and CSV in estimates/
  • docs/cost_optimisation.md and the recommendation
How to check
  • every resource billed while idle is in the estimate: volumes, addresses, databases, NAT gateways, load balancers
  • every unit price has a source and a date
  • the totals are shown with and without the free allowances
  • delivery by pull request in the repository of the group
The lab as a checkThe lab accepts the workload and the unit prices of the group: changing the fields and the prices of the region gives a second estimate to compare with the calculator, and "Copy as Markdown" puts it in the documents.
Self-study
Self-study for this session

Two readings assigned on Adalove, on the AWS Pricing Calculator that the groups use in the second hour, with the reading material and the lab of the session.

Self-study 1

AWS Pricing Calculator

The calculator the group uses to estimate the cost of the infrastructure of the project, with the estimate saved by a share link and exported as CSV.

calculator.aws· 30 min
Self-study 2

Docs - AWS Pricing Calculator

User guide to the options of the Pricing Calculator, organised in the left-hand menu.

docs.aws.amazon.com· 60 min
Material and lab of this sessionThe reading material is Lesson 12 material, and the calculator of the five architectures is in the lab of Lesson 12.

About this session

Cloud Infrastructure Pricing · 16/12/2026 · Prof. Afonso

Learning objective

By the end of the session, students should be able to estimate the monthly cost of the infrastructure of a DataApp from its measured workload, with the AWS Pricing Calculator and with the prices of the AWS Price List, compare alternative architectures, regions and pricing models, and propose an optimisation based on right-sizing, scheduling, commitments and Spot, applying it to the DataApp of the group.

Session strategy

Demonstration followed by application. In the first hour the professor prices on AWS the DataApp of Lesson 7 in four steps with a coding agent, the AWS Pricing Calculator and the browser lab of the session: the measurement of the workload, five candidate architectures and their billing dimensions, the estimate in two regions and the optimisation. In the second hour each group estimates, compares and optimises the architecture of its own DataApp and delivers the documents and the exported estimates by pull request.

Session structure

  1. Daily — 15 min
  2. Cost factors and pricing models: on-demand, commitments, Spot and free allowances — 10 min
  3. Step 01 · the measured workload of tcg-dataapp — 8 min
  4. Step 02 · five architectures and what each one bills — 10 min
  5. Step 03 · the estimate in the AWS Pricing Calculator and in the lab — 12 min
  6. Step 04 · optimisation: size, schedule, commitment, Spot and region — 10 min
  7. Second hour · each group estimates, compares and optimises its own architecture — 55 min