Concurrent Access & Scaling
Multi-node HA and horizontal scaling planned for Pixeltable Cloud (2026).
Web Framework Concurrency
Pixeltable is thread-safe and works with FastAPI, Flask, Django, and other web frameworks out of the box. The key rule: use sync (def) endpoint handlers, not async def.
Why Sync Endpoints
FastAPI (and Starlette) dispatches sync (def) handlers to a thread pool. Each concurrent request gets its own thread, and Pixeltable automatically creates an isolated database connection per thread. This gives you true parallel request handling with no extra configuration.
Returning Query Results
table.select(...).collect() returns a ResultSet object, which Pydantic cannot serialize directly. You have two options:
Option 1: to_pydantic() (recommended for FastAPI)
Define a Pydantic model and let Pixeltable validate and convert each row. FastAPI serializes these natively.
to_pandas() + to_dict()
Convert via pandas when you don’t need a Pydantic model.
uvloop Compatibility
Pixeltable is compatible with uvloop, the high-performance event loop used by default in many production deployments. No special configuration is needed — sync endpoints work identically whether the server uses the default asyncio loop or uvloop.GPU Acceleration
- Automatic GPU Detection: Pixeltable uses CUDA GPUs for local models (Hugging Face, Ollama) when available.
- CPU Fallback: Models run on CPU if no GPU detected (functional but slower).
- Configuration: Control via
CUDA_VISIBLE_DEVICESenvironment variable.
Error Handling
Access error details via
table.column.errortype and table.column.errormsg.
Testing Transformations Before Deployment
When you add a computed column, Pixeltable executes it immediately for all existing rows. For expensive operations (LLM calls, model inference), validate your logic on a sample first usingselect(); nothing is stored until you commit with add_computed_column().
Full Tutorial
Step-by-step guide with examples for built-in functions, expressions, and custom UDFs
Schema Evolution
Production Safety:
- Version control
schema.pylike database migration scripts. - Rollback via
table.revert()(single operation) or Git revert (complex changes).
Updating Models
The most common schema evolution is switching an embedding or LLM model. In a traditional stack this requires a migration script, a compute cluster, reprocessing every row, and a maintenance window. In Pixeltable it’s one line — the old column keeps working while the new one backfills. Traditional approach:Because both columns coexist, you can A/B test retrieval quality before cutting over — no rollback plan needed.
Deployment Patterns
Web Applications:- For standard endpoints, use
pxt servewith a TOML config orFastAPIRouter - Run
python schema.pyonce before starting workers to create tables - Each router calls
pxt.get_table()directly and defines its own@pxt.queryfunctions - Use sync (
def) endpoint handlers for concurrent request support
Pixeltable Starter Kit
Clone a production-ready FastAPI + React app with multimodal upload, search, and agent endpoints — plus deployment configs for Docker Compose, Helm, Terraform, and AWS CDK.
- Schedule via
cron, Airflow, AWS EventBridge, GCP Cloud Scheduler, or webhooks - Deploy to Cloud Run Jobs, Lambda, ECS Fargate, Kubernetes Jobs
- Isolate batch workloads from real-time serving (separate containers/instances)
- Use Pixeltable’s incremental computation to process only new data
- The starter kit includes a batch processing pipeline with
export_sqland thedestinationparameter, plus ready-to-use deploy configs for Lambda, Cloud Run, ECS Fargate, and K8s Jobs
- Docker provides reproducible builds across environments
- Full Backend: Mount persistent volume at
~/.pixeltable(or setPIXELTABLE_HOME) - Kubernetes: Use
ReadWriteOncePVC (single-pod write access) - Docker Compose or Kubernetes for multi-container deployments
- The starter kit includes a multi-stage Dockerfile and ready-to-use deployment configs:
Environment Management
Multi-Tenancy and Isolation
Logical Isolation Example:
High Availability Constraints
Troubleshooting
Reset Database (Development Only)
To completely reset Pixeltable’s local state during development:Common Issues
Environment Separation
Use environment-specific namespaces to manage dev/staging/prod configurations:Testing
Staging Environment:- Mirror production configuration.
- Test schema changes, UDF updates, application code changes.
- Use representative data (anonymized or synthetic).