Snowflake中仓库重复停复工的信用使用
Credit usage of repetitive warehouse suspension & resumption in Snowflake
我很好奇 usage/credits/cost 在一分钟内多次恢复和暂停仓库的影响(无论是手动还是自动发生)。
Snowflake 文档对于这种极端情况有些含糊不清。
来自Virtual Warehouse Credit Usage:
The credit numbers shown here are for a full hour of usage; however, credits are billed per-second, with a 60-second (i.e. 1-minute) minimum:
- Each time a warehouse is started or resized to a larger size, the warehouse is billed for 1 minute’s worth of usage based on the hourly rate shown above.
- Stopping and restarting a warehouse within the first minute does not change the amount billed; the minimum billing charge is 1 minute.
来自How are Credits Charged for Warehouses?:
When warehouses are provisioned:
- The minimum billing charge for provisioning a warehouse is 1 minute (i.e. 60 seconds).
- There is no benefit to stopping a warehouse before the first 60-second period is over because the credits have already been billed for that period.
- After the first 60 seconds, all subsequent billing for a running warehouse (until it is shut down). Three examples are provided below:
- If a warehouse runs for 30 to 60 seconds, it is billed for 60 seconds.
- If a warehouse runs for 61 seconds, it is billed for only 61 seconds.
- If a warehouse runs for 61 seconds, shuts down, and then restarts and runs for less than 60 seconds, it is billed for 121 seconds (60 + 1 + 60).
我正在寻找的示例如下:
- 如果一个仓库运行10秒,关机,然后立即重启,再运行10秒:
- 是否按 60 秒计费?
- 还是按120秒(60+60)计费?
我假设是后者,但我想确定一下。
create warehouse timetest2 WAREHOUSE_SIZE = XSMALL INITIALLY_SUSPENDED = TRUE;
use warehouse timetest2;
alter warehouse timetest2 RESUME;
select sum(random())
from table(generator(TIMELIMIT => 10));
alter warehouse timetest2 SUSPEND;
最后三个步骤完成两次,暂停 5 秒。
select start_time,
warehouse_name,
credits_used_compute,
round(credits_used_compute * 60,3) as minutes_billed
from table(information_schema.warehouse_metering_history(dateadd('hour',-1,current_timestamp)));
START_TIME
WAREHOUSE_NAME
CREDITS_USED_COMPUTE
MINUTES_BILLED
2022-04-16 15:32:36.000 -0700
TIMETEST2
0.033333333
2
2022-04-16 15:32:36.000 -0700
TIMETEST
0.033333333
2
做了两次,以防第一次草率。如前所述,它似乎是按分钟计费。
只是 运行 一些测试,结果很清楚:
每次重新启动仓库(无论上下文或上次暂停时间),都会产生 60 秒的最低费用。
我用中型仓库测试(每分钟 4/60 学分):
- 恢复 6 次,间隔分钟:0.40 学分
- 同一分钟内恢复 6 次:0.40 积分
我很好奇 usage/credits/cost 在一分钟内多次恢复和暂停仓库的影响(无论是手动还是自动发生)。
Snowflake 文档对于这种极端情况有些含糊不清。
来自Virtual Warehouse Credit Usage:
The credit numbers shown here are for a full hour of usage; however, credits are billed per-second, with a 60-second (i.e. 1-minute) minimum:
- Each time a warehouse is started or resized to a larger size, the warehouse is billed for 1 minute’s worth of usage based on the hourly rate shown above.
- Stopping and restarting a warehouse within the first minute does not change the amount billed; the minimum billing charge is 1 minute.
来自How are Credits Charged for Warehouses?:
When warehouses are provisioned:
- The minimum billing charge for provisioning a warehouse is 1 minute (i.e. 60 seconds).
- There is no benefit to stopping a warehouse before the first 60-second period is over because the credits have already been billed for that period.
- After the first 60 seconds, all subsequent billing for a running warehouse (until it is shut down). Three examples are provided below:
- If a warehouse runs for 30 to 60 seconds, it is billed for 60 seconds.
- If a warehouse runs for 61 seconds, it is billed for only 61 seconds.
- If a warehouse runs for 61 seconds, shuts down, and then restarts and runs for less than 60 seconds, it is billed for 121 seconds (60 + 1 + 60).
我正在寻找的示例如下:
- 如果一个仓库运行10秒,关机,然后立即重启,再运行10秒:
- 是否按 60 秒计费?
- 还是按120秒(60+60)计费?
我假设是后者,但我想确定一下。
create warehouse timetest2 WAREHOUSE_SIZE = XSMALL INITIALLY_SUSPENDED = TRUE;
use warehouse timetest2;
alter warehouse timetest2 RESUME;
select sum(random())
from table(generator(TIMELIMIT => 10));
alter warehouse timetest2 SUSPEND;
最后三个步骤完成两次,暂停 5 秒。
select start_time,
warehouse_name,
credits_used_compute,
round(credits_used_compute * 60,3) as minutes_billed
from table(information_schema.warehouse_metering_history(dateadd('hour',-1,current_timestamp)));
START_TIME | WAREHOUSE_NAME | CREDITS_USED_COMPUTE | MINUTES_BILLED |
---|---|---|---|
2022-04-16 15:32:36.000 -0700 | TIMETEST2 | 0.033333333 | 2 |
2022-04-16 15:32:36.000 -0700 | TIMETEST | 0.033333333 | 2 |
做了两次,以防第一次草率。如前所述,它似乎是按分钟计费。
只是 运行 一些测试,结果很清楚:
每次重新启动仓库(无论上下文或上次暂停时间),都会产生 60 秒的最低费用。
我用中型仓库测试(每分钟 4/60 学分):
- 恢复 6 次,间隔分钟:0.40 学分
- 同一分钟内恢复 6 次:0.40 积分