docs/workload.mdWhat is measured and what is decidedInstruction session · Wednesday, December 16, 2026 · one hour of demonstration, one hour in groups
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.
Project ritual
Each group reports the progress of its deliverables, the work planned for this session and the blockers that require a decision.
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.
docs/workload.mdWhat is measured and what is decideddocs/architectures.mdFive architectures and what each service countsdocs/cost_optimisation.mdSize, schedule, commitment, Spot and regioncalculator.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.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.
| Service | What is counted | Unit | Unit price, us-east-1 | Driven by |
|---|---|---|---|---|
| EC2 t4g.small | time the instance is running | hour | $0.0168 | hours on, not hours of work |
| EBS gp3 | provisioned volume | GB-month | $0.08 | size, even with the instance stopped |
| Public IPv4 | address in use | hour | $0.005 | hours the address is attached |
| Lambda, ARM | compute | GB-second | $0.0000133334 | runs × duration × memory |
| Fargate, ARM | vCPU and memory of the task | vCPU-hour, GB-hour | $0.03238 · $0.00356 | runs × billed duration × size |
| S3 Standard | stored data, requests | GB-month, request | $0.023 · PUT $0.000005 | data kept, files written and read |
| Data transfer out | bytes sent to the internet | GB | $0.09 | readers; data coming in is free |
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.
| Model | t4g.small, us-east-1, per hour | Condition |
|---|---|---|
| On-demand | $0.0168 | no commitment, billed per second with a minimum of one minute |
| Compute Savings Plan, 1 year, no upfront | $0.0121 | a 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.0105 | tied to the instance family and the region |
| Spot | about $0.0072 | 57% below on-demand on average, by the Spot Instance Advisor; interruption with two minutes of notice |
Lambda: 1 million requests and 400,000 GB-seconds per month. Scheduler: 14 million invocations. Egress: 100 GB per month, across the account.
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.
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
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.
scripts/measure_run.sh, docs/workload.md.
[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.
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.
| Quantity | Value | Origin |
|---|---|---|
| wall time of a run | 25.6 s | measured; Lesson 7 reference 40 s |
| CPU time, user + system | 10.8 + 1.1 s | measured |
| peak resident memory | 392 MB | measured |
| warehouse/tcg.duckdb | 1.85 MB | measured |
| out/ (report and three Parquet files) | 0.09 MB | measured |
| downloaded per run | 21.6 MB | measured: 19.8 archives + 1.8 catalogue |
| runs per month | 30 | decision: one per day |
| egress to readers | 1 GB | assumption |
Step 02 · 0:33 · Architectures
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.
docs/architectures.md, with Mermaid diagrams.
[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.
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.
| Architecture | Billed while working | Billed while idle |
|---|---|---|
| A · EC2 always on | instance hours | the instance, the volume and the public IPv4, 730 hours |
| B · EC2 started for each run | instance and IPv4 for the run and the boot | the EBS volume only |
| C · Lambda + Scheduler + S3 | GB-seconds and one request per run; S3 requests | the bytes kept in S3 |
| D · Fargate task + Scheduler + S3 | vCPU and memory from the image pull to the end, minimum one minute | the image in ECR and the bytes in S3 |
| E · D + RDS for PostgreSQL | as D | the database instance and its storage, 730 hours |
Step 03 · 0:43 · Estimate
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.
docs/pricing_calculator.md, estimates/*.csv, costs/cost_model.py, costs/prices.json, tests/test_cost_model.py.
[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.
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.
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.
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.
cost_model.py, and a test proves that the page and Python agree on 180 totals.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.
| Architecture | USD per month | Largest line |
|---|---|---|
| A · EC2 always on | 16.55 | t4g.small, 730 h: $12.26; the public IPv4 alone adds $3.65 |
| E · Fargate task + RDS PostgreSQL | 14.03 | db.t4g.micro, 730 h: $11.68 |
| B · EC2 started for each run | 0.66 | the 8 GB volume kept while stopped: $0.64 |
| D · Fargate task + Scheduler + S3 | 0.05 | the image in ECR: $0.03 |
| C · Lambda + Scheduler + S3 | < 0.01 | 150 S3 PUT requests: $0.0008; compute inside the free allowance |
Step 04 · 0:55 · Optimise
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.
docs/cost_optimisation.md.
[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.
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.
| Lever | Change | USD per month | Condition |
|---|---|---|---|
| none | A, t4g.small, on-demand | 16.55 | the starting point |
| right-sizing | t4g.small (2 GiB) → t4g.micro (1 GiB) | 10.42 | peak of 392 MB plus 30% fits in 1 GiB |
| commitment | t4g.small reserved 1 year, no upfront | 11.96 | pays above 62.5% of the hours in use |
| Spot | t4g.small on Spot | 9.56 | a run may be interrupted; the idempotent load of Lesson 7 allows a retry |
| scheduling | B: started only for each run | 0.66 | the 96% saving comes from not paying for the idle hours |
| region | A in São Paulo | 24.43 | 1.48 times Virginia; a requirement of residency or latency can justify it |
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.
| Architecture | 30 runs | 720 runs | 8,640 runs | São Paulo, 30 runs |
|---|---|---|---|---|
| A · EC2 always on | 16.55 | 16.55 | 16.55 | 24.43 |
| B · EC2 started for each run | 0.66 | 1.08 | 5.87 | 1.24 |
| C · Lambda + Scheduler + S3 | < 0.01 | 0.02 | 0.22 | < 0.01 |
| D · Fargate task + Scheduler + S3 | 0.05 | 0.39 | 4.41 | 0.05 |
| E · Fargate task + RDS PostgreSQL | 14.03 | 14.37 | 18.39 | 29.25 |
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.
docs/workload.md, with the origin of each quantitydocs/architectures.md, at least three architecturescalculator.aws in São Paulo and Virginia, as share links and CSV in estimates/docs/cost_optimisation.md and the recommendationTwo 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.
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.
User guide to the options of the Pricing Calculator, organised in the left-hand menu.
Cloud Infrastructure Pricing · 16/12/2026 · Prof. Afonso
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.
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.