I’m curious about the usage/credits/cost implications of resuming & suspending a warehouse multiple times within one minute (whether this happens manually or automatically).
The use case is for very short workloads with an unpredictable schedule (may be with or without overlap):
- Is it better to suspend the warehouse immediately at the end of each workload (assuming no other workload is running), and incur another 60 seconds of credits if it gets resumed immediately?
- Or would it be better to leave the warehouse running/idle for some time? (in the hopes of avoiding unnecessary charges of 60 seconds minimum, but with the possibility of costing more due to the increased idle time)
The Snowflake documentation is slightly ambiguous regarding this edge case.
From 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.
From 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).
What I’m looking for would be an example along the lines of:
- If a warehouse runs for 10 seconds, shuts down, and then immediately restarts and runs for another 10 seconds:
- is it billed for 60 seconds?
- or is it billed for 120 seconds (60 + 60)?
I assume it is the latter, but I would like to know for sure.
>Solution :
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;
with the last three steps done twice, with 5 seconds of pause.
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 |
Done twice, just incase as the first was sloppy. It seems to bill per minute as noted.