Skip to content

Commit

Permalink
further mqtt concurrency tweaks. Limit sidekiq retry queue to one wor…
Browse files Browse the repository at this point in the history
…ker and use stronger transaction isolation guarantee
  • Loading branch information
timcowlishaw committed Jun 11, 2024
1 parent e369edb commit 3a56229
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ gem 'rufus-scheduler'
gem 'sentry-ruby'
gem 'sentry-rails'
gem 'sentry-sidekiq'
gem 'sidekiq-limit_fetch'
gem 'sinatra'
#gem 'skylight'
gem 'stamp'
Expand Down
5 changes: 4 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ GEM
rack (~> 2.0)
rack-protection (>= 2.0.0)
redis (>= 4.1.0)
sidekiq-limit_fetch (4.4.1)
sidekiq (>= 6)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand Down Expand Up @@ -601,6 +603,7 @@ DEPENDENCIES
sentry-sidekiq
shoulda-matchers
sidekiq (~> 6)
sidekiq-limit_fetch
simplecov
sinatra
spring
Expand All @@ -621,4 +624,4 @@ RUBY VERSION
ruby 3.0.6p216

BUNDLED WITH
2.5.10
2.5.11
2 changes: 1 addition & 1 deletion app/lib/mqtt_messages_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def handle_topic(topic, message, retry_on_nil_device=true)
return true
end

Device.transaction(isolation: :repeatable_read) do
Device.transaction(isolation: :serializable) do
device = Device.lock.find_by(device_token: device_token(topic))
if device.nil?
handle_nil_device(topic, message, retry_on_nil_device)
Expand Down
2 changes: 2 additions & 0 deletions config/sidekiq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- default
- mailers
- mqtt_retry
:limits:
- mqtt_retry: 1

production:
:concurrency: 25
Expand Down

0 comments on commit 3a56229

Please sign in to comment.