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

Refactor fetcher, polling strategy and manager #236

Closed
wants to merge 9 commits into from

Conversation

mariokostelac
Copy link
Contributor

@mariokostelac mariokostelac commented Aug 13, 2016

Simplifying manager, fetcher and polling strategy in order to make whole system easier to understand, test and more performant

  • Fetcher became synchronous and quite simple. It became totally unaware of the manager so we finally lost that bidirectional dependency.
  • Manager became far slimmer. It lost responsibility of deciding on next queue (moved to polling strategy) and calls fetcher and assign method synchronously for the sake of easier testing.
  • Polling strategy it quite simple and can be replaced with something else. WeightedRoundRobin actually implements the old implicit strategy.

I've done some testing locally for next setup

  • one 1, two workers
  • workers just re-enq the job back to the q
  • run OS X 10.11.6, MacBook Pro (Retina, 13-inch, Early 2015)
  • run workers for 5 minutes

For concurrency set to 1, throughput increased ~50%.
For concurrency set to 10, throughput increased ~30%.
For concurrency set to 20, throughput increased ~20%.

It's important to note that increase becomes higher if jobs gets faster (shorter).

WDYT @phstc?

gshutler and others added 7 commits July 30, 2016 15:09
In order to be able to customize the order and manner in which Shoryuken
polls SQS queues, the previous hard-coded strategy was extracted into a
separate class.

This meant that some of the method names were altered to be more generic
(for example rebalance_queue_weight! became messages_received),
otherwise this was a direct extraction.
Mock "receive" calls appear to use a stronger interpretation of
equality.

Also altered assertions around raised errors to suppress new warnings.
expect(subject.instance_variable_get('@queues')).to eq [queue2, queue1]
it 'calls dispatch_single_messages if worker wants single messages' do
expect_any_instance_of(described_class).to receive(:dispatch_single_messages)
.with(queue_config_of(queue))

Choose a reason for hiding this comment

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

Place the . on the previous line, together with the method call receiver.

@mariokostelac mariokostelac force-pushed the mario/extract_fetcher branch from d9e13fb to e69752a Compare August 13, 2016 20:02
@mariokostelac mariokostelac changed the title WIP: extract fetcher Refactor fetcher, polling strategy and manager Aug 13, 2016
@mariokostelac mariokostelac force-pushed the mario/extract_fetcher branch from 434713a to e69752a Compare August 15, 2016 08:05
rescue => ex
logger.error { "Error fetching message: #{ex}" }
logger.error { ex.backtrace.first }
[]
Copy link
Collaborator

Choose a reason for hiding this comment

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

@mariokostelac not sure if we need rescue => ex where, as we are using watchdog wrapping the method body.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should use one or another, not both, that's for sure. I do like having error handling here because SQS does return 500 now and then and it'd be nice to return empty array / retry fetch in that case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@mariokostelac hm nvm just saw that the current implementation does the same.

@phstc
Copy link
Collaborator

phstc commented Aug 21, 2016

Hey @mariokostelac it's looking super good. I did an initial PR code review, but I'm going to checkout it and test it locally, so I can understand it better.

@phstc
Copy link
Collaborator

phstc commented Aug 28, 2016

@mariokostelac I could perform an end-to-end test today. It seems to be working fine, but ctrl-c does not seem to be working, it seems it isn't catching the shutdown signal, besides that and two feedbacks I left to you, I believe it's ready to go.

@mariokostelac
Copy link
Contributor Author

@phstc ok, I will apply changes based on your comments and take a look at Ctrl-C issue. It worked for me (that's how I stopped it), but could be I broke something.

@phstc
Copy link
Collaborator

phstc commented Aug 29, 2016

@mariokostelac if Ctrl-C (SIGINT) works fine for you, ping me and I can test it again. I don't see anything related to trapping signals in your PR, might be something on my test, but it's good to double check it.

@phstc phstc mentioned this pull request Sep 2, 2016
@atyndall
Copy link
Contributor

atyndall commented Oct 20, 2016

Has any progress been made on this? The StrictPriorityPolling implementation in pull #106 would be ideal for our circumstances.

Edit: Changes to include Strict Priority polling compatible with this PR have been submitted in #263

@phstc
Copy link
Collaborator

phstc commented Nov 2, 2016

@mariokostelac let's merge it :shipit: 🍻 so, we can also merge #263. Could you check the merge the conflicts?

@mariokostelac
Copy link
Contributor Author

@phstc I see I have not write rights anymore. Do you prefer creating another PR for that (from forked repo)?

@phstc
Copy link
Collaborator

phstc commented Dec 13, 2016

@mariokostelac I think that makes sense.

@mariokostelac
Copy link
Contributor Author

Closing in favor of #236!

@phstc phstc deleted the mario/extract_fetcher branch March 25, 2022 23:49
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