Monitor usage and control costs
DuckDB queries run on compute measured in Data Processing Units (DPUs). You control how much compute a query and a workgroup can use with workgroup settings, and you read each query's resource usage from the API.
Set DPU limits
Set DPU limits on a DuckDB workgroup in its engine configuration, under the athena-execution-properties classification. Use min-dpu-count and max-dpu-count to bound the compute that queries in the workgroup can use. max-dpu-count caps the compute a single query can consume, which limits the work a runaway query can do. A query can run across several workers only when max-dpu-count is 8 DPUs or more, or is not set. For more information, see Query execution.
To make the workgroup's settings apply to every query, including queries submitted with client-side overrides, set EnforceWorkGroupConfiguration to true in the workgroup configuration. When this setting is true, Athena uses the workgroup's settings and ignores client-side settings that would override them.
DPU sizing and the DPU range
This section describes how Amazon Athena sizes the compute for your DuckDB queries in Data Processing Units (DPUs). It also describes how to set a DPU range, how the DPU range affects billing, and the errors that a DPU range can cause. The DPU range is the minimum DPU count and the maximum DPU count that you set for your queries. Before you set a DPU range, make sure that you know how to create and update workgroups.
You can use a DPU range to control how much compute your queries use. In Athena, each DuckDB query runs on serverless compute that Athena measures in DPUs. Each DPU typically provides 4 vCPU and 16 GB of memory. Athena sizes the compute for each query.
Athena runs each query on one compute size, which Athena picks from the available sizes. The sizes currently include 1 DPU, 4 DPUs, and larger sizes. No size is currently between 1 DPU and 4 DPUs. The largest size for a single query depends on the AWS Region. The following table lists the current largest size that Athena provides in each Region.
| Region | Largest size for a single query |
|---|---|
| US East (N. Virginia) | 124 DPUs |
| US East (Ohio) | 60 DPUs |
| US West (Oregon) | 124 DPUs |
| Asia Pacific (Tokyo) | 60 DPUs |
| Europe (Ireland) | 124 DPUs |
You can set the DPU range for the queries in a workgroup or for a single query. With Athena, most queries then run on a compute size that is inside your DPU range. Some queries run on a single worker and use at most 4 DPUs, regardless of the DPU range. For more information, see Query execution. If your minimum is larger than the largest size for your Region, the query runs on the largest size. For instructions on setting the DPU range, see Set DPU limits.
Valid values for the DPU range
To make sure that your DPU range is valid, Athena checks the min-dpu-count and max-dpu-count values that you set. Athena does this check when you create or update a workgroup that uses DuckDB, or when you start a query. Each value that you set is one end of the DPU range, and it does not have to match a size. For example, a DPU range of 0.5 to 2.75 runs on the 1-DPU size. The following table lists the rules that each value must meet.
| Rule | Valid values |
|---|---|
| The value must be inside the allowed range. The allowed range is currently 0.25 to 124. | 0.25, 16, 124 |
| The value must be a multiple of 0.25. | 0.5, 1, 2.75, 4 |
| A value greater than 16 must be a multiple of 4. | 20, 64, 124 |
The max-dpu-count value must be greater than or equal to the min-dpu-count value. | A min-dpu-count of 1 and a max-dpu-count of 4 |
The following table lists the default value of each setting.
| Setting | Default |
|---|---|
min-dpu-count | 0.25 |
max-dpu-count | 124. A query does not run on a size larger than the largest size for its Region. For the largest size in each Region, see DPU sizing and the DPU range. |
A DPU range can pass these checks and still cause an error when the query starts. A DPU range of 2 to 3 currently matches no size, so Athena fails the query when it starts. For more information about this error, see No valid compute size fits the requested DPU range.
Billing and the DPU range
Athena bills a query for the DPUs that the query runs on and the time that they run. For instructions on reviewing the compute that a query used, see Review usage with GetQueryExecution. For current pricing, see Amazon Athena pricing
The minimum DPU count is not a minimum charge. A query can be billed for less than the minimum that you set.
Troubleshoot DPU range errors
Athena checks the DPU range at two points. First, Athena checks the values in the CreateWorkGroup, UpdateWorkGroup, or StartQueryExecution request. Then, when the query starts, Athena checks that an available size fits the DPU range.
InvalidRequestException
When the request has a value that is not valid, Athena rejects the request with an InvalidRequestException. The following table lists the cause of each error and the error message.
| Cause | Error message |
|---|---|
The min-dpu-count or max-dpu-count value is not a number. | Min DPU Count must be a valid number. |
The min-dpu-count or max-dpu-count value is outside the allowed range. | Max DPU Count must be in the range of 0.25 to 124.0. |
The min-dpu-count or max-dpu-count value is not a multiple of 0.25. | Min DPU Count must be a multiple of 0.25. |
The min-dpu-count or max-dpu-count value is greater than 16 and is not a multiple of 4. | Max DPU Count above 16 must be a multiple of 4. |
The max-dpu-count value is less than the min-dpu-count value. | Max DPU Count (1.0) must be greater than or equal to Min DPU Count (4.0). |
No valid compute size fits the requested DPU range
This error can happen when no available size is between the minimum and the maximum that you set. A DPU range of 2 to 3 falls between the 1-DPU and 4-DPU sizes, so it causes this error.
For this error, Athena accepts the query. Then Athena fails the query before the query uses any compute. The query state is FAILED. The error message has this form: No valid compute size fits the requested DPU range (min 2, max 3). Change the min or max DPU and run the query again.
To read the message, call GetQueryExecution and check Status.StateChangeReason or Status.AthenaError.ErrorMessage. The error is a user error, so Status.AthenaError.ErrorCategory is 2. For more information about error categories, see Error category.
Do these steps to fix the error:
Choose
min-dpu-countandmax-dpu-countvalues that include an available size, or remove the DPU range.Update
min-dpu-countandmax-dpu-countin the workgroup or in the query.Run the query again.
For instructions on setting the DPU range, see Set DPU limits.
BytesScannedCutoffPerQuery is not enforced
A DuckDB workgroup accepts BytesScannedCutoffPerQuery, but does not enforce it, so this setting gives a DuckDB workgroup no per-query cutoff. To cap the work a query can do, use the DPU limits described in the preceding section, and create Amazon CloudWatch alarms on your usage metrics.
Dependent AWS services
Your queries read and write data in your own account, and those services bill you at their normal rates:
| Service | What you are charged for |
|---|---|
| Amazon S3 | GET and LIST requests and data transfer for source data your queries read; PUT requests and storage for data your queries write |
| AWS Glue Data Catalog | Metadata requests such as table and partition lookups, and stored metadata objects |
| AWS KMS |
Decrypt and GenerateDataKey requests when source, output, or managed results are encrypted with your own AWS KMS key
|
| Amazon CloudWatch |
Query metrics published when the workgroup sets PublishCloudWatchMetricsEnabled to true, and any alarms you create. New DuckDB workgroups publish query metrics by default. To turn this off, set PublishCloudWatchMetricsEnabled to false when you create or update the workgroup.
|
When query results are stored in managed query results, you are not charged for results storage or for requests to read results.
Review usage with GetQueryExecution
GetQueryExecution is where you see what each query consumed. Two fields on QueryExecution.Statistics report DPU usage:
| Field | Meaning |
|---|---|
DpuConsumedInMillis
|
DPU-milliseconds the query consumed. |
DpuCount
|
Peak DPUs running concurrently at any point during the query. Not a total. |
After a query completes, the DPU usage metrics in the query statistics, such as DpuCount, are not published immediately. GetQueryExecution and BatchGetQueryExecution omit these values for a couple of minutes while Athena finishes recording usage. If the metrics are missing from the response, call the API again after several minutes.
During the preview, Athena might return DpuCount and DpuConsumedInMillis metrics that vary for the same query.
The dpu_count column of the query_executions system table is not currently populated for DuckDB queries. Use GetQueryExecution to see the DPU usage of a DuckDB query.
In Amazon CloudWatch, the ProcessedBytes metric is always 0 for DuckDB queries. To see how much data a query read, use DataScannedInBytes instead.