Guide April 18, 2026 · 18 mins · The D23 Team

Apache Superset Async Queries: When to Use Them

Learn when and how to configure Apache Superset async queries with Celery and Redis for long-running analytics without timeouts.

Apache Superset Async Queries: When to Use Them

Understanding Async Queries in Apache Superset

Apache Superset, the open-source business intelligence platform that powers D23’s managed analytics platform, handles queries in two fundamental ways: synchronously and asynchronously. Most users encounter synchronous queries first—you click a dashboard, the browser sends a request to the Superset server, the server queries your database, and waits for results before responding. This works fine for fast queries, but breaks down when analytics demand grows.

Async queries flip this model. Instead of blocking and waiting, your browser fires off a request, gets an acknowledgment, then polls for results as they arrive. The actual query work happens on background workers, not the web server. This architectural shift is subtle but profound—it’s the difference between a checkout line where everyone waits for the slowest customer versus a kitchen where orders cook in parallel and you grab your food when it’s ready.

In production environments serving data and analytics leaders at scale-ups and mid-market companies, async queries become essential infrastructure. Without them, a single slow query can cascade into timeouts across your entire dashboard, frustrating users and degrading the analytics experience your team relies on.

The Problem: Synchronous Query Limits

Synchronous query execution in Superset works through the standard HTTP request-response cycle. When you load a dashboard with five charts, your browser makes five separate requests. Each one waits for the web server to execute the query, fetch results, and return them. The web server itself typically has a timeout—often 30 seconds, sometimes 60—because HTTP connections can’t hang open indefinitely.

This creates several failure modes:

Timeout Errors: A query against a large fact table with complex joins takes 45 seconds. The web server’s 30-second timeout fires first. The query might still be running on the database, but the client gets a 504 Gateway Timeout. The user sees an error. The database continues working on a query nobody’s waiting for anymore—wasted resources.

Blocking Web Workers: Superset runs multiple web workers (usually with Gunicorn). Each worker can handle one synchronous request at a time. If you have 8 workers and 10 users run queries simultaneously, two users wait in queue. Add slow queries to the mix and queue times explode. Your dashboard feels sluggish even though your database has capacity.

Resource Contention: Web workers are Python processes. They consume memory and CPU while blocking on I/O waiting for database responses. A single slow query ties up a worker that could serve ten fast requests. On shared infrastructure, this becomes a noisy neighbor problem—one user’s analytics job starves others.

Poor User Experience: Users can’t cancel queries easily. They can’t see progress. They don’t know if the dashboard is hung or still loading. The interface feels unresponsive, which erodes confidence in the analytics platform itself.

These problems compound at scale. Engineering and platform teams embedding self-serve BI into products face them acutely—each customer dashboard is another potential timeout risk.

How Async Queries Work: The Architecture

Async query execution in Superset relies on three components: a task queue, workers, and a results backend. The flow looks like this:

  1. User Action: You load a dashboard or run a query from the explore interface.
  2. Task Submission: The web server receives the request, creates a task describing the query, and pushes it to a task queue (usually Redis).
  3. Acknowledgment: The web server immediately responds with a task ID and tells the client “your query is queued.”
  4. Worker Execution: Background workers (Celery workers) pull tasks from the queue and execute them against your database.
  5. Result Storage: Query results are stored in a results backend (also typically Redis, or a database).
  6. Client Polling: The browser polls the server asking “is my query done yet?” Every few seconds, it checks the task status.
  7. Result Delivery: Once the query completes, the next poll retrieves results and the dashboard renders.

This architecture decouples query execution from the web request lifecycle. The web server never blocks. Workers run independently. Queries can take hours if needed—the client will keep polling until they finish (or the user closes the browser).

The key insight: async queries move work off the critical path. Your web server stays responsive. Your workers scale independently. Your database gets cleaner, more predictable load.

When to Enable Async Queries: Decision Framework

Not every Superset deployment needs async queries. Small teams with fast databases and few concurrent users won’t notice the difference. But several signals indicate it’s time to switch.

Signal 1: Dashboard Load Times Exceed 10 Seconds

If your dashboards regularly take longer than 10 seconds to fully load, async queries can help. The improvement isn’t magic—the queries still take the same time—but users perceive it differently. With async, they see the dashboard skeleton immediately and charts fill in as they complete. With sync, they stare at a blank screen for 10 seconds then everything appears at once.

Signal 2: Intermittent Timeout Errors

If your logs show occasional 504 errors or “query timeout” messages, especially during peak hours, async queries are your answer. These errors typically indicate a few queries are running long, blocking web workers, and causing subsequent requests to timeout. Async prevents this cascade.

Signal 3: Query Variability

Some queries are fast (under 2 seconds). Others are slow (30+ seconds). This variability is the enemy of synchronous execution. You must set your timeout high enough for slow queries, but then fast queries wait unnecessarily. Async eliminates this tradeoff—fast queries return immediately, slow queries run in the background.

Signal 4: Embedded Analytics in Your Product

If you’re embedding self-serve BI dashboards into a SaaS product or internal tool, async queries are nearly mandatory. Your product’s responsiveness directly affects user experience. Async keeps your product feeling snappy even when analytics queries run long. This is especially true for engineering and platform teams building analytics into customer-facing features.

Signal 5: Multiple Concurrent Users

Once you have more than 10-15 concurrent dashboard users, async becomes valuable. With fewer users, web worker blocking is tolerable. At scale, it’s a bottleneck. Async lets you serve more users with the same hardware.

Signal 6: Data Warehouse Queries Exceeding 30 Seconds

If your typical dashboard queries run 30+ seconds (common with large fact tables, complex joins, or slow data warehouses), async is essential. These queries will always timeout in sync mode unless you extend your web server timeout to unsafe levels.

Configuring Async Queries: The Technical Setup

Enabling async queries requires three components: a task queue (Redis), background workers (Celery), and configuration changes in Superset.

Step 1: Install and Run Redis

Redis serves dual duty—task queue and results backend. Install it on your infrastructure:

# On Ubuntu/Debian
sudo apt-get install redis-server

# On macOS with Homebrew
brew install redis

# Start the service
redis-server

For production, use a managed Redis service (AWS ElastiCache, Azure Cache, or similar) rather than self-hosting. Managed services handle replication, backups, and failover automatically.

Step 2: Install Celery

Celery is a distributed task queue library for Python. Install it in your Superset environment:

pip install celery[redis]

This installs Celery and the Redis client library it needs.

Step 3: Configure Superset

Edit your Superset configuration file (typically superset_config.py or environment variables in Docker). According to the official Async Queries via Celery documentation, you need several settings:

# Enable async queries
SUPERSET_WEBSERVER_TIMEOUT = 600  # 10 minutes for web requests
SUPERSET_CELERY_INSTANCES = 4  # Number of Celery workers

# Task queue configuration
CELERY_BROKER_URL = "redis://localhost:6379/0"
CELERY_RESULT_BACKEND = "redis://localhost:6379/0"

# Async query settings
ASYNC_QUERY_JOB_TIMEOUT = 3600  # 1 hour timeout for async queries
QUERY_CELERY_TIMEOUT = 300  # 5 minute timeout per individual query

# Enable async for dashboards and charts
GLOBAL_ASYNC_QUERIES = True
GLOBAL_ASYNC_QUERIES_JWT_SECRET = "your-secret-key-here"

The GLOBAL_ASYNC_QUERIES flag enables async for all dashboards. The JWT secret is used to sign async query requests, preventing unauthorized query submission.

Step 4: Start Celery Workers

Celery workers process the queued tasks. Start them with:

celery -A superset.tasks worker --loglevel=info

For production, run multiple workers (usually one per CPU core) and manage them with a process supervisor like systemd, supervisor, or Kubernetes. According to the Apache Superset GitHub discussion on async queries, you can configure worker concurrency and queue routing for optimal performance.

Step 5: Verify Configuration

Load a dashboard and monitor the logs. You should see:

  • Web server receives request, returns task ID immediately
  • Celery worker picks up the task
  • Worker executes the query against your database
  • Results store in Redis
  • Browser polls and retrieves results

If you see queries still timing out, check:

  • Redis is running and accessible
  • Celery workers are running (celery -A superset.tasks inspect active)
  • Your database connection is working from the worker process
  • Firewall rules allow worker-to-database communication

Performance Tuning for Async Queries

Enabling async queries is the first step. Optimizing them is the next. Several tuning parameters directly impact async performance.

Worker Count and Concurrency

Each Celery worker can handle multiple concurrent tasks depending on your configuration. Start with one worker per CPU core on your worker machine. If you have an 8-core server, start 8 workers:

celery -A superset.tasks worker --concurrency=8 --loglevel=info

Monitor queue depth and worker CPU usage. If the queue grows (tasks waiting for workers), add more workers. If workers are idle, you have excess capacity.

Connection Pooling

Your database connection is a limited resource. Each Celery worker needs a connection to execute queries. According to Best Practices to Optimize Apache Superset Dashboards, connection pooling prevents workers from exhausting database connections.

In your database connection settings in Superset, enable connection pooling:

SQLALCHEMY_POOL_SIZE = 20  # Connections per worker
SQLALCHEMY_POOL_RECYCLE = 3600  # Recycle connections after 1 hour
SQLALCHEMY_POOL_TIMEOUT = 30  # Wait 30 seconds for a connection
SQLALCHEMY_POOL_PRE_PING = True  # Test connections before use

These settings prevent connection exhaustion and reduce stale connection errors.

Query Timeout Tuning

You have two timeout settings:

  • QUERY_CELERY_TIMEOUT: Maximum time a single query can run (default 5 minutes)
  • ASYNC_QUERY_JOB_TIMEOUT: Maximum time a full async job can run (default 1 hour)

Set these based on your actual query patterns. If your slowest dashboard query takes 2 minutes, set QUERY_CELERY_TIMEOUT to 180 seconds. If you have ad-hoc exploration queries that sometimes take 30 minutes, increase ASYNC_QUERY_JOB_TIMEOUT to 1800 seconds.

According to Apache Superset Async Query Timeouts, timeout values should reflect your SLA requirements, not arbitrary limits.

Caching Strategy

Async queries work best with caching. If the same dashboard is viewed repeatedly, queries run repeatedly. Superset’s query cache stores results for identical queries. Configure it:

CACHE_CONFIG = {
    'CACHE_TYPE': 'redis',
    'CACHE_REDIS_URL': 'redis://localhost:6379/1',
    'CACHE_DEFAULT_TIMEOUT': 300,  # 5 minutes
}

TABLE_NAMES_CACHE_CONFIG = {
    'CACHE_TYPE': 'redis',
    'CACHE_REDIS_URL': 'redis://localhost:6379/2',
}

With caching, the second user viewing a dashboard gets cached results instantly, even if the first user’s query took 30 seconds.

Real-World Scenarios: When Async Queries Shine

Scenario 1: Data Warehouse with Large Fact Tables

Your company uses Snowflake or BigQuery to store 500GB of events. Dashboard queries aggregate billions of rows. A typical query scans 50GB and takes 45 seconds. Without async, every dashboard load times out.

With async, users see the dashboard immediately with a loading state. Charts fill in as queries complete. If a user navigates away, the query still runs in the background—no waste. The next user loads the cached results instantly.

Scenario 2: Embedded Analytics in SaaS

Your product embeds self-serve BI dashboards for customers. Each customer has different data volumes. Some customers have small datasets (queries return in 1 second). Others have massive deployments (queries take 20 seconds).

With sync queries, you must set timeouts high enough for the slowest customer, making the product feel sluggish for everyone else. With async, each customer gets responsive dashboards. Fast queries return instantly. Slow queries run in the background without blocking.

Scenario 3: Complex Reporting for Private Equity

A private equity firm uses Superset to track KPIs across 20 portfolio companies. Portfolio performance dashboards combine data from multiple sources, require complex calculations, and take 60+ seconds to run. Private equity firms standardizing analytics across portfolio companies depend on these dashboards for due diligence and value creation tracking.

Async queries make these dashboards practical. The PE analyst loads the dashboard, sees the structure immediately, and charts populate over the next minute. They can explore drill-downs and ad-hoc queries without waiting between interactions.

Scenario 4: Venture Capital Portfolio Tracking

A VC firm tracks metrics across 50+ portfolio companies. A single dashboard queries data from each company’s API and database. The query takes 2 minutes to collect and aggregate all data. Venture capital firms tracking portfolio performance with AI-assisted analytics need reliable, responsive dashboards.

Async queries enable this. The dashboard loads instantly. Data populates over 2 minutes. The investor can view fund metrics and LP reporting without staring at a loading screen. Background workers handle the heavy lifting.

Async Queries and AI-Powered Analytics

Async queries become even more valuable when combined with AI-powered analytics. Text-to-SQL systems and natural language query interfaces generate queries dynamically based on user questions. These generated queries are often inefficient—they work correctly but aren’t optimized.

According to Building Real-Time Dashboards with Apache Superset, asynchronous query execution with Celery and Redis is essential for real-time dashboards that prevent timeouts and improve concurrency.

When a user asks “What’s our revenue trend by region?” your text-to-SQL engine generates a query. That query might be inefficient—it could take 30 seconds. Async queries absorb this latency gracefully. The user gets an immediate response: “Generating your query…” The background worker executes the generated query. Results appear when ready.

At D23, we integrate async queries with MCP (Model Context Protocol) servers for analytics, enabling AI-assisted query generation and optimization. Async execution ensures that AI-generated queries don’t degrade the user experience, even when they’re not perfectly optimized.

Monitoring Async Query Performance

Once async queries are running, monitor them to ensure they’re performing as expected.

Key Metrics to Track

Queue Depth: How many tasks are waiting for workers? If this grows consistently, you need more workers.

Worker Utilization: Are workers busy or idle? Monitor CPU and memory usage. Idle workers indicate excess capacity. Saturated workers indicate a bottleneck.

Query Execution Time: How long do queries take from submission to completion? Track this over time. If it increases, your database might be degrading or your workers might be overloaded.

Cache Hit Rate: What percentage of queries are served from cache? Higher is better. If your cache hit rate is low, increase cache TTL or adjust your caching strategy.

Error Rate: What percentage of async queries fail? Failures indicate issues with your database, workers, or configuration. Track and investigate.

Monitoring Tools

Celery provides built-in monitoring:

# View active tasks
celery -A superset.tasks inspect active

# View worker stats
celery -A superset.tasks inspect stats

# View registered tasks
celery -A superset.tasks inspect registered

For production, integrate with monitoring systems like Prometheus, Datadog, or New Relic. According to Apache Superset Performance Tuning Guide, monitoring async execution and caching strategies is critical for high-performance deployments.

Common Pitfalls and How to Avoid Them

Pitfall 1: Undersized Redis Instance

Redis stores both task queue and results. If it runs out of memory, tasks are lost. Monitor Redis memory usage and ensure you have headroom.

redis-cli INFO memory

If Redis memory usage exceeds 80%, increase capacity or implement result expiration to clean up old results.

Pitfall 2: Insufficient Database Connections

With many Celery workers, you can exhaust database connections. Each worker needs a connection to execute queries. If you have 10 workers and your database allows 20 connections, you’re at capacity with no headroom.

Calculate: Workers × Queries Per Worker = Required Connections. Add 20% headroom. Configure your database connection pool accordingly.

Pitfall 3: Forgetting to Start Workers

Developers sometimes deploy async configuration but forget to start Celery workers. Queries get queued but never execute. The user sees a loading state forever. Always verify workers are running:

celery -A superset.tasks inspect ping

This command should show all active workers. If it shows nothing, workers aren’t running.

Pitfall 4: Misconfigured JWT Secret

The GLOBAL_ASYNC_QUERIES_JWT_SECRET must be set to a strong random value. If it’s missing or weak, async queries might fail or be vulnerable. Generate a strong secret:

python -c "import secrets; print(secrets.token_urlsafe(32))"

Use this value in your configuration.

Pitfall 5: Not Tuning Query Timeouts

Default timeouts might be too aggressive for your workload. If your slowest dashboard query takes 5 minutes but QUERY_CELERY_TIMEOUT is 300 seconds, queries timeout. Monitor actual query execution times and adjust timeouts accordingly.

Async Queries in Production: Best Practices

Moving async queries to production requires careful planning.

Use Managed Services

Don’t self-host Redis or Celery workers in production. Use managed services:

  • Redis: AWS ElastiCache, Azure Cache for Redis, or Google Cloud Memorystore
  • Celery Workers: Run on Kubernetes, ECS, or your container orchestration platform

Managed services handle failover, backups, and scaling automatically.

Implement Redundancy

Run multiple Celery workers across different machines. If one worker fails, others pick up its load. Configure your task queue for persistence so tasks aren’t lost if Redis restarts.

Set Up Alerting

Alert on:

  • Queue depth exceeding threshold (tasks piling up)
  • Worker count dropping below expected (workers crashed)
  • Query timeout rate increasing (database degradation)
  • Redis memory usage exceeding threshold

Plan for Scaling

As your user base grows, you’ll need more workers. Design your infrastructure to scale horizontally—add more worker machines without changing configuration. Use auto-scaling groups if running on cloud infrastructure.

Document Configuration

Async query configuration is complex. Document your settings, including:

  • Why you chose specific timeout values
  • How many workers you’re running and why
  • Your caching strategy
  • Monitoring and alerting setup

This documentation helps when troubleshooting or onboarding new team members.

Comparing Async to Alternatives

Async queries aren’t the only solution to slow dashboards. Understanding alternatives helps you choose the right approach.

Materialized Views

Pre-compute and store query results in a table. Dashboards query the materialized view instead of the raw data. This is fast but requires maintenance—views must be refreshed regularly.

Async vs. Materialized Views: Async handles ad-hoc queries and exploration. Materialized views are better for static dashboards that change infrequently.

Caching

Store query results in memory and reuse them. Subsequent identical queries return instantly.

Async vs. Caching: Caching helps when the same queries run repeatedly. Async helps when queries are slow, even if they run infrequently.

Data Warehouse Optimization

Optimize your database schema, indexes, and queries to run faster. This is always valuable.

Async vs. Database Optimization: These aren’t mutually exclusive. Optimize your database first, then add async for queries that are still slow.

Upgrading to Premium BI Tools

Looker, Tableau, and Power BI have built-in async query handling and optimization. They’re mature and well-supported.

Async in Superset vs. Premium Tools: Superset with async queries is comparable in performance but with the benefits of open-source—no vendor lock-in, customizability, and cost savings. For organizations evaluating managed open-source BI as an alternative to Looker, Tableau, and Power BI, async-enabled Superset is a compelling option.

Integrating Async Queries with D23

If you’re using D23’s managed Apache Superset platform, async queries come pre-configured. Our infrastructure handles Redis, Celery workers, and configuration automatically. You get the benefits without the operational burden.

D23 goes further, integrating async queries with AI-powered analytics. Our text-to-SQL capabilities generate queries dynamically, and async execution ensures they don’t degrade responsiveness. For engineering and platform teams embedding self-serve BI into products, this combination is powerful—your end users get AI-assisted analytics with instant dashboard responsiveness.

Our API-first BI architecture is built on async queries. Every dashboard, chart, and exploration query runs asynchronously. This enables consistent, predictable performance whether you have 5 users or 5,000.

For organizations considering managed solutions, D23 provides the operational expertise and infrastructure to run async queries at scale. Our data consulting services help teams optimize their analytics architecture, including async query configuration and tuning.

Conclusion: Async Queries as Foundation

Async queries transform Apache Superset from a tool suitable for small teams to a platform that scales. They’re not a feature you add for fun—they’re infrastructure that enables growth.

If your dashboards timeout, your users are frustrated, or you’re planning for growth, async queries should be on your roadmap. The technical setup is straightforward. The operational benefits are substantial.

Start with the decision framework outlined above. If your situation matches any of those signals, enable async queries. Monitor performance. Tune based on your actual workload. You’ll see immediate improvements in responsiveness and reliability.

For teams building analytics into products or managing analytics at scale, async queries are non-negotiable. Combined with caching, database optimization, and AI-powered query generation, they form the foundation of a modern analytics platform.

According to Async Queries in Superset: When and How, understanding these scenarios and implementing async execution properly is critical for production deployments. Whether you’re self-hosting Superset or using a managed service like D23, async queries are essential for reliable, responsive analytics at scale.