🚀 Add Adaptive Polling Feature to SolidQueue #624
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves: #625
🚀 SolidQueue Adaptive Polling
Adaptive Polling is a feature that automatically optimizes SolidQueue's memory and CPU consumption by dynamically adjusting worker polling intervals based on current workload.
📊 Benefits
🔧 How It Works
The system continuously monitors:
Based on these metrics, it:
⚙️ Configuration
Basic Setup
In your Rails application that uses the SolidQueue gem, add to
config/application.rb
orconfig/environments/production.rb
:Advanced Configuration
In your Rails application, create a file
config/initializers/solid_queue_adaptive_polling.rb
:🌟 Recommended Configurations
Production (Aggressive)
Staging (Balanced)
Development (Conservative)
📈 Monitoring
The system automatically logs information about its operation:
Startup Logs
Operation Logs (Debug)
Worker Statistics
🔬 How to Test
1. Test Environment
2. Simulate Load
3. Simulate Idle
🐛 Troubleshooting
Issue: Polling too slow
Issue: Polling too fast
Issue: Slow adaptation
🔧 Advanced Per-Worker Configuration
For different configurations per worker, use YAML configuration:
📚 Detailed Algorithm
System States
Adaptation Logic
🚨 Considerations
📦 Installation and Setup
Ensure your application is using SolidQueue with the version that includes Adaptive Polling
Create an initializer in your application:
# In your Rails application touch config/initializers/solid_queue_adaptive_polling.rb
Configure based on the example file:
examples_adaptive_polling_config.rb
in the gem to see all optionsRestart your application to apply the configurations
Monitor the logs to verify it's working:
For complete example configurations, see the
examples_adaptive_polling_config.rb
file included in the gem.