Skip to content
This repository has been archived by the owner on Feb 7, 2020. It is now read-only.

Support for automatic re-sizing of EC2 pools #86

Merged
merged 1 commit into from
Jun 11, 2014

Conversation

squarenerd
Copy link
Contributor

The final settings will probably need tuning as we watch how it works, but this seems like a good start.

describe AutosizeWorkersJob do
let(:idle_response) {
{
:workers=>469,
Copy link
Contributor

Choose a reason for hiding this comment

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

these should be arithmetic from the actual config to 1) make it clear what your intent is, and 2) make them not break when config changes, because that is surprising

(i.e. config[:maximum_total_workers] - 1)

@xaviershay
Copy link
Contributor

thanks for implementing this!

@squarenerd
Copy link
Contributor Author

@robolson Do you approve this PR?

def self.perform
worker_thresholds = Settings.worker_thresholds
return unless worker_thresholds.present?
redis_connection = Redis.new
Copy link
Collaborator

Choose a reason for hiding this comment

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

This works because we use the default Redis settings. Eventually we'll need to pull the connection into a redis constant/global to be shared.

@robolson
Copy link
Collaborator

Proposed improvement to AutosizeWorkersJob: add need_to_upsize and need_to_downsize together and call an adjust_workers_by(difference) method which does either the spin ups or the spins downs. This would make the mocking in the tests nicer.

redis_connection.del(MonitorWorkersJob.REDIS_STATS_KEY) if need_to_upsize || need_to_downsize
if need_to_downsize
workers_to_shutdown = [worker_thresholds[:instance_chunk_size], current_workers-worker_thresholds[:minimum_total_workers]].min
1.upto(workers_to_shutdown) { ShutdownInstanceJob.enqueue_on(worker_thresholds[:autosize_queue], nil) }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of creating dummy classes we can manually enqueue a class name like this Resque.enqueue_to(worker_thresholds[:autosize_queue], 'ShutdownInstanceJob'). Is that confusing because you can' tell where ShutdownInstanceJob is coming from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, makes perfect sense. Once again I was just copying existing patterns. I'll change.

@squarenerd
Copy link
Contributor Author

@robolson How does this look?

@robolson robolson merged commit 0eb8e28 into master Jun 11, 2014
@robolson robolson deleted the rw-dynamic-ec2-sizing branch June 11, 2014 23:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants