Backend Polling Implementation
The DeployStack Satellite implements a sophisticated HTTP polling system for outbound-only communication with the backend. This firewall-friendly approach enables command orchestration, configuration synchronization, and status reporting without requiring inbound connections to the satellite.Polling Architecture
Core Components
The polling system consists of four integrated services:Service Integration Flow
Command Polling Service
Adaptive Polling Strategy
The polling service implements priority-based polling with automatic mode transitions: Immediate Mode (2 seconds):- Activated when
immediate
priority commands are pending - Used for MCP installations and critical updates
- Enables 3-second end-to-end response time goal
- Automatically returns to normal mode when immediate commands are processed
- Activated when
high
priority commands are pending - Used for MCP deletions and configuration changes
- Balances urgency with resource efficiency
- Activated when only
normal
priority commands are pending - Used for routine maintenance and non-urgent tasks
- Default polling interval for steady-state operation
- Used when no commands are pending
- Minimizes backend load during idle periods
- Automatically switches to faster modes when commands arrive
- Activated when polling requests fail
- Starts at current interval, doubles on each failure
- Maximum backoff of 300 seconds (5 minutes)
- Resets to appropriate priority mode on successful poll
Polling Implementation
Command Processing Pipeline
Commands flow through a structured processing pipeline:- Command Validation: Payload validation and format checking
- Command Routing: Route to appropriate processor based on command type
- Execution: Process command with error handling and timeout
- Result Reporting: Send execution results back to backend
configure
- Update MCP server configurationspawn
- Start HTTP MCP server proxykill
- Stop HTTP MCP server proxyrestart
- Restart HTTP MCP server proxyhealth_check
- Perform health checks on all servers
Dynamic Configuration Management
Configuration Sync Process
The satellite replaces hardcoded MCP server configurations with dynamic updates from the backend:Configuration Validation
All incoming configurations undergo strict validation: Server Configuration Validation:- URL format validation using
new URL()
- Server type restriction to ‘http’ only
- Timeout value validation (positive numbers)
- Required field presence checking
- Deep comparison of server configurations
- Identification of added, removed, and modified servers
- Structured logging of all configuration changes
Integration with Existing Services
Configuration updates trigger cascading updates across satellite services:HTTP Proxy Management Integration
Dynamic Server Registration
The HTTP Proxy Manager integrates with the dynamic configuration system:Server Health Monitoring
The command processor implements health checking for HTTP MCP servers:Tool Discovery Integration
Dynamic Tool Rediscovery
The Remote Tool Discovery Manager integrates with configuration updates:Tool Cache Management
Tool discovery maintains an in-memory cache that updates when server configurations change:- Cache Invalidation: Complete cache reset on configuration changes
- Namespace Preservation: Tools maintain server-prefixed naming
- Error Resilience: Failed discoveries don’t block other servers
- Performance Optimization: Memory-only storage for fast access
Error Handling and Recovery
Polling Error Recovery
The polling service implements comprehensive error handling: Network Errors:- Automatic retry with exponential backoff
- Maximum backoff limit of 300 seconds
- Connection timeout handling (15 seconds)
- Graceful degradation on persistent failures
- 401 Unauthorized handling
- API key validation logging
- Structured error reporting to logs
- Invalid server configuration rejection
- Partial configuration application
- Rollback to previous working configuration
Command Execution Error Handling
Command processing includes robust error handling:Heartbeat Integration
Process Status Reporting
The heartbeat service integrates with the command processor to report process status:System Metrics Collection
Current system metrics include:- Memory Usage: Node.js heap usage in MB
- Process Uptime: Satellite process uptime in seconds
- Process Count: Number of managed HTTP proxy processes
- Error Count: Recent error count for health assessment
Development Integration
Service Initialization Order
The polling system requires specific initialization order:Environment Configuration
Polling behavior is controlled by environment variables:Performance Characteristics
Polling Efficiency
The adaptive polling strategy optimizes resource usage:- Normal Operations: 30-second intervals minimize backend load
- Immediate Response: 2-second intervals for urgent commands
- Error Backoff: Exponential backoff prevents cascade failures
- Network Optimization: Query parameters reduce response size
Memory Usage
The polling system maintains minimal memory footprint:- Configuration Cache: ~1KB per MCP server configuration
- Command Queue: Temporary storage for pending commands
- Tool Cache: ~1KB per discovered tool
- Process Tracking: Minimal metadata per HTTP proxy process
Network Traffic
Polling generates predictable network patterns:- Command Polling: Small JSON requests every 30 seconds (normal mode)
- Configuration Sync: Infrequent larger payloads on configuration changes
- Heartbeats: Regular status reports every 30 seconds
- Command Results: Small JSON responses after command execution
Implementation Status: The polling system is fully implemented and operational. It successfully handles command orchestration, configuration synchronization, and status reporting through outbound-only HTTP communication with the backend.
Troubleshooting
Common Issues
401 Unauthorized Errors:- Indicates missing backend endpoints for satellite management
- Expected during development when backend endpoints are not implemented
- Satellite continues normal operation, polling will succeed once endpoints exist
- Check server URL format and accessibility
- Verify server type is set to ‘http’
- Ensure timeout values are positive numbers
- Check backend connectivity and availability
- Verify satellite API key is valid
- Monitor exponential backoff behavior in logs
Debug Logging
Enable debug logging to monitor polling behavior:- Polling attempt details and timing
- Configuration update processing
- Command execution results
- Error handling and recovery actions