cr-pricing
cr-pricing
A Crystal tool that estimates the monthly cost of a Google Cloud Run service using the request-based (pay-per-use) billing model.

It offers two interfaces:
- an interactive TUI (default) with sliders for the five primary inputs, built on the crysterm toolkit, and
- a scriptable CLI for flag-based, non-interactive estimates.
The free tier is intentionally ignored, so the estimate reflects the full metered cost of the configured workload. It also assumes that your application is non-thread-safe that processes one request at a time (i.e. concurrency = 1). This is certainly the worst case scenario, and it is very likely any real-world application can handle some level of concurrency. Therefore the cost estimate is probably too high, perhaps by a meaningful amount. Finally, egress network costs are not considered, since they are not part of the Cloud Run offering. My experience is that GCP networking costs for most Cloud Run applications are fairly low, and swamped out by the conservative nature of the overall estimate. However, if your application generates a significant amount of outbound data, it would be wise to account for that cost in any final estimate.
Installation
Build the executable with the Crystal compiler:
shards install # fetches dependencies (crysterm, ameba)
crystal build src/cr-pricing.cr -o bin/cr-pricing --release
Interactive TUI
Run with no arguments to launch the terminal UI:
./bin/cr-pricing
Four horizontal sliders control the primary inputs — CPU, memory, requests per month, and region — and the estimated monthly cost updates live as you adjust them.
| Key | Action |
|---|---|
↑ / ↓ (or k/j) |
Select a slider |
← / → (or h/l) |
Decrease / increase its value |
q / Esc |
Quit |
The TUI assumes an average request duration of 100 ms and concurrency of 1 (the CLI defaults); use the CLI to vary those.
Command-line usage
Pass any flag to use the non-interactive CLI:
./bin/cr-pricing [options]
| Flag | Description | Default |
|---|---|---|
-c, --cpu |
vCPU allocated per instance | 1 |
-m, --memory |
Memory in MiB per instance | 512 |
-r, --requests |
HTTP requests per month | 2000000 |
-R, --region |
Cloud Run region | us-central1 |
-d, --duration |
Average request duration in milliseconds | 100 |
-n, --concurrency |
Concurrent requests per instance | 1 |
--list-regions |
List supported regions and pricing tiers | — |
-h, --help |
Show help | — |
Example
TUI

CLI
$ ./bin/cr-pricing --cpu 1 --memory 512 --requests 2000000 --region us-central1
Google Cloud Run pricing estimate (request-based billing, free tier ignored)
==========================================================================
Configuration
Region: us-central1 (Tier 1)
CPU: 1 vCPU
Memory: 512 MiB
Requests: 2,000,000 / month
Avg duration: 100 ms
Concurrency: 1
Monthly cost breakdown
CPU: $4.80
Memory: $0.25
Requests: $0.80
------------------------------
Total: $5.85
How the estimate is calculated
With request-based billing, CPU and memory are only billed while an instance is actively handling a request (plus startup/shutdown). The monthly cost therefore depends on how long the average request runs, which is why --duration and --concurrency are exposed in addition to the four core inputs.
For each billed resource:
- Billable instance time =
requests × ceil(duration → 100 ms) ÷ concurrency. Cloud Run rounds active time up to the nearest 100 ms, and concurrent requests share a single instance's billed time. - CPU cost =
billable_seconds × cpu × cpu_rate - Memory cost =
billable_seconds × (memory_mib ÷ 1024) × memory_rate - Request cost =
(requests ÷ 1,000,000) × request_rate
Rates (USD, request-based active time)
Rates come from the Cloud Run pricing page and depend on the region's pricing tier:
| Resource | Tier 1 | Tier 2 |
|---|---|---|
| CPU (per vCPU-second) | $0.000024 |
$0.00003360 |
| Memory (per GiB-second) | $0.0000025 |
$0.00000350 |
| Requests (per million) | $0.40 |
$0.40 |
Run ./bin/cr-pricing --list-regions to see which tier a region belongs to.
Development
crystal spec # run the test suite
crystal tool format # auto-format the code
ameba # lint
Docker
I have pushed two built container images into DockerHub. It has two tags, depending on the architecture you are running. This should make things easier if you do not want to pull down the Crystal compiler. I will work on making a multi-architecture image available in the future.
docker run --rm -it nbrand/cr-pricing:arm64
docker run --rm -it nbrand/cr-pricing:amd64
Project layout
src/cr-pricing.cr # entrypoint: launches the TUI, or the CLI when given flags
src/cr-pricing/region.cr # region -> pricing tier mapping
src/cr-pricing/rates.cr # request-based pricing rates per tier
src/cr-pricing/calculator.cr# cost calculation (shared by TUI and CLI)
src/cr-pricing/cli.cr # flag parsing and report output
src/cr-pricing/tui.cr # interactive slider UI (crysterm)
spec/ # specs (crystal spec)
TODO
Fix some help artifacts in the TUI, near the bottom of the screen. Showing '?' when it should not.
Use of AI
I did use AI tooling to write this code. It wrote all the code, leveraging the AGENTS.md file, and various prompts to fine tune the output. I did not use any special skills or tooling. I used Cursor, and OPUS 4.8 for the implementation, with cheaper models for minor features and tooling (Git, README.md updates, etc...).
It took less than a day to implement the code, with another day for verification. If I was working straight, it would have taken just 1-2 hours. It cost about $20.
Contributing
- Fork it (https://github.com/your-github-user/cr-pricing/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Nick Brandaleone - creator and maintainer
cr-pricing
- 0
- 0
- 0
- 0
- 2
- about 12 hours ago
- July 17, 2026
MIT License
Sat, 18 Jul 2026 14:57:37 GMT