Repository navigation
feat(plan-selection): AWS Fargate us-east-1 price preset for cost model 1 - #756
Merged
Merged
Conversation
…el 1 Add ResourceUnitCost::aws_fargate_us_east_1(): the per vCPU-second and per GB-second prices from https://aws.amazon.com/fargate/pricing/ (checked 2026-10-18), converted to per CPU operation, per scanned byte and per byte-second at ResourceSpeed::illustrative, the speed Stage 3 uses for latency. Disk and the provisioned prices are 0, with reasons. stage_pipeline accepts --cost-model aws-fargate-us-east-1. Closes #742
… rejection reasons Under the dollar-priced Fargate preset every Example 4 cost is below 0.001, so "costlier: 0.000 vs 0.000 cost_per_second" hid the comparison. Costs at or above 0.001 keep three decimals.
… resource speed aws_fargate_us_east_1 now takes the ResourceSpeed Stage 3 uses for latency (PlanSelectionSettings::resource_speed) instead of reading ResourceSpeed::illustrative; stage_pipeline passes its settings' speed. The doc cites the page's "GB = 1024^3 bytes" and states what per-second prices cannot express (1-minute minimum, fixed task sizes from 0.25 vCPU / 0.5 GB). Rename BYTES_PER_GB to BYTES_PER_GIB.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Plan selection prices candidates only with
ResourceUnitCost::illustrative(), made-up numbers not tied to any provider. A deployment on AWS Fargate, billed per vCPU-second and per GB-second of memory (cost model 1), has to work out its ownResourceUnitCostby hand, and the selected plan's cost is not a dollar figure (#742).What
ResourceUnitCost::aws_fargate_us_east_1(speed): AWS Fargate on-demand prices for US East (N. Virginia), Linux/x86, converted to the planner's units for cost model 1 at the deployment's resource speed; one cost unit is one US dollar.stage_pipeline --cost-model aws-fargate-us-east-1: cost model 1 at those prices.costlier: 2.699e-8 vs 2.361e-8 cost_per_second). Before, every dollar cost read0.000. Costs at or above 0.001 keep three decimals, so the illustrative-price outputs are unchanged.Only cost model 1 gets a preset. A provisioned (EC2-like) preset for cost model 2 is not part of this PR.
How
Source: https://aws.amazon.com/fargate/pricing/, checked 2026-10-18. That copy of the page left the per-hour rate tables empty. The numbers come from the page's Pricing Example 1 ("Using the Linux/X86 pricing for US East (N. Virginia) Region where CPU cost: $0.000011244 per vCPU second, memory cost: $0.000001235 per GB per second, and ephemeral storage cost: $0.0000000308 per GB per second"). Per hour, that is $0.0404784 per vCPU-hour and $0.004446 per GB-hour.
The preset takes the deployment's
ResourceSpeed(PlanSelectionSettings::resource_speed), the speed Stage 3 uses for latency, so it charges exactly the core time the latency check counts. The values below are at the defaultResourceSpeed::illustrative()(1e-6 ms per operation, so 1e9 operations per core-second, and 1e-7 ms per scanned byte).cost_per_cpu_opms_per_cpu_op/ 1,000 (1e-9 s per operation)cost_per_scanned_bytems_per_scanned_byte/ 1,000 (1e-10 s per byte). Fargate has no scan price, but a scan occupies the vCPU-seconds it bills.cost_per_memory_byte_secondcost_per_disk_byte_secondcost_per_provisioned_memory_byte_secondcost_per_provisioned_cpu_core_secondProvisionedCapacity, every price the preset gives is 0, whichPlanSelectionSettings::validaterefuses (ZeroCalibration).The per-second prices cannot express two parts of Fargate billing. First, the 1-minute minimum per task ("Pricing is calculated per second with a 1-minute minimum"). Second, the fixed task sizes a task is billed for (from 0.25 vCPU with 0.5 GB up), which round usage up to the next size. The doc comment states both.
Key code interfaces added / modified
crates/plan-selection/src/lib.rscrates/devtools/src/bin/stage_pipeline.rsUsage
Example 4 (#509,
planner-layering-3b: a monthly 300 s p99 overlatency_mswith a rank ε = 0.01, δ = 0.01 target), priced at Fargate's prices. Verified at 64b8aae:The selection and ranking match the illustrative prices (P2 at 2.1 cost units/s). The ranking holds because Fargate's memory-to-CPU ratio (1 GiB-second ≈ 110 CPU-ms) is close to the illustrative one (1 GB-second = 125 CPU-ms).
Before this PR
The only prices were
ResourceUnitCost::illustrative()(1 cost unit = 1 CPU-ms).stage_pipeline --cost-modelaccepted onlyusage-over-time,provisioned-capacityandcluster-capacity. A dollar-scale cost in a rejection reason would have printed as0.000.After this PR
A Fargate deployment passes
CostModel::UsageOverTime(ResourceUnitCost::aws_fargate_us_east_1(settings.resource_speed))(or--cost-model aws-fargate-us-east-1) and gets each candidate's cost in US dollars per second, with the source and check date recorded next to the numbers.Limitations and follow-ups:
ResourceSpeedpassed in.stage_pipelinehas no speed flag, so it passes the defaultResourceSpeed::illustrative(1e9 ops per core-second).Verification
cargo nextest run -p asap-plan-selection -E 'test(aws_fargate)': the newaws_fargate_us_east_1_converts_the_page_priceschecks each field against its documented conversion at the illustrative speed and at a core twice as slow (CPU and scan prices double, memory unchanged), that cost model 1 validates, and that cost model 2 is refused withZeroCalibration. Passed.cargo nextest run -p asap-devtools --test stage_pipeline: 23 passed, including the newaws_fargate_preset_prices_example_4_in_dollars(P2 selected at $2.36124e-8/s, P3-m1 ≈ $1.2262e-4/s, P1's reason in scientific notation) and the unchangedcost_model_flag_chooses_how_candidates_are_compared. The reason assertion failed before the formatting fix (costlier: 0.000 vs 0.000).cargo fmt --all -- --checkandcargo clippy -p asap-plan-selection -p asap-devtools --all-targets --all-features --locked -- -D warnings: clean.Closes #742