solid_queue_autoscaler 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +189 -0
- data/LICENSE.txt +21 -0
- data/README.md +553 -0
- data/lib/generators/solid_queue_autoscaler/dashboard_generator.rb +54 -0
- data/lib/generators/solid_queue_autoscaler/install_generator.rb +21 -0
- data/lib/generators/solid_queue_autoscaler/migration_generator.rb +29 -0
- data/lib/generators/solid_queue_autoscaler/templates/README +41 -0
- data/lib/generators/solid_queue_autoscaler/templates/create_solid_queue_autoscaler_events.rb.erb +24 -0
- data/lib/generators/solid_queue_autoscaler/templates/create_solid_queue_autoscaler_state.rb.erb +15 -0
- data/lib/generators/solid_queue_autoscaler/templates/initializer.rb +58 -0
- data/lib/solid_queue_autoscaler/adapters/base.rb +102 -0
- data/lib/solid_queue_autoscaler/adapters/heroku.rb +93 -0
- data/lib/solid_queue_autoscaler/adapters/kubernetes.rb +158 -0
- data/lib/solid_queue_autoscaler/adapters.rb +57 -0
- data/lib/solid_queue_autoscaler/advisory_lock.rb +71 -0
- data/lib/solid_queue_autoscaler/autoscale_job.rb +71 -0
- data/lib/solid_queue_autoscaler/configuration.rb +269 -0
- data/lib/solid_queue_autoscaler/cooldown_tracker.rb +153 -0
- data/lib/solid_queue_autoscaler/dashboard/engine.rb +136 -0
- data/lib/solid_queue_autoscaler/dashboard/views/layouts/solid_queue_heroku_autoscaler/dashboard/application.html.erb +206 -0
- data/lib/solid_queue_autoscaler/dashboard/views/solid_queue_heroku_autoscaler/dashboard/dashboard/index.html.erb +138 -0
- data/lib/solid_queue_autoscaler/dashboard/views/solid_queue_heroku_autoscaler/dashboard/events/index.html.erb +102 -0
- data/lib/solid_queue_autoscaler/dashboard/views/solid_queue_heroku_autoscaler/dashboard/workers/index.html.erb +106 -0
- data/lib/solid_queue_autoscaler/dashboard/views/solid_queue_heroku_autoscaler/dashboard/workers/show.html.erb +209 -0
- data/lib/solid_queue_autoscaler/dashboard.rb +99 -0
- data/lib/solid_queue_autoscaler/decision_engine.rb +228 -0
- data/lib/solid_queue_autoscaler/errors.rb +44 -0
- data/lib/solid_queue_autoscaler/metrics.rb +172 -0
- data/lib/solid_queue_autoscaler/railtie.rb +179 -0
- data/lib/solid_queue_autoscaler/scale_event.rb +292 -0
- data/lib/solid_queue_autoscaler/scaler.rb +294 -0
- data/lib/solid_queue_autoscaler/version.rb +5 -0
- data/lib/solid_queue_autoscaler.rb +108 -0
- metadata +179 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 7ba25b2ae8e389c0cc4da50d7587f93df6b6eeb404ffe4d810ff8e4b574354dd
|
|
4
|
+
data.tar.gz: 73da42d85f85f71efcaa913467dffaf1aac049d2a0c12fd3a52965600f682be6
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: df644086ce41dd9ac5f7788551db7eec3fff37bfae9b81ead46d41d8850a49beaa72b0a8299a3c32171f2c8a321b0ff64ec969b4a00ad19cd9d8422b87358fc8
|
|
7
|
+
data.tar.gz: 22d75c0d678297d5ca8ac2e8c1265c2adc95b4f398a9daa4bd7a349d3ebbb3142e1753f6ec8732e88790bd97c95d6da5448549e2468e3814bfc711f502731363
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [1.0.0] - 2025-01-16
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **Renamed gem** from `solid_queue_heroku_autoscaler` to `solid_queue_autoscaler` to better reflect multi-platform support (Heroku, Kubernetes, custom adapters)
|
|
15
|
+
- **Renamed module** from `SolidQueueHerokuAutoscaler` to `SolidQueueAutoscaler`
|
|
16
|
+
- Version reset to 1.0.0 for the new gem name
|
|
17
|
+
|
|
18
|
+
### Migration from solid_queue_heroku_autoscaler
|
|
19
|
+
|
|
20
|
+
1. Update your Gemfile:
|
|
21
|
+
```ruby
|
|
22
|
+
# Old
|
|
23
|
+
gem "solid_queue_heroku_autoscaler"
|
|
24
|
+
# New
|
|
25
|
+
gem "solid_queue_autoscaler"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. Update your initializer:
|
|
29
|
+
```ruby
|
|
30
|
+
# Old
|
|
31
|
+
SolidQueueHerokuAutoscaler.configure do |config|
|
|
32
|
+
# New
|
|
33
|
+
SolidQueueAutoscaler.configure do |config|
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
3. Update any rake task references:
|
|
37
|
+
```bash
|
|
38
|
+
# Old
|
|
39
|
+
rake solid_queue_heroku_autoscaler:scale
|
|
40
|
+
# New
|
|
41
|
+
rake solid_queue_autoscaler:scale
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## [0.2.1] - 2025-01-16
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
|
|
48
|
+
- **Adapter symbol support**: Fixed `config.adapter = :heroku` and `config.adapter = :kubernetes` not working correctly. The adapter setter now properly converts symbols to adapter instances.
|
|
49
|
+
- Also supports `config.adapter = :k8s` as an alias for `:kubernetes`
|
|
50
|
+
|
|
51
|
+
## [0.2.0] - 2025-01-20
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
|
|
55
|
+
- **Dashboard UI**: Web-based dashboard for monitoring autoscaler events and status
|
|
56
|
+
- Overview page with real-time metrics, worker status, and recent events
|
|
57
|
+
- Workers page with detailed status, configuration, and cooldown info
|
|
58
|
+
- Events log with filtering by worker type
|
|
59
|
+
- Manual scale trigger from the UI
|
|
60
|
+
- **ScaleEvent model**: Tracks all scaling decisions in the database
|
|
61
|
+
- **Event recording configuration**: `record_events` and `record_all_events` options
|
|
62
|
+
- **New rake tasks**: `events`, `cleanup_events` for managing scale event history
|
|
63
|
+
- **Dashboard generator**: `rails generate solid_queue_autoscaler:dashboard`
|
|
64
|
+
- **Ruby 3.4 support**: Added CI testing for Ruby 3.4
|
|
65
|
+
|
|
66
|
+
## [0.1.0] - 2025-01-19
|
|
67
|
+
|
|
68
|
+
### Added
|
|
69
|
+
|
|
70
|
+
#### Core Features
|
|
71
|
+
- **Metrics-based autoscaling** for Solid Queue workers on Heroku and Kubernetes
|
|
72
|
+
- **Queue depth monitoring** - Scale based on number of pending jobs
|
|
73
|
+
- **Latency monitoring** - Scale based on oldest job age
|
|
74
|
+
- **Throughput tracking** - Monitor jobs processed per minute
|
|
75
|
+
|
|
76
|
+
#### Scaling Strategies
|
|
77
|
+
- **Fixed scaling** - Add/remove a fixed number of workers per scaling event
|
|
78
|
+
- **Proportional scaling** - Scale workers proportionally based on load level
|
|
79
|
+
|
|
80
|
+
#### Multi-Worker Support
|
|
81
|
+
- **Named configurations** - Configure multiple worker types independently
|
|
82
|
+
- **Per-worker cooldowns** - Each worker type has its own cooldown tracking
|
|
83
|
+
- **Unique advisory locks** - Parallel scaling of different worker types
|
|
84
|
+
- **Queue filtering** - Assign specific queues to each worker configuration
|
|
85
|
+
|
|
86
|
+
#### Infrastructure Adapters
|
|
87
|
+
- **Heroku adapter** - Scale dynos via Heroku Platform API
|
|
88
|
+
- **Kubernetes adapter** - Scale deployments via Kubernetes API
|
|
89
|
+
- **Pluggable architecture** - Easy to add custom adapters
|
|
90
|
+
|
|
91
|
+
#### Safety Features
|
|
92
|
+
- **PostgreSQL advisory locks** - Singleton execution across multiple dynos
|
|
93
|
+
- **Configurable cooldowns** - Prevent rapid scaling oscillations
|
|
94
|
+
- **Separate scale-up/down cooldowns** - Fine-tune scaling behavior
|
|
95
|
+
- **Min/max worker limits** - Prevent over/under-provisioning
|
|
96
|
+
- **Dry-run mode** - Test scaling decisions without making changes
|
|
97
|
+
|
|
98
|
+
#### Persistence
|
|
99
|
+
- **Database-backed cooldown tracking** - Survives dyno restarts
|
|
100
|
+
- **Migration generator** - Easy setup of state table
|
|
101
|
+
- **Fallback to in-memory** - Works without migration
|
|
102
|
+
|
|
103
|
+
#### Rails Integration
|
|
104
|
+
- **Railtie with rake tasks** - `scale`, `scale_all`, `metrics`, `formation`, `cooldown`, `reset_cooldown`, `workers`
|
|
105
|
+
- **Configuration initializer generator** - Quick setup
|
|
106
|
+
- **ActiveJob integration** - `AutoscaleJob` for recurring execution
|
|
107
|
+
- **Solid Queue recurring job support** - Run autoscaler on schedule
|
|
108
|
+
|
|
109
|
+
#### Developer Experience
|
|
110
|
+
- **Comprehensive test suite** - 356 RSpec examples
|
|
111
|
+
- **RuboCop configuration** - Clean, consistent code style
|
|
112
|
+
- **GitHub Actions CI** - Automated testing on Ruby 3.1, 3.2, 3.3
|
|
113
|
+
- **Detailed logging** - Track all scaling decisions and actions
|
|
114
|
+
|
|
115
|
+
### Configuration Options
|
|
116
|
+
|
|
117
|
+
```ruby
|
|
118
|
+
SolidQueueAutoscaler.configure(:worker_name) do |config|
|
|
119
|
+
# Heroku settings
|
|
120
|
+
config.heroku_api_key = ENV['HEROKU_API_KEY']
|
|
121
|
+
config.heroku_app_name = ENV['HEROKU_APP_NAME']
|
|
122
|
+
config.process_type = 'worker'
|
|
123
|
+
|
|
124
|
+
# Kubernetes settings (alternative to Heroku)
|
|
125
|
+
# config.adapter_class = SolidQueueAutoscaler::Adapters::Kubernetes
|
|
126
|
+
# config.kubernetes_deployment = 'my-worker'
|
|
127
|
+
# config.kubernetes_namespace = 'production'
|
|
128
|
+
|
|
129
|
+
# Worker limits
|
|
130
|
+
config.min_workers = 1
|
|
131
|
+
config.max_workers = 10
|
|
132
|
+
|
|
133
|
+
# Scaling strategy (:fixed or :proportional)
|
|
134
|
+
config.scaling_strategy = :fixed
|
|
135
|
+
|
|
136
|
+
# Scale-up thresholds
|
|
137
|
+
config.scale_up_queue_depth = 100
|
|
138
|
+
config.scale_up_latency_seconds = 300
|
|
139
|
+
config.scale_up_increment = 1
|
|
140
|
+
|
|
141
|
+
# Proportional scaling settings
|
|
142
|
+
config.scale_up_jobs_per_worker = 50
|
|
143
|
+
config.scale_up_latency_per_worker = 60
|
|
144
|
+
|
|
145
|
+
# Scale-down thresholds
|
|
146
|
+
config.scale_down_queue_depth = 10
|
|
147
|
+
config.scale_down_latency_seconds = 30
|
|
148
|
+
config.scale_down_decrement = 1
|
|
149
|
+
|
|
150
|
+
# Cooldowns
|
|
151
|
+
config.cooldown_seconds = 120
|
|
152
|
+
config.scale_up_cooldown_seconds = 60
|
|
153
|
+
config.scale_down_cooldown_seconds = 180
|
|
154
|
+
|
|
155
|
+
# Queue filtering
|
|
156
|
+
config.queues = ['default', 'mailers']
|
|
157
|
+
|
|
158
|
+
# Behavior
|
|
159
|
+
config.dry_run = false
|
|
160
|
+
config.enabled = true
|
|
161
|
+
|
|
162
|
+
# Custom table prefix for Solid Queue tables
|
|
163
|
+
config.table_prefix = 'solid_queue_'
|
|
164
|
+
end
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Usage Examples
|
|
168
|
+
|
|
169
|
+
```ruby
|
|
170
|
+
# Scale default worker
|
|
171
|
+
SolidQueueAutoscaler.scale!
|
|
172
|
+
|
|
173
|
+
# Scale specific worker type
|
|
174
|
+
SolidQueueAutoscaler.scale!(:critical_worker)
|
|
175
|
+
|
|
176
|
+
# Scale all configured workers
|
|
177
|
+
SolidQueueAutoscaler.scale_all!
|
|
178
|
+
|
|
179
|
+
# Get metrics for a worker
|
|
180
|
+
metrics = SolidQueueAutoscaler.metrics(:default)
|
|
181
|
+
|
|
182
|
+
# List registered workers
|
|
183
|
+
SolidQueueAutoscaler.registered_workers
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
[1.0.0]: https://github.com/reillyse/solid_queue_autoscaler/releases/tag/v1.0.0
|
|
187
|
+
[0.2.1]: https://github.com/reillyse/solid_queue_heroku_autoscaler/releases/tag/v0.2.1
|
|
188
|
+
[0.2.0]: https://github.com/reillyse/solid_queue_heroku_autoscaler/releases/tag/v0.2.0
|
|
189
|
+
[0.1.0]: https://github.com/reillyse/solid_queue_heroku_autoscaler/releases/tag/v0.1.0
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 reillyse
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|