sidekiq_autoscale 0.2.2 → 0.2.5
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9594b93761884560ef45c30deeba2742fe01ef5436c22b8d0d7d0fd5a8aad7b
|
4
|
+
data.tar.gz: 000f5f60168fdc88108bec6d3b71f0a0e07abfa5438dc744e3ae560a9830f1df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbc39ccf5c38b038870bad30c2082706235d91aeb6a084ac9b935791c0487ccc3162669fe2376ebbdeed869a28d82b042f5d8c3f6b8e5456daaa4cbef379ec72
|
7
|
+
data.tar.gz: 82847ac63473029e8bdcf70caa417abd8471bb2669d4339706df337ab720c0b31a41cdee9fb3e8ca494788f07b6a415522acf7770068c63d5a17519396765e73
|
data/README.md
CHANGED
@@ -148,5 +148,33 @@ metadata:
|
|
148
148
|
|
149
149
|
Then assign your sidekiq deployment the `myapp-sidekiq` service account.
|
150
150
|
|
151
|
+
## Multiple sidekiq pools
|
152
|
+
|
153
|
+
Sidekiq autoscaler works with multiple Sidekiq pools that run off a single redis instance.
|
154
|
+
|
155
|
+
A typical use case for this would be a client pushing jobs to the same Redis backend,
|
156
|
+
which are then processed by multiple sets of workers (i.e. high CPU vs. high memory instances).
|
157
|
+
|
158
|
+
If so, you need to set two environment variables in each pool:
|
159
|
+
* `SIDEKIQ_QUEUES` - list of queues to be processed
|
160
|
+
* `SIDEKIQ_POOL` - name of the pool
|
161
|
+
|
162
|
+
You also need to use `$SIDEKIQ_POOL` tag when starting sidekiq processs.
|
163
|
+
|
164
|
+
Example:
|
165
|
+
|
166
|
+
```
|
167
|
+
# High priority pool
|
168
|
+
SIDEKIQ_QUEUES='["critical", "urgent"]'
|
169
|
+
SIDEKIQ_POOL=high
|
170
|
+
|
171
|
+
# Low priority pool
|
172
|
+
SIDEKIQ_QUEUES='["default", "low", "searchkick"]'
|
173
|
+
SIDEKIQ_POOL=low
|
174
|
+
|
175
|
+
# Start sidekiq
|
176
|
+
bundle exec sidekiq -C config/sidekiq.yml -g $SIDEKIQ_POOL
|
177
|
+
```
|
178
|
+
|
151
179
|
## License
|
152
180
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -15,7 +15,7 @@ module SidekiqAutoscale
|
|
15
15
|
|
16
16
|
def worker_count
|
17
17
|
@resources.get(@deployment_name).spec.replicas
|
18
|
-
rescue Excon::Errors::Error, K8s::Error, K8s::Error::Forbidden => e
|
18
|
+
rescue Excon::Errors::Error, Excon::Error::Socket, K8s::Error, K8s::Error::Forbidden => e
|
19
19
|
SidekiqAutoscale.on_scaling_error(e)
|
20
20
|
0
|
21
21
|
end
|
@@ -2,10 +2,11 @@
|
|
2
2
|
|
3
3
|
module SidekiqAutoscale
|
4
4
|
class Middleware
|
5
|
-
|
6
|
-
|
5
|
+
POOL_NAME = ENV.fetch("SIDEKIQ_POOL", "default")
|
6
|
+
LAST_SCALED_AT_EVENT_KEY = "sidekiq_autoscaling:#{POOL_NAME}:last_scaled_at"
|
7
|
+
SCALING_LOCK_KEY = "sidekiq_autoscaling:#{POOL_NAME}:scaling_lock"
|
7
8
|
LOG_TAG = "[SIDEKIQ_SCALE][SCALING_EVENT]"
|
8
|
-
WORKER_COUNT_KEY = "sidekiq_autoscaling/current_worker_count"
|
9
|
+
WORKER_COUNT_KEY = "sidekiq_autoscaling/#{POOL_NAME}/current_worker_count"
|
9
10
|
|
10
11
|
# @param [Object] worker the worker instance
|
11
12
|
# @param [Hash] job the full job payload
|
@@ -9,7 +9,12 @@ module SidekiqAutoscale
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def queue_names
|
12
|
-
|
12
|
+
from_env = ENV["SIDEKIQ_QUEUES"]
|
13
|
+
if from_env
|
14
|
+
JSON.parse(from_env)
|
15
|
+
else
|
16
|
+
::Sidekiq::Queue.all.map(&:name)
|
17
|
+
end
|
13
18
|
end
|
14
19
|
|
15
20
|
def busy_threads
|
@@ -39,7 +44,13 @@ module SidekiqAutoscale
|
|
39
44
|
private
|
40
45
|
|
41
46
|
def process_set
|
42
|
-
@process_set ||=
|
47
|
+
@process_set ||= begin
|
48
|
+
ps = ::Sidekiq::ProcessSet.new
|
49
|
+
pool = ENV["SIDEKIQ_POOL"]
|
50
|
+
|
51
|
+
ps = ps.select {|process| process.tag == pool } if pool
|
52
|
+
ps
|
53
|
+
end
|
43
54
|
end
|
44
55
|
end
|
45
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq_autoscale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: railties
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 5.2.6
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 5.2.6
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: redlock
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -358,7 +358,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
358
358
|
- !ruby/object:Gem::Version
|
359
359
|
version: '0'
|
360
360
|
requirements: []
|
361
|
-
rubygems_version: 3.
|
361
|
+
rubygems_version: 3.3.7
|
362
362
|
signing_key:
|
363
363
|
specification_version: 4
|
364
364
|
summary: A simple gem to handle Sidekiq autoscaling.
|