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

allow batch enqueueing of jobs using Redis Pipelining #154

Merged
merged 3 commits into from
Jan 11, 2019

Conversation

jack-kerouac
Copy link
Contributor

This change allows enqueueing a list of jobs with higher performance than one-by-one invoking the existing client.enqueue() method. It therefore uses Redis Pipelining: https://redis.io/topics/pipelining.

I decided against supporting splitting the list of jobs into chunks of e.g. 10,000 jobs, which is recommended by Redis ('Important Note' at https://redis.io/topics/pipelining#redis-pipelining). I mentioned this in the JavaDoc and left it to the client of this method to keep the library simple. Some clients might want to ignore this and I wanted to leave it up to the user.

This change also includes a bit of refactoring of the validate methods to be able to validate the queue name parameter independently of a job parameter.

Closes #123

maciejp and others added 3 commits December 18, 2018 12:00
Using Redis Pipelining is much faster than one-by-one enqueueing since there is a single Round-Trip-Time for the entire batch, instead of one RTT for each job. This improves the performance of enqueueing a large number of jobs considerably.

I decided against splitting large batches into multiple chunks (as recommended by https://redis.io/topics/pipelining#redis-pipelining), but mentioned it in the JavaDoc of this method. Thus, it is up to the user of this library to decide whether he wants to consider chunking the batch.
Not once per job in the list. Thus, I refactored the validation methods to be smaller. I decided against inlining `validateArguments()` method since I am not sure whether this is in line with the design principle of the author of this library.
@jack-kerouac
Copy link
Contributor Author

This PR supersedes #153. Sorry for the confusion.

Please review and merge. Thanks for the great work!

@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) to 70.365% when pulling 02e3af9 on tadodotcom:batch-enqueue-using-pipelining into 88bab76 on gresrun:master.

@bp-FLN
Copy link
Contributor

bp-FLN commented Dec 19, 2018

can you maybe please tell how much faster that solution is?

@jack-kerouac
Copy link
Contributor Author

This mainly depends on the RTT to Redis (and of course the number of jobs).

If the RTT to Redis is 1ms, enqueueing 1000 jobs takes 1s, if done one by one. If done using the new method, it is 1ms (or a little more since Redis still needs to append to the list, but this is very fast, compared to network latency). So the speedup factor is basically equal to the number of jobs to enqueue :-).

@gresrun gresrun merged commit dcffe90 into gresrun:master Jan 11, 2019
@gresrun
Copy link
Owner

gresrun commented Jan 11, 2019

Thanks for the PR!

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.

5 participants