Fast Development Mode
Overview
The dev-fast
script provides an optimized local development experience with 4-6x faster WebSocket streaming performance compared to the standard dev
script.
Usage
# Using pnpm (recommended)
pnpm dev-fast
# Using the script directly
./dev-fast
# With AWS profile
pnpm dev-fast --profile your-profile
What It Does
- Compiled Subscriber-Fanout: Builds and runs the compiled JavaScript version instead of
tsx watch
, eliminating TypeScript compilation overhead - Increased MongoDB Pool: Sets
MONGODB_MAX_POOL_SIZE=10
(vs default 2) for better concurrent connection handling - Faster WebSocket Updates: Reduces throttling from 100ms to 25ms in development (4x more updates per second)
- Memory Optimization: Sets
NODE_OPTIONS="--max-old-space-size=4096"
to prevent garbage collection pauses - Development Environment: Properly sets
NODE_ENV=development
for all services
Performance Improvements
- WebSocket streaming: 4-6x faster perceived response time
- Database operations: ~2x faster with larger connection pool
- Overall responsiveness: Significantly improved, closer to production performance
When to Use
Use dev-fast
when:
- Testing AI streaming responses
- Working with real-time features
- Demonstrating the app locally
- Performance testing
Use regular dev
when:
- You need hot-reload for subscriber-fanout code
- You're debugging TypeScript compilation issues
- Initial setup or configuration changes
Trade-offs
- Build time: Adds ~5-10 seconds startup time to build subscriber-fanout
- Hot reload: Subscriber-fanout changes require restart (client still hot-reloads)
- Memory usage: Uses more memory due to larger pools and compiled code
Troubleshooting
If you encounter issues:
- Ensure all dependencies are installed:
pnpm install
- Clean build artifacts:
pnpm clean
- Check MongoDB is running and accessible
- Verify AWS credentials are configured
Technical Details
The optimizations include:
- MongoDB maxPoolSize: 10 (configurable via
MONGODB_MAX_POOL_SIZE
) - WebSocket throttle: 25ms in development vs 100ms in production
- Node.js heap size: 4GB
- Compiled TypeScript for critical path services