Skip to content

Estimating Costs

vzakaznikov edited this page Mar 20, 2024 · 15 revisions

Estimating Costs

✅ Available: >= 1.7

You can get an estimated cost for a job, a run, or a set of runs using the estimate command. The estimator will show typical worst-case and best-case cost scenarios.

All costs are in Euros (€).

❗Warning: Manual monitoring is required to make sure server instances are cleaned up properly and costs are kept under control.

The cost estimator works using the new runner names, which include server type and server location in the runner name.

Runner name:

github-hetzner-runner-{run id}-{job id}-{server type}-{server location}

For example,

github-hetzner-runner-8315964014-22754907649-cx11-hel1

Estimating costs for a given job

You can estimate costs for a given job using the estimate job command and passing it the id of the job.

For example,

github-hetzner-runners estimate job 22754907649

Estimating costs for a given run

You can estimate costs for a given run using the estimate run command and passing it the id of the run.

For example,

github-hetzner-runners estimate run 8315964014

Optionally, if you want to get an estimate for a specific attempt, you can specify the attempt number using the --attempt option.

For example,

github-hetzner-runners estimate run 8315964014 --attempt 1

Estimating costs for different runs

You can estimate costs for different runs using the estimate runs command.

You can specify the following options to select specific runs:

Options:
  • --actor name actor name
  • --branch name branch name
  • --event name event name
  • --status {queued,in_progress,completed,success,failure,neutral,cancelled,skipped,timed_out,action_required} status value
  • --exclude-pull-requests exclude pull requests
  • --head-sha value head SHA value

The command will show estimates for one run at a time, and you will have to press Ctrl-D to continue to the next run.

For example,

$ github-hetzner-runners estimate runs
10:40:00 🍀 Logging in to Hetzner Cloud
...
✋ Press any key to continue (Ctrl-D to abort)...

Limitations

Calculating costs for runs created by versions <= 1.7 is not supported.

Costs are estimated using the latest server prices that are pulled up from Hetzner Cloud during the command execution.

The costs of the server used to run the cloud service are not included.

The costs for IPv4 and IPv6 addresses are fixed at 0.0008 and 0.0000, respectively, but can be manually modified using the --ipv4 and --ipv6 options.

Options:
  • --ipv4 price IPv4 price per hour, default: 0.0008
  • --ipv6 price IPv6 price per hour, default: 0.0000

The cost estimator only shows typical worst-case and best-case scenarios.

❗Warning:

The actual costs can vary significantly due to various factors, including but not limited to the following:

  • Time it takes to set up and delete the server
  • Failures to delete old servers
  • Failures in server setup
  • Disabling server recycling
  • Differences in prices between now and when the job was actually executed
  • etc.

Also,

❗Warning: The server setup and tear-down time are not included in the calculations.

How costs are calculated

✋ Note: Costs are estimated using the latest server prices that are pulled up from Hetzner Cloud during the command execution. Therefore, any differences in prices between when the job was actually executed and the current prices are not accounted for. All costs are in Euros (€).

The typical worst-case scenario is calculated as follows:

math.ceil(duration.total_seconds() / 3600) * 3600 * price

and gives the cost assuming the server usage is billed per hour and is not reused for any other jobs; therefore, the duration of the job is rounded to the nearest hour.

The best-case scenario is calculated as follows:

duration.total_seconds() * price

and gives the idealized cost assuming the server is utilized 100% and absolutely no time is wasted in setting up a server or switching between the jobs.

The actual costs will vary, and in typical cases, they should be somewhere between the worst-case and best-case scenarios.

Unknown jobs

The number of jobs and their duration, for which costs could not be estimated, will be reflected as follows:

unknown_jobs: 1
unknown_duration: 0:00:11

Saving output to a file

You can save the output of any estimate commands to a file using the -o, --output option. The contents of the file will be in YAML format.

For example,

estimate.yaml:
- name: vzakaznikov is testing out GitHub Actions 🚀
  id: 8345322092
  attempt: 1
  jobs:
    - name: Explore-GitHub-Actions
      id: 22839957391
      status: completed
      started_at: 2024-03-19 15:04:00
      completed_at: 2024-03-19 15:04:23
      duration: 00:00:23
      url: https://api.github.com/repos/testflows/TestFlows-GitHub-Hetzner-Runners/actions/jobs/22839957391
      run_id: 8345322092
      run_url: https://api.github.com/repos/testflows/TestFlows-GitHub-Hetzner-Runners/actions/runs/8345322092
      runner_id: 1047
      runner_name: github-hetzner-runner-8333499151-22805094091-cx11-hel1
      runner_group_id: 1
      runner_group_name: Default
      workflow_name: vzakaznikov is testing out GitHub Actions 🚀
      estimate:
        servers:
        - type: cx11
          location: hel1
          price: 0.006000
          duration: 00:00:23
          worst: 0.006000
          best: 0.000038
        worst: 0.006000
        best: 0.000038
  total:
    jobs: 1
    duration: 00:00:23
  known:
    jobs: 1
    duration: 00:00:23
  unknown:
    jobs: 0
    duration: 00:00:00
  estimate:
    servers:
    - type: cx11
      location: hel1
      price: 0.006000
      duration: 00:00:23
      worst: 0.006000
      best: 0.000038
    worst: 0.006000
    best: 0.000038

Command Options

The estimate command supports the following options:

Options:
  • estimate cost estimator commands
    • -o path, --output path save estimate into the given file using the YAML format
    • --ipv4 price IPv4 price per hour, default: 0.0008
    • --ipv6 price IPv6 price per hour, default: 0.0000
    • run run cost estimator
      • id run id
      • --attempt number attempt number
    • job job cost estimator
      • id job id
    • runs runs cost estimator
      • --actor name actor name
      • --branch name branch name
      • --event name event name
      • --status {queued,in_progress,completed,success,failure,neutral,cancelled,skipped,timed_out,action_required} status value
      • --exclude-pull-requests exclude pull requests
      • --head-sha value head SHA value
Clone this wiki locally