Build process
Before deploying, build your application:dist/index-production.js- Production entry pointdist/- Compiled step handlersmotia.lock.json- Lock file with step metadata
Deployment options
Single-process deployment
The simplest deployment runs the iii engine and SDK in a single container:Multi-process deployment
For larger applications, separate the engine from SDK processes:Serverless deployment
Motia does not currently support serverless platforms (AWS Lambda, Vercel, etc.) because it requires the iii engine runtime. However, you can:- Deploy the iii engine to a long-running instance (ECS, GKE, etc.)
- Deploy SDK processes as separate services
- Use managed queues (SQS, Pub/Sub) for event processing
Environment configuration
Create environment-specific config files:Development (config.yaml)
Production (config-production.yaml)
Infrastructure as code
Kubernetes
Deploy to Kubernetes with Helm or raw manifests:AWS ECS
Deploy to ECS with Fargate:Google Cloud Run
Deploy to Cloud Run:Automated deployment
The Motia repository uses GitHub Actions for CI/CD:Deploy workflow
E2E tests workflow
Production checklist
Before deploying to production:- Use
file_basedstorage for state and streams (notin_memory) - Configure OTLP exporter for observability
- Set appropriate sampling ratios (e.g., 0.1 for 10%)
- Enable CORS with specific allowed origins (not
*) - Use environment variables for secrets (not hardcoded)
- Set up health checks (HTTP GET
/health) - Configure resource limits (CPU, memory)
- Enable rate limiting on public endpoints
- Set up alerts for error rates and latency
- Test rollback procedures
- Document runbooks for common incidents
Monitoring
Health checks
The iii engine exposes a health check endpoint:Metrics
Export metrics to Prometheus:http.server.request.duration(latency)http.server.request.count(throughput)queue.message.duration(queue processing time)state.operation.duration(state performance)
Alerts
Set up alerts for:- HTTP 5xx error rate > 1%
- P95 latency > 1s
- Queue processing failures > 10/min
- Memory usage > 80%
- CPU usage > 80%
Rollback procedures
If a deployment fails:1. Revert to previous version
2. Remove failed NPM package
3. Delete Git tag
Security considerations
- Secrets: Use environment variables, not hardcoded values
- CORS: Restrict allowed origins in production
- Authentication: Implement auth middleware for protected endpoints
- Rate limiting: Prevent abuse with rate limiting middleware
- Input validation: Always validate request bodies with schemas
- HTTPS: Use TLS in production (terminate at load balancer)
- Network policies: Restrict ingress/egress in Kubernetes
Next steps
- Implement testing strategies
- Configure observability
- Learn about middleware