GCP Cloud Tasks Queue
GCP Cloud Tasks Queue
Made by
Massdriver
Official
Yes
Clouds
Tags
Google Cloud Tasks Queue
Google Cloud Tasks is a fully managed service that allows you to execute tasks asynchronously within your applications. This service enables you to decouple your application logic from background work, improving modularity and enabling more scalable design patterns.
Design Decisions
- Rate Limits: The queue can be configured with custom rate limits, including maximum concurrent dispatches and maximum dispatches per second.
- Retry Configuration: The retry behavior for tasks is flexible, allowing customization of maximum attempts, retry durations, backoff parameters, and doublings.
- Monitoring: Automated alarms for queue depth monitoring can be set up to alert on potential issues, ensuring timely interventions.
- IAM Roles: Specific IAM roles for enqueuer and task runner are defined with conditions to limit their scope to relevant resources.
- APIs Enablement: The necessary APIs (e.g., App Engine API, Cloud Tasks API) are enabled to ensure all required services are activated for the queue to function.
- Logging: Stackdriver logging configurations are added to sample logs at a specified ratio, aiding in the visibility and troubleshooting of the queue operations.
Runbook
Trouble Connecting or Accessing Cloud Tasks Queue
If you experience issues connecting to or accessing your Cloud Tasks Queue, check the following:
Verify that the required APIs are enabled:
gcloud services list --enabled | grep -E 'appengine.googleapis.com|cloudtasks.googleapis.com'
If the required APIs are not listed, enable them:
gcloud services enable appengine.googleapis.com cloudtasks.googleapis.com
Queue Depth Exceeds Threshold
If you receive an alert that the queue depth is too high, inspect the queue state:
gcloud tasks queues describe YOUR_QUEUE_NAME --location=YOUR_LOCATION
Ensure that the rate limits are set appropriately and that there are no bottlenecks in task execution.
Task Failures or Retries
Check the status and count of tasks that have failed or are being retried frequently:
gcloud tasks tasks list --queue=YOUR_QUEUE_NAME --location=YOUR_LOCATION
To retrieve details about a specific task:
gcloud tasks tasks describe YOUR_TASK_NAME --queue=YOUR_QUEUE_NAME --location=YOUR_LOCATION
Review the retry configuration to ensure it is set according to your needs:
gcloud tasks queues describe YOUR_QUEUE_NAME --location=YOUR_LOCATION --format="yaml(retryConfig)"
Adjust retry settings if necessary to better handle failures.
IAM Role Issues
If tasks cannot be enqueued or executed, check IAM policies for the necessary roles:
gcloud projects get-iam-policy YOUR_PROJECT_ID
Ensure that the roles cloudtasks.enqueuer
and cloudtasks.taskRunner
have the required permissions and that their conditions are met.
gcloud iam roles describe roles/cloudtasks.enqueuer roles/cloudtasks.taskRunner --project=YOUR_PROJECT_ID
Ensure conditions in the roles are correct and end with your queue's name prefix as expected.
Variable | Type | Description |
---|---|---|
location | string | No description |
resource_config.logging.sampling_ratio | number | No description |
resource_config.rate_limits.max_concurrent_dispatches | number | No description |
resource_config.rate_limits.max_dispatches_per_second | number | No description |
resource_config.retry_config.max_attempts | integer | No description |
resource_config.retry_config.max_backoff_s | integer | No description |
resource_config.retry_config.max_doublings | integer | No description |
resource_config.retry_config.max_retry_duration_s | integer | No description |
resource_config.retry_config.min_backoff_s | integer | No description |