Skip to main content

Certification track: AI Tooling

Crawl4AI on Google Cloud Run

Crawl4AI on Google Cloud Run

Crawl4AI is an open-source LLM-friendly web crawler and scraper. This module deploys Crawl4AI on Cloud Run v2 on top of the App_CloudRun foundation, which provisions and manages the shared Google Cloud infrastructure.

This guide focuses on the cloud services Crawl4AI uses and how to explore and operate them from the Google Cloud Console and the command line. For the mechanics common to every Cloud Run application — service identity, ingress and load balancing, scaling and concurrency, CI/CD, Cloud Armor, IAP, Binary Authorization, VPC Service Controls, backups, and the deployment lifecycle — refer to the App_CloudRun foundation guide rather than repeating them here.


1. Overview

Crawl4AI runs as a Python/ASGI container on Cloud Run v2 Gen2. The deployment wires together a focused set of Google Cloud services:

CapabilityGoogle Cloud serviceNotes
ComputeCloud Run v2 (Gen2)Python service, 1 vCPU / 4 GiB by default, request-based autoscaling
Task queueEmbedded Redis (in-container)Supervisord starts Redis inside the container; ephemeral per instance
ASGI serverEmbedded Gunicorn (in-container)Port 11235, managed by supervisord alongside Redis
Object storageCloud StorageOptional buckets for crawl result caching (none by default)
SecretsSecret ManagerAPI keys and JWT secret injected at runtime
IngressCloud Run URL / Cloud Load BalancingDefault run.app URL, optional external HTTPS load balancer + custom domain

Sensible defaults worth knowing up front:

  • No external database. database_type is fixed to NONE — Cloud SQL is not provisioned. All task state lives in the in-container Redis instance and is lost when the container restarts.
  • Gen2 is required. Supervisord needs a full Linux process tree, and Chromium uses /tmp for shared memory via --disable-dev-shm-usage. Gen1 cannot support this.
  • ALL_TRAFFIC egress is required. The crawler must reach arbitrary public URLs on the internet; PRIVATE_RANGES_ONLY blocks all external crawl targets.
  • Redis runs inside the container. Do not set REDIS_HOST or REDIS_PORT as environment variables — they must stay at localhost:6379 to reach the bundled instance.
  • Security is off by default. JWT authentication requires providing a SECRET_KEY via secret_environment_variables and a custom config.yml with security.jwt_enabled=true.

2. Google Cloud Services & How to Explore Them

All commands assume PROJECT and REGION are set. Service and resource names are reported in the deployment Outputs.

A. Cloud Run — the Crawl4AI service

Crawl4AI runs as a Cloud Run v2 Gen2 service that autoscales by request load between the minimum and maximum instance counts. Each deployment creates an immutable revision; traffic can be split across revisions for safe rollouts. Each instance runs its own supervisord tree: Redis (priority 10) starts first, then Gunicorn (priority 20).

  • Console: Cloud Run → select the service for revisions, traffic, logs, and metrics.
  • CLI:
    gcloud run services list --project "$PROJECT" --region "$REGION"
    gcloud run services describe <service-name> --project "$PROJECT" --region "$REGION"
    gcloud run revisions list --service <service-name> --project "$PROJECT" --region "$REGION"

See App_CloudRun for scaling, concurrency, execution environment, and traffic splitting.

B. Embedded Redis and task queue

Redis runs inside each container instance as a supervisord-managed process on localhost:6379. It stores task results with a configurable TTL (redis_task_ttl_seconds, default 3600 s). Task results are lost when the container restarts — this is expected for an ephemeral crawl API. There is no Memorystore instance; the embedded Redis does not appear in the Console.

There is no direct shell access on Cloud Run, but you can observe Redis behaviour from logs:

gcloud run services logs read <service-name> --project "$PROJECT" --region "$REGION" \
--filter="supervisord" --limit 50

C. Cloud Storage (optional)

Crawl4AI has no default GCS bucket — it is stateless. Optional buckets can be provisioned via storage_buckets to store crawl results or custom config.yml files.

  • Console: Cloud Storage → Buckets.
  • CLI:
    gcloud storage buckets list --project "$PROJECT"
    gcloud storage ls gs://<results-bucket>/

See App_CloudRun for GCS Fuse mounts and CMEK.

D. Secret Manager

LLM API keys and the JWT signing secret are stored as Secret Manager secrets and injected into the service at runtime; plaintext never appears in configuration. Crawl4AI has no auto-generated secrets — all secrets must be provided via secret_environment_variables.

  • Console: Security → Secret Manager.
  • CLI:
    gcloud secrets list --project "$PROJECT"
    gcloud secrets versions access latest --secret=<secret-name> --project "$PROJECT"

Recognised secret names (pass the Secret Manager secret name, not the value): SECRET_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY, DEEPSEEK_API_KEY, GROQ_API_KEY, GEMINI_API_KEY, LLM_API_KEY.

See App_CloudRun for injection and rotation details.

E. Networking & ingress

The service is reachable at its run.app URL by default with ingress_settings = "all". An external HTTPS load balancer with a custom domain, Cloud CDN, and Cloud Armor can be layered on. VPC egress is set to ALL_TRAFFIC so the crawler can reach arbitrary public URLs.

  • Console: Cloud Run (service URL); Network services → Load balancing.
  • CLI:
    gcloud run services describe <service-name> --region "$REGION" --format='value(status.url)'
    gcloud compute addresses list --project "$PROJECT"

See App_CloudRun.

F. Cloud Logging & Monitoring

Container logs (Python output streamed via PYTHONUNBUFFERED=1) flow to Cloud Logging. Cloud Run metrics flow to Cloud Monitoring, with optional uptime checks and alert policies.

  • Console: Logging → Logs Explorer; Monitoring → Dashboards / Alerting.
  • CLI:
    gcloud run services logs read <service-name> --project "$PROJECT" --region "$REGION" --limit 50

3. Crawl4AI Application Behaviour

  • Supervisord startup sequence. On every container start, supervisord (PID 1) starts Redis first (priority 10), then Gunicorn (priority 20). The /health endpoint only responds after both processes are ready — allow at least 40 seconds of initial delay before health checks start.

  • REST API endpoints. Crawl4AI exposes:

    EndpointMethodPurpose
    /crawlPOSTSubmit an asynchronous crawl job; returns a task_id
    /task/{id}GETPoll status and retrieve results for a task
    /crawl/syncPOSTSynchronous crawl (blocks until complete)
    /healthGETHealth check — returns {"status":"ok"} when ready
    /playgroundGETInteractive browser-based crawl UI
  • Task result lifecycle. Async crawl results are stored in the embedded Redis with a TTL of redis_task_ttl_seconds (default 1 hour). After the TTL expires the result is gone. There is no durable result store.

  • No database migrations or initialization jobs. Crawl4AI is fully stateless — Crawl4AI_Common supplies no initialization job. No database setup is required.

  • LLM-based extraction. Provide LLM API keys via secret_environment_variables and set LLM_PROVIDER (or provider-specific keys such as OPENAI_API_KEY) via environment_variables to enable AI-driven content extraction.

  • JWT authentication (optional). Security is disabled by default. To enable, supply SECRET_KEY via secret_environment_variables and provide a custom config.yml with security.jwt_enabled=true. The /token endpoint issues short-lived JWTs when authentication is enabled.

  • CRAWL4AI_HOOKS_ENABLED warning. Setting this variable to "true" enables arbitrary Python code execution via webhook hooks. Only enable in a fully trusted environment.


4. Configuration Variables

Variables are grouped exactly as they appear on the deployment platform. Only settings specific to or notable for Crawl4AI are listed; every other input is inherited from App_CloudRun with its standard behaviour.

Group 1 — Project & Identity

VariableDefaultDescription
project_id(required)Target Google Cloud project.
regionus-central1Region for the service and regional resources.

Group 2 — Deployment Environment

VariableDefaultDescription
tenant_deployment_iddemoShort suffix that makes resource names unique per environment.
support_users[]Emails granted project access and monitoring alerts.
resource_labels{}Labels applied to all resources.

Group 3 — Application Identity

VariableDefaultDescription
application_namecrawl4aiBase name for resources. Do not change after first deploy.
application_display_nameCrawl4AI Web CrawlerFriendly name shown in the Console.
description(set)Service description.
application_version0.7.8Crawl4AI image version tag; pin to a specific tag for production.

Group 4 — Runtime & Scaling

VariableDefaultDescription
deploy_applicationtrueSet false to provision infrastructure only without deploying the container.
cpu_limit1000mCPU per instance; ~0.5–1 vCPU per active browser context.
memory_limit4GiMemory per instance. Minimum 4 GiB for stable Chromium operation; 8 GiB recommended for concurrent crawls.
min_instance_count0Minimum instances. Set to 1 for a warm Chromium pool; default 0 causes 30–60 s cold starts.
max_instance_count3Maximum instances (cost ceiling).
cpu_always_allocatedfalseRequest-based billing — a crawl runs synchronously within its HTTP request with no post-response background work, so CPU throttling between requests is safe.
execution_environmentgen2Required — Gen2 for supervisord's process tree and Chromium's /tmp shared memory.
timeout_seconds3600Maximum request duration; set to the Cloud Run maximum to allow long batch crawl jobs.
container_protocolhttp1HTTP protocol version.
enable_image_mirroringtrueMirror the Crawl4AI image to Artifact Registry to avoid Docker Hub rate limits.
traffic_split[]Percentage-based canary/blue-green traffic allocation across revisions.

Group 5 — Access & Networking

VariableDefaultDescription
ingress_settingsallTraffic sources permitted to reach the service. Use "internal-and-cloud-load-balancing" when fronted by Cloud Armor.
vpc_egress_settingALL_TRAFFICRequired — routes all outbound traffic through the VPC so the crawler can reach arbitrary public URLs.
enable_iapfalseRequire Google sign-in via Identity-Aware Proxy.
iap_authorized_users / iap_authorized_groups[]Who may access through IAP.
enable_cloud_armorfalseProvision a Global HTTPS Load Balancer with Cloud Armor WAF.
application_domains[]Custom hostnames for the external load balancer.
enable_cdnfalseEnable Cloud CDN on the LB backend.

Group 6 — Environment Variables & Secrets

VariableDefaultDescription
environment_variables{}Extra non-secret settings. PYTHONUNBUFFERED and REDIS_TASK_TTL are set automatically. Do not set REDIS_HOST or REDIS_PORT. Recognised overrides: LLM_PROVIDER, LLM_BASE_URL, LLM_TEMPERATURE, CRAWL4AI_HOOKS_ENABLED.
secret_environment_variables{}Map of env var → Secret Manager secret name. Use for SECRET_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.
secret_propagation_delay30Seconds to wait after secret creation before proceeding.
secret_rotation_period2592000sSecret Manager rotation notification frequency.

Group 7 — Backup & Restore

Not applicable for Crawl4AI — the service is stateless and carries no database. backup_schedule, backup_retention_days, and enable_backup_import are present for interface compatibility but have no effect.

Group 8 — CI/CD & Binary Authorization

Standard App_CloudRun Cloud Build / Cloud Deploy integration — see App_CloudRun. Key inputs: enable_cicd_trigger, github_repository_url, github_token, enable_cloud_deploy, enable_binary_authorization.

Group 9 — Jobs & Custom SQL

VariableDefaultDescription
initialization_jobs[]Crawl4AI_Common supplies no default init job — leave empty unless a custom setup step is needed.
cron_jobs[]Optional recurring Cloud Run Jobs triggered by Cloud Scheduler.
enable_custom_sql_scriptsfalseNot applicable for Crawl4AI (no database).

Group 11 — Storage & Filesystem

VariableDefaultDescription
create_cloud_storagetrueProvision any buckets listed in storage_buckets.
storage_buckets[]No buckets by default — Crawl4AI is stateless. Add entries to provision crawl-result buckets.
enable_nfsfalseProvision a Filestore NFS volume. Not required for standard Crawl4AI deployments.
gcs_volumes[]GCS Fuse mounts.
manage_storage_kms_iam / enable_artifact_registry_cmekfalseCMEK options.

Group 12 — Database Backend

VariableDefaultDescription
database_typeNONEFixed — no Cloud SQL instance is provisioned for Crawl4AI.

All other database variables (enable_cloudsql_volume, database_password_length, etc.) are present for interface compatibility and have no effect.

Group 14 — Observability & Health

VariableDefaultDescription
startup_probe_config / startup_probeHTTP /health, 40 s delayAllow supervisord time to start Redis then Gunicorn before the first probe fires.
health_check_config / liveness_probeHTTP /health, 60 s delayLiveness probe after startup.
uptime_check_configdisabled by default, path /healthCloud Monitoring uptime check.
alert_policies[]Optional metric alert policies.
max_images_to_retain / delete_untagged_images / image_retention_days(set)Artifact Registry cleanup policy.

Group 19 — Crawl4AI Application Settings

VariableDefaultDescription
redis_task_ttl_seconds3600TTL in seconds for task results in embedded Redis. Valid range: 300–86400. Too short causes results to expire before clients poll; too long causes unbounded memory growth.

5. Outputs

Returned on a successful deployment — the quickest way to locate and explore the running resources.

OutputDescription
service_nameCloud Run service name.
service_urlDefault run.app URL of the service.
service_locationRegion the service runs in.
stage_servicesStage-specific service URLs (Cloud Deploy).
load_balancer_ip / load_balancer_urlExternal HTTPS load balancer IP / URL (when enabled).
storage_bucketsCreated Cloud Storage buckets.
network_name / network_exists / regionsVPC network, presence, regions.
container_image / container_registryDeployed image and Artifact Registry repo.
monitoring_enabled / monitoring_notification_channels / uptime_check_namesMonitoring status, channels, uptime checks.
initialization_jobsNames of any setup jobs.
deployment_id / tenant_id / resource_prefixNaming identifiers.
project_id / project_numberProject identifiers.
cicd_enabled / github_repository_url / github_repository_owner / github_repository_name / cicd_configurationCI/CD status and details.
artifact_registry_repository / cloudbuild_trigger_name / cloudbuild_trigger_idRegistry and build trigger.
vpc_sc_enabled / vpc_sc_perimeter_name / vpc_sc_dry_run_modeVPC-SC status.
audit_logging_enabled / artifact_registry_cmek_enabledAudit logging and CMEK status.

6. Configuration Pitfalls & Sensible Defaults

Risk: Critical (data loss / outage / security) — High (service degraded) — Medium (cost or partial degradation) — Low (minor).

SettingSensible valueRiskConsequence if wrong
vpc_egress_settingALL_TRAFFICCriticalUsing PRIVATE_RANGES_ONLY blocks all external crawl targets; every crawl to a public URL fails with a connection error.
memory_limit8GiCriticalBelow 4 GiB, Chromium processes are OOM-killed mid-crawl returning partial results; below 2 GiB the container fails to start.
REDIS_HOST / REDIS_PORT (env vars)do not setCriticalOverriding these breaks the embedded Redis connection; all async crawl jobs fail immediately.
database_typeNONECriticalCrawl4AI has no database; changing this causes unnecessary Cloud SQL provisioning and a startup failure.
execution_environmentgen2HighGen1 cannot run supervisord's process tree; the service fails to deploy with VPC network configuration.
min_instance_count1HighScale-to-zero (0) causes 30–60 s cold starts (supervisord must boot Redis then Gunicorn); the first request typically times out.
cpu_limit4000mHighBelow 2000m, Chromium rendering triggers internal timeouts on complex pages; crawl throughput drops significantly.
enable_iap / enable_cloud_armorenable for productionHighWith ingress_settings = "all", the API is publicly accessible and anyone can submit crawl jobs consuming cloud resources.
LLM_API_KEY / provider API keysvia secret_environment_variablesHighMissing or expired keys cause LLM-based extraction to fail silently (empty extracted_content). Inject as secrets, not plain-text env vars.
redis_task_ttl_seconds3600MediumToo short (< 300 s) causes results to expire before async clients poll; too long causes unbounded memory growth. Valid range: 300–86400.
timeout_seconds3600MediumDeep crawls or LLM extraction of large pages can take several minutes; reduce only for short-lived APIs where zombie requests should be terminated faster.
application_versionpinned tagMediumUsing "latest" is non-reproducible; a rebuild may pull a breaking Crawl4AI API change.
enable_image_mirroringtrueLowCrawl4AI images are large; without mirroring, every deployment pulls from Docker Hub and risks rate-limit failures and slow cold starts.

For the foundation behaviour referenced throughout — service identity, scaling and concurrency, ingress and load balancing, CI/CD, Cloud Armor, IAP, Binary Authorization, VPC-SC, and image mirroring — see App_CloudRun. Crawl4AI-specific shared application configuration is described in Crawl4AI_Common.