Why are AWS Batch Jobs stuck in RUNNABLE?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
When using AWS Batch, a common issue that users encounter is jobs being stuck in the `RUNNABLE` state. The `RUNNABLE` state indicates that the job is ready to run but is waiting for resources to become available. If jobs remain in this state longer than expected, there are several potential reasons that could be contributing to the delay. Below is a detailed examination of these potential issues, alongside technical considerations and solutions.
Key Factors Leading to Jobs Stuck in RUNNABLE
1. Resource Constraints
AWS Batch operates by running jobs on resources specified within a compute environment. If insufficient resources are available, jobs may get stuck in the `RUNNABLE` state. This can occur due to:
- Insufficient vCPUs or Memory: If the respective AWS Batch compute environment does not have enough vCPUs or memory, the scheduler cannot place those jobs onto any available compute resources.
- Job Definition Resource Specifications: The requested resources for the job as defined in the job definition might be too high, making it impossible to match with available compute environments.
Solution: Ensure that your job definitions request resources that align with available compute infrastructure, or consider scaling up your compute resources.
2. Compute Environment State
The compute environment state directly affects job scheduling:
- Compute Environment Disabled: Ensure your compute environment is not set to the `DISABLED` state, as it will prevent new jobs from being placed onto the resources.
- Service Quotas: Check if service quotas (such as EC2 instance limits) have been reached, preventing the spin-up of additional resources.
Solution: Review account limits and ensure compute environments are active and within designated quotas.
3. Scheduling Policies
AWS Batch uses scheduling strategies which prioritize jobs. Misconfigured scheduling policies can lead to delayed job execution:
- Job Queues Configuration: If job queues are not properly prioritized or depleted job slots exist, lower-priority jobs may remain in the `RUNNABLE` state indefinitely.
- Fair Share Scheduling: Implementing Fair Share Scheduling without proper weight distribution might lead to small jobs occupying resources at the expense of larger ones.
Solution: Analyze the queue configuration and adjust priorities or weights to match anticipated workloads.
4. AWS Batch Service Health
Although rare, AWS service outages or degraded service performance in AWS Batch can result in jobs being stuck in `RUNNABLE` status.
Solution: Monitor AWS Service Health Dashboard and configure AWS Personal Health Dashboard to receive timely updates.
Technical Considerations
When diagnosing issues with jobs stuck in the `RUNNABLE` state, AWS provides several tools and logs:
- AWS CloudWatch Events and Logs: Capture logs for job transitions and failures to gain insights into state changes and bottlenecks.
- AWS Batch Console Metrics: Utilize metrics on the AWS Batch Console to assess compute environment usage, job queues, and scaling limits.
- AWS CloudTrail Logs: These logs help in auditing actions related to AWS Batch resources and could provide clues regarding operational activities affecting job transitions.
Summary Table
| Factor | Description | Solution |
| Resource Constraints | Lack of sufficient vCPUs or memory Mismatched resource requests in job definition | Align job definition specifications Scale up compute resources |
| Compute Environment State | Disabled state or reached service quotas | Re-enable compute environment Increase AWS account limits |
| Scheduling Policies | Misconfigured job queue priorities or fair share issues | Adjust job queue configurations Re-evaluate fair share weights |
| AWS Batch Service Health | Potential AWS service interruptions | Monitor AWS service status Set up Health Notifications |
Additional Considerations
Scalability and Cost Management
When addressing issues with stuck jobs, consider the cost-effectiveness of scaling options. Use spot instances where applicable for cost savings but prepare for interruptions due to spot market volatility.
Continuous Monitoring
Implement continuous monitoring and load testing within your compute environments. This approach helps in preemptively identifying bottlenecks and scaling requirements.
Conclusion
Understanding the intricacies of AWS Batch is critical in diagnosing why jobs may be stuck in a `RUNNABLE` state. By systematically evaluating resources, compute environment settings, policies, and service health, users can effectively minimize job delays and enhance the efficiency of batch processing operations.
Related reading
- Why are no Amazon S3 authentication handlers ready?
- Why can't an AWS lambda function inside a public subnet in a VPC connect to the internet?
- Why can't I connect AWS RDS instance from EC2 instance in another VPC after peering
- Why can't I use the new st1/sc1 EBS volumes by AWS as root volumes
- Why are circular references considered harmful?
- Why are connections to GitHub over SSH throwing an error Warning Remote Host Identification Has Changed?
- Why do I get 'execution role must be assumable' error when trying to deploy to LambdaEdge?
- Why do I need a PersistentVolume, if I have a PersistentVolumeClaim?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.