simonw / datasette-publish-fly

Datasette plugin for publishing data using Fly
Apache License 2.0
20 stars 7 forks source link

Let users specify the instance size to be used #2

Open simonw opened 4 years ago

simonw commented 4 years ago

https://fly.io/docs/pricing/ lists four options:

Fly_App_Pricing_·_Fly

It would be great if you could run datasette publish fly data.db --size=cpu1 to deploy with a larger instance.

simonw commented 4 years ago

It looks like you do this using the flyctl scale vm command - but the docs at https://fly.io/docs/flyctl/scale-vm/ are missing some details.

Filed a documentation bug with Fly about that here: https://github.com/superfly/flyctl/issues/83

simonw commented 4 years ago

I can get the list of available sizes like so:

~ $ flyctl platform vm-sizes
  NAME       CPU CORES   MEMORY   PRICE (SECOND)   PRICE (MONTH)  
  micro-1x   0.12        128 MB   $0.000001        $2.670000      
  micro-2x   0.25        512 MB   $0.000003        $8.000000      
  cpu1mem1   1           1 GB     $0.000013        $35.000000     
  cpu2mem2   2           2 GB     $0.000027        $70.000000     
  cpu4mem4   4           4 GB     $0.000053        $140.000000    
  cpu8mem8   8           8 GB     $0.000107        $280.000000    

Displaying the price to users feels useful here.

simonw commented 4 years ago

flyctl platform vm-sizes --json

[
    {
        "Name": "micro-1x",
        "CPUCores": 0.125,
        "MemoryGB": 0.125,
        "MemoryMB": 128,
        "PriceMonth": 2.67,
        "PriceSecond": 0.000001015
    },
    {
        "Name": "micro-2x",
        "CPUCores": 0.25,
        "MemoryGB": 0.5,
        "MemoryMB": 512,
        "PriceMonth": 8,
        "PriceSecond": 0.000003044
    },
    {
        "Name": "cpu1mem1",
        "CPUCores": 1,
        "MemoryGB": 1,
        "MemoryMB": 1024,
        "PriceMonth": 35,
        "PriceSecond": 0.000013318
    },
    {
        "Name": "cpu2mem2",
        "CPUCores": 2,
        "MemoryGB": 2,
        "MemoryMB": 2048,
        "PriceMonth": 70,
        "PriceSecond": 0.000026636
    },
    {
        "Name": "cpu4mem4",
        "CPUCores": 4,
        "MemoryGB": 4,
        "MemoryMB": 4096,
        "PriceMonth": 140,
        "PriceSecond": 0.000053272
    },
    {
        "Name": "cpu8mem8",
        "CPUCores": 8,
        "MemoryGB": 8,
        "MemoryMB": 8192,
        "PriceMonth": 280,
        "PriceSecond": 0.000106544
    }
]
simonw commented 3 years ago

That's disappointing: I tried this command again today and it doesn't return accurate pricing information any more:

~ % flyctl platform vm-sizes --json
[
    {
        "Name": "shared-cpu-1x",
        "CPUCores": 1,
        "MemoryGB": 0,
        "MemoryMB": 256,
        "PriceMonth": 0,
        "PriceSecond": 0
    },
    {
        "Name": "dedicated-cpu-1x",
        "CPUCores": 1,
        "MemoryGB": 0,
        "MemoryMB": 2048,
        "PriceMonth": 0,
        "PriceSecond": 0
    },
...
simonw commented 3 years ago

Filed that as a bug: https://github.com/superfly/flyctl/issues/339

simonw commented 3 years ago

Today the command returns this:

[
    {
        "Name": "shared-cpu-1x",
        "CPUCores": 1,
        "MemoryGB": 0.25,
        "MemoryMB": 256,
        "PriceMonth": 1.94,
        "PriceSecond": 7.5e-7,
        "MemoryIncrementsMB": [
            256,
            1024,
            2048
        ]
    },
    {
        "Name": "dedicated-cpu-1x",
        "CPUCores": 1,
        "MemoryGB": 2,
        "MemoryMB": 2048,
        "PriceMonth": 31,
        "PriceSecond": 0.00001196,
        "MemoryIncrementsMB": [
            2048,
            4096,
            8192
        ]
    },
    {
        "Name": "dedicated-cpu-2x",
        "CPUCores": 2,
        "MemoryGB": 4,
        "MemoryMB": 4096,
        "PriceMonth": 62,
        "PriceSecond": 0.00002392,
        "MemoryIncrementsMB": [
            4096,
            8192,
            16384
        ]
    },
    {
        "Name": "dedicated-cpu-4x",
        "CPUCores": 4,
        "MemoryGB": 8,
        "MemoryMB": 8192,
        "PriceMonth": 124,
        "PriceSecond": 0.00004784,
        "MemoryIncrementsMB": [
            8192,
            16384,
            32768
        ]
    },
    {
        "Name": "dedicated-cpu-8x",
        "CPUCores": 8,
        "MemoryGB": 16,
        "MemoryMB": 16384,
        "PriceMonth": 248,
        "PriceSecond": 0.00009568,
        "MemoryIncrementsMB": [
            16384,
            32768,
            65536
        ]
    }
]
simonw commented 3 years ago

The command for this is:

flyctl scale vm dedicated-cpu-1x

You can pass an optional --memory option:

flyctl scale vm dedicated-cpu-1x --memory=2048

The docs are at https://fly.io/docs/flyctl/scale-vm/

Valid memory values aren't completely clear. Documentation says:

For dedicated vms, this should be a multiple of 1024MB.

For shared vms, this can be 256MB or a a multiple of 1024MB.

But... the output of flyctl platform vm-sizes --json includes a MemoryIncrementsMB key which looks like this for the largest instance:

{
    "Name": "dedicated-cpu-8x",
    "CPUCores": 8,
    "MemoryGB": 16,
    "MemoryMB": 16384,
    "PriceMonth": 248,
    "PriceSecond": 0.00009568,
    "MemoryIncrementsMB": [
        16384,
        32768,
        65536
    ]
}

Are those three values the only valid options for --memory?

simonw commented 3 years ago

Posted a question about this here: https://github.com/superfly/flyctl/issues/478