superfly / flyctl

Command line tools for fly.io services
https://fly.io
Apache License 2.0
1.4k stars 235 forks source link

pricing via API :) #2230

Open gedw99 opened 1 year ago

gedw99 commented 1 year ago

Can you add pricing to the CLI for automation purposes and make it optionally return JSON.

For example with Hertzer you can pick a server type and get all the info you need.

https://github.com/hetznercloud/cli

hcloud server-type describe ccx22
ID:             34
Name:           ccx22
Description:    CCX22 Dedicated CPU
Cores:          4
CPU Type:       dedicated
Architecture:   x86
Memory:         16.0 GB
Disk:           160 GB
Storage Type:   local
Pricings per Location:
  - Location:   nbg1:
    Hourly:     € 0.0775880000000000
    Monthly:    € 45.1010000000000000
  - Location:   hel1:
    Hourly:     € 0.0775880000000000
    Monthly:    € 45.1010000000000000
  - Location:   hil:
    Hourly:     € 0.0775880000000000
    Monthly:    € 45.1010000000000000
  - Location:   ash:
    Hourly:     € 0.0775880000000000
    Monthly:    € 45.1010000000000000
  - Location:   fsn1:
    Hourly:     € 0.0775880000000000
    Monthly:    € 45.1010000000000000

hcloud server-type describe -o json ccx22

{
    "architecture": "x86",
    "cores": 4,
    "cpu_type": "dedicated",
    "deprecated": false,
    "description": "CCX22 Dedicated CPU",
    "disk": 160,
    "id": 34,
    "memory": 16,
    "name": "ccx22",
    "prices": [
        {
            "location": "nbg1",
            "price_hourly": {
                "gross": "0.0775880000000000",
                "net": "0.0652000000"
            },
            "price_monthly": {
                "gross": "45.1010000000000000",
                "net": "37.9000000000"
            }
        },
        {
            "location": "hel1",
            "price_hourly": {
                "gross": "0.0775880000000000",
                "net": "0.0652000000"
            },
            "price_monthly": {
                "gross": "45.1010000000000000",
                "net": "37.9000000000"
            }
        },
        {
            "location": "hil",
            "price_hourly": {
                "gross": "0.0775880000000000",
                "net": "0.0652000000"
            },
            "price_monthly": {
                "gross": "45.1010000000000000",
                "net": "37.9000000000"
            }
        },
        {
            "location": "ash",
            "price_hourly": {
                "gross": "0.0775880000000000",
                "net": "0.0652000000"
            },
            "price_monthly": {
                "gross": "45.1010000000000000",
                "net": "37.9000000000"
            }
        },
        {
            "location": "fsn1",
            "price_hourly": {
                "gross": "0.0775880000000000",
                "net": "0.0652000000"
            },
            "price_monthly": {
                "gross": "45.1010000000000000",
                "net": "37.9000000000"
            }
        }
    ],
    "storage_type": "local"
}

they also have interval at cli level globally so you can get real time info... Its pretty neat.

Global Flags:
      --poll-interval
kzys commented 1 year ago

Do you have specific things you'd like to do with that information, like launching machines in the cheapest region?

gedw99 commented 1 year ago

Hey @kzys

I have to run servers on GCP, hetzner, and now Fly for large machine learning runs.

So if pricing is part of the API it would mean i can do adaptive deployment. GCP and AWS offer spot price VMS for this and also have an API for real time spot pricing.

Now i know fly does NOT have spot pricing...

I have no idea if Fly offers MOQ ( minimum order quantity ) style pricing yet, but right now i just need pricing at the API level to write my code against.

We then run our benchmark on each fly machine to get what we can a Grunt co-efficient. This Grunt coefficient gives us a rating of the performance on FLY as well as GCP and Hetzner.

Then i can work that back against the pricing to have a Grunt price / hr :)

Oh and launching in cheapest regions would be cool. A bit like the Hetzner API example where you can watch the feed per region.

If You need to contact me directly my github profile has contacts.