Skip to content

Move experience broadcasts to async Sidekiq job#213

Open
JaredShay wants to merge 4 commits into
mainfrom
segment-performance-improvements
Open

Move experience broadcasts to async Sidekiq job#213
JaredShay wants to merge 4 commits into
mainfrom
segment-performance-improvements

Conversation

@JaredShay

Copy link
Copy Markdown
Collaborator

Replace all synchronous broadcast_experience_update calls with a coalescing Sidekiq job (BroadcastUpdateJob) that uses sidekiq-unique-jobs lock: :until_executing per experience_id. This caps inflight work at 1 executing + 1 queued per experience, eliminating the 200+ query serialization cost from the HTTP path.

Two broadcast paths remain synchronous: resubscribe_required messages (extracted to broadcast_profile_changes) and the existing broadcast_family_feud_update delta events.

Also replace the Thread.new { sleep 3 } in show_x with a proper Minigames::ClearShowXJob.set(wait: 3.seconds) call.

Test adapter is now :test by default in specs and :inline for system specs so BroadcastUpdateJob executes synchronously in browser tests. Add a new segment_visibility_spec covering the manual assign/remove resubscribe path end-to-end.

@JaredShay
JaredShay force-pushed the segment-performance-improvements branch 2 times, most recently from 6605b8a to 44b9e1f Compare June 17, 2026 18:30
Replace all synchronous broadcast_experience_update calls with a
coalescing Sidekiq job (BroadcastUpdateJob) that uses
sidekiq-unique-jobs lock: :until_executing per experience_id.
This caps inflight work at 1 executing + 1 queued per experience,
eliminating the 200+ query serialization cost from the HTTP path.

Two broadcast paths remain synchronous: resubscribe_required
messages (extracted to broadcast_profile_changes) and the existing
broadcast_family_feud_update delta events.

Also replace the Thread.new { sleep 3 } in show_x with a proper
Minigames::ClearShowXJob.set(wait: 3.seconds) call.

Test adapter is now :test by default in specs and :inline for
system specs so BroadcastUpdateJob executes synchronously in
browser tests. Add a new segment_visibility_spec covering the
manual assign/remove resubscribe path end-to-end.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@JaredShay
JaredShay force-pushed the segment-performance-improvements branch from 44b9e1f to 3da9bbc Compare June 17, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant