Background Jobs
Background Jobs
Learn how background jobs work in the Shifts platform, including how to monitor job status, troubleshoot issues, configure workers, and optimize performance for system administrators.
Overview
Background jobs in the Shifts platform handle resource-intensive tasks asynchronously to maintain system performance and user experience. These jobs process operations like report generation, data imports/exports, notifications, email delivery, and scheduled maintenance without blocking user interactions. This article explains how background jobs work and how system administrators can monitor, manage, and troubleshoot them.
Understanding Background Jobs
How Background Jobs Work
Background jobs operate on a queuing system:
- The application creates a job with specific parameters
- The job is added to a queue
- Worker processes pick up jobs from the queue
- Workers execute the jobs asynchronously
- Results are stored or actions are taken based on job outcomes
Job Types in Shifts
The platform uses several job categories:
- Immediate Jobs: Time-sensitive operations that run as soon as possible
- Scheduled Jobs: Tasks that run at predetermined times
- Recurring Jobs: Regular maintenance operations that repeat on a schedule
- Priority Jobs: Critical operations that take precedence in the queue
- Batch Jobs: Large operations broken into smaller chunks for processing
Accessing Background Job Management
To monitor and manage background jobs:
- Log in with system administrator credentials
- Navigate to System Admin > System Tools > Background Jobs
- The job management dashboard will display
- Use the tabs and controls to view and manage different aspects of the job system
Job Dashboard Overview
Main Dashboard
The job dashboard displays:
- Active Workers: Currently running worker processes
- Queue Depths: Number of jobs waiting in each queue
- Processing Rate: Jobs processed per minute
- Recent Jobs: Recently completed or failed jobs
- Scheduled Jobs: Upcoming tasks with execution times
- System Health: Worker and queue health indicators
Queue Monitoring
View detailed queue information:
- Click the Queues tab
- For each queue, see:
- Queue name and purpose
- Current job count
- Average processing time
- Oldest job age
- Queue latency (delay before processing)
- Set up alerts for queue thresholds
Worker Monitoring
Track worker processes:
- Navigate to the Workers tab
- View:
- Worker ID and host
- Current status (idle, busy, dead)
- Currently processing job (if any)
- Uptime and job count
- Resource utilization (memory, CPU)
- Start, stop, or restart workers as needed
Common Background Jobs
AI Assistant Jobs
Jobs related to AI features:
- AI Thread Cleanup: Removes old conversation threads
- Vector Store Upload: Updates knowledge base vector stores
- Assistant Setup: Configures and initializes AI assistants
- Assistant Scheduled: Performs regular maintenance on assistants
Analytics Jobs
Data processing operations:
- Analytics Processor: Calculates and caches analytics data
- Report Generation: Creates scheduled reports
- Dashboard Refresh: Updates dashboard metrics and charts
- Data Aggregation: Compiles data for business intelligence
User Communication Jobs
Notifications and messaging:
- Email Delivery: Sends system emails and notifications
- SMS Delivery: Processes text message notifications
- In-App Notification: Delivers in-platform notifications
- Digest Creation: Compiles periodic notification digests
Data Management Jobs
Data processing and maintenance:
- Data Import: Processes uploaded CSV/Excel files
- Data Export: Generates downloadable data exports
- Bulk Operations: Processes mass updates to records
- Schema Sync: Updates database knowledge repositories
System Maintenance Jobs
Administrative tasks:
- Orphaned Business Cleanup: Removes abandoned business data
- Session Cleanup: Purges expired user sessions
- Temporary File Cleanup: Removes old temporary files
- Database Optimization: Performs database maintenance
Managing Scheduled Jobs
Viewing Scheduled Jobs
See upcoming jobs:
- Navigate to the Scheduled tab
- View all pending scheduled jobs
- For each job, see:
- Job type and description
- Scheduled execution time
- Recurrence pattern (if recurring)
- Last execution result
- Next execution time
Creating Scheduled Jobs
Set up new scheduled tasks:
- Click Add Scheduled Job
- Select the job type from available options
- Configure job parameters:
- Schedule (one-time or recurring)
- Timing options (daily, weekly, monthly)
- Priority level
- Notification settings
- Click Create Job
Modifying Job Schedules
Adjust existing job schedules:
- Find the job in the scheduled jobs list
- Click Edit
- Modify schedule parameters:
- Change timing or frequency
- Adjust parameters
- Enable/disable the job
- Click Save Changes
Job Configuration and Performance
Queue Configuration
Optimize queue settings:
- Navigate to System Admin > System Configuration > Background Jobs
- Click the Queue Settings tab
- Configure:
- Queue Names: Add or modify queue definitions
- Job Routing: Define which jobs go to which queues
- Queue Priorities: Set processing priority
- Concurrency Limits: Maximum jobs processed simultaneously
- Click Save Configuration
Worker Configuration
Manage worker processes:
- Go to the Worker Configuration tab
- Configure:
- Worker Count: Number of worker processes
- Memory Limits: Maximum memory per worker
- Timeout Settings: How long before jobs are considered stuck
- Retry Settings: When and how to retry failed jobs
- Resource Allocation: CPU and memory allocation
- Click Save Worker Configuration
Performance Tuning
Optimize job processing:
- Navigate to Performance Settings
- Configure performance parameters:
- Batch Size: How many jobs to process in batches
- Rate Limiting: Control processing speed
- Throttling Rules: Prevent queue overloading
- Resource Allocation: Balance system resources
- Apply and monitor performance changes
Monitoring and Troubleshooting
Job Logs
View detailed job history:
- Go to the Job History tab
- Search and filter job logs:
- By job type
- By status (completed, failed)
- By date range
- By queue
- Click on any job for detailed information:
- Complete parameters
- Execution time and duration
- Error messages (if failed)
- Stack trace (for debugging)
- Retry history
Failed Jobs
Manage failed operations:
- Navigate to the Failed tab
- View all failed jobs with:
- Error details
- Failure time
- Retry count
- Job parameters
- For any failed job, choose to:
- Retry: Attempt the job again
- Delete: Remove from the failed queue
- Edit & Retry: Modify parameters and retry
- Move to Dead: Archive permanently failed jobs
Job Statistics
Analyze job performance:
- Go to the Statistics tab
- View metrics like:
- Jobs processed per hour/day
- Average processing time
- Failure rate by job type
- Queue throughput
- Worker efficiency
- Use graphs and charts to identify:
- Peak processing times
- Recurring failures
- Performance bottlenecks
- Resource constraints
Advanced Job Management
Job Prioritization
Set processing order:
- Navigate to Priority Settings
- Define priority levels (Critical, High, Normal, Low)
- Assign job types to priority levels
- Configure queue behavior for different priorities
- Set up priority bumping for aging jobs
Job Dependencies
Configure job sequences:
- Go to Job Dependencies
- Create job chains where:
- One job must complete before another starts
- Success/failure conditions trigger different follow-up jobs
- Complex workflows can be automated
- Set up error handling for dependency chains
Web Interface Access Control
Manage dashboard access:
- Navigate to Security Settings
- Configure:
- Access Permissions: Who can view/manage jobs
- IP Restrictions: Limit access by IP address
- Authentication: Additional security layers
- Action Logging: Track who performs which actions
- Save security settings
System Integration
API Access
Access job functionality programmatically:
- Navigate to API Integration
- View documentation for:
- Creating jobs via API
- Checking job status
- Managing workers and queues
- Retrieving job results
- Generate API tokens for secure access
- Test API endpoints from the interface
Notification Integration
Configure job notifications:
- Go to Notification Settings
- Set up alerts for:
- Failed critical jobs
- Queue backlog thresholds
- Worker failures
- Job completion
- Configure delivery channels (email, SMS, webhook)
- Set notification thresholds and schedules
Disaster Recovery
Backup and Restore
Protect job data:
- Navigate to Backup Settings
- Configure:
- Queue data backups
- Job history archiving
- Scheduled backup jobs
- Retention policies
- Test restore procedures for job data
Failover Configuration
Prepare for system issues:
- Go to Failover Settings
- Configure:
- Redundant worker processes
- Automatic worker restarts
- Queue rebalancing during outages
- Recovery procedures
Best Practices
For optimal background job management:
- Regular Monitoring: Check job queues and failures daily
- Scale Appropriately: Adjust worker count based on system load
- Prioritize Critical Jobs: Ensure essential operations take precedence
- Set Job Timeouts: Prevent stuck jobs from blocking queues
- Configure Retries: Automatically retry transient failures
- Balance Resources: Donβt let background jobs impact user experience
- Archive Old Data: Regularly clear old job history to maintain performance
- Monitor Trends: Track job volume and performance over time
Related Resources
This article should be updated when:
- New background job types are added
- Job processing infrastructure changes
- Configuration options are expanded
- Management interface is updated
- Integration capabilities are enhanced