Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question - stress testing and workers #602

Open
sheldondz opened this issue Sep 19, 2024 · 2 comments
Open

Question - stress testing and workers #602

sheldondz opened this issue Sep 19, 2024 · 2 comments

Comments

@sheldondz
Copy link

sheldondz commented Sep 19, 2024

Hi,

We are writing some stress tests to batch writes to an external data source, we have a worker that processes a job after x seconds and batches the data.

We plan to spawn a large number jobs to do this, is there a way to wait for all workers to be done and track for failures.

We currently using copied from the river tests itself, is this the best way to test this?

subscribeChan, subscribeCancel := client.Subscribe(river.EventKindJobCompleted, river.EventKindJobFailed)
defer subscribeCancel()
events := waitForNJobs(subscribeChan, N)

@brandur
Copy link
Contributor

brandur commented Sep 21, 2024

@sheldondz Yeah, subscriptions are one way to do this. However, note that subscription events are only emitted for jobs worked within the specific client instance that's subscribed to. i.e. If you have two separate nodes both running their own River client, each one must be subscribed to separately, and assuming each client is working roughly equal jobs, each subscription will only receive half the total jobs going through the queue.

The other strategy to consider would just be a classic poll loop. I know it sounds icky, but as long as you pick a reasonable period duration (not too fast to hammer the database, but not too slow as to be unresponsive), it'd probably work fine in practice.

@sheldondz
Copy link
Author

@brandur thanks for the suggestions.

So for this case will it be possible for me to have 2 queues, with 2 clients?

Client 1 processes jobs using LISTEN/NOTIFY
Client 2 processes jobs using polling. The queue for this client will only create jobs for the above scenario.

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

No branches or pull requests

2 participants