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

Sanitized options #504

Merged
merged 14 commits into from
Apr 23, 2017
Merged

Sanitized options #504

merged 14 commits into from
Apr 23, 2017

Conversation

manast
Copy link
Member

@manast manast commented Apr 21, 2017

This PR aims to cleanup the constructor of the Queue and make the options more sane. Also support for configuring a lot of settings that were constants before.

@manast
Copy link
Member Author

manast commented Apr 21, 2017

@bradvogel @chuym new PR you may be interested of. This is a small one, but will break backwards compatibility.

@bradvogel
Copy link
Contributor

Awesome! Will review shortly

README.md Outdated
var audioQueue = Queue('audio transcoding', 6379, '127.0.0.1');
var imageQueue = Queue('image transcoding', 6379, '127.0.0.1');
var pdfQueue = Queue('pdf transcoding', 6379, '127.0.0.1');
var videoQueue = Queue('video transcoding', {redis: {port: 6379, host: '127.0.0.1'}});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be clearer to use the redis string version here, eg redis://127.0.0.1:6379, since the documentation lists the redisConnectionString as the second option (albeit optional - but some people might not notice that)

README.md Outdated
var videoQueue = Queue('video transcoding', {redis: {port: 6379, host: '127.0.0.1'}});
var audioQueue = Queue('audio transcoding');
var imageQueue = Queue('image transcoding');
var pdfQueue = Queue('pdf transcoding');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's clearer to use use new in the examples, e.g. new Queue('pdf transcoding');, so it's clearer that an object instance is returned.

README.md Outdated
var imageQueue = Queue('image transcoding');
var pdfQueue = Queue('pdf transcoding');
var pdfQueue = new Queue('pdf transcoding');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the examples above too, for consistency.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. My idea was to show different ways to instantiate in the examples. I could clarify with a comment instead. I like to be able to instantiate without new, but maybe this is not a best practice anymore.

README.md Outdated
createClient?: (type: enum('client', 'subscriber'), redisOpts?: RedisOpts) => redisClient,

// Advanced settings
settings?: QueueSettings {
Copy link
Contributor

@bradvogel bradvogel Apr 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working on a PR to document these in more detail

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README.md Outdated
stalledInterval?: number = 5000,
maxStalledCount?: number = 1, // The maximum number of times a job can be recovered from the 'stalled' state
guardInterval?: number = 5000,
retryProcessDelay?: number = 5000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should include lockRenewTime?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this in #507

@bradvogel bradvogel mentioned this pull request Apr 23, 2017
@bradvogel
Copy link
Contributor

bradvogel commented Apr 23, 2017

Created PR #507 into this PR. Let me know how that looks.

The readme is coming along nicely!

README.md Outdated

// Advanced settings
settings?: QueueSettings {
lockDuration?: number = 5000,
Copy link
Contributor

@bradvogel bradvogel Apr 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about defaulting the lock to 30 seconds? My thoughts:

  • A lot of people complain about jobs being double processed currently. So there must be a lot of poorly written job processor code out there that stalls the event loop :). Or folks, like me, forget that we're running our code on tiny instances in the cloud where the CPU is so limited that a tiny bit of JS work will max the CPU. A 30sec timeout would give a bit more buffer. At least until we figure out a generic solution like [Feature] Support for running jobs in child processes #488.
  • An expired lock (due to event loop stalling) is quite fatal now that we check the lock prior to moving the job to the completed or failed (previously we would still move it if there wasn't a lock). So if a long running job (let's say 2min) stalls the event loop for even just 5sec, it means that the job is basically tombstoned at that point. It might still continue processing, but another worker would have likely picked it up as a stalled job and double-processed it. Or if it doesn't happen to get picked up as stalled, when it finally completes it still won't be moved to completed because it lost the lock at one time.
  • The tradeoff is that it will take longer for jobs to be considered 'stalled'. So instead waiting max 5sec to find out if a job was stalled, we'd wait 30sec. I think this is generally OK and that most people aren't running jobs that are that time-sensitive. Actual stalled jobs [due to process crashes] should be extremely rare anyways.

What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it is ok to have a larger value as default, specially now when it can be configured. I also look forward #488, which for long duration jobs should work much better.

README.md Outdated
// Advanced settings
settings?: QueueSettings {
lockDuration?: number = 5000,
stalledInterval?: number = 5000,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per above comment, I think this should be moved to 30sec also. It doesn't do much good to make it a lot less than the lock time. Also note that since this is run once per process, if it was set to 30sec here, across 6+ worker processes it'd get called about every 5sec anyways.

@manast manast merged commit 450f530 into v3.0.0 Apr 23, 2017
@roggervalf roggervalf deleted the sanitized-options branch May 12, 2024 00:16
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.

2 participants