{"action":"created","comment":{"url":"https://api.github.com/repos/Shopify/resque/pulls/comments/41183562","id":41183562,"diff_hunk":"@@ -460,6 +460,45 @@ def keys\n     end\n   end\n \n+  # Returns a hash with queue names and sizes in a single network roundtrip\n+  def queue_sizes\n+    queues = self.queues\n+\n+    sizes = redis.pipelined {","path":"lib/resque.rb","position":17,"original_position":17,"commit_id":"101bdc7224f11b67462bdd08cf9b47757fbf0a7d","original_commit_id":"101bdc7224f11b67462bdd08cf9b47757fbf0a7d","user":{"login":"eapache","id":1706826,"avatar_url":"https://avatars.githubusercontent.com/u/1706826?v=3","gravatar_id":"","url":"https://api.github.com/users/eapache","html_url":"https://github.com/eapache","followers_url":"https://api.github.com/users/eapache/followers","following_url":"https://api.github.com/users/eapache/following{/other_user}","gists_url":"https://api.github.com/users/eapache/gists{/gist_id}","starred_url":"https://api.github.com/users/eapache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eapache/subscriptions","organizations_url":"https://api.github.com/users/eapache/orgs","repos_url":"https://api.github.com/users/eapache/repos","events_url":"https://api.github.com/users/eapache/events{/privacy}","received_events_url":"https://api.github.com/users/eapache/received_events","type":"User","site_admin":false},"body":"It's called SCTP and nobody uses it :'(","created_at":"2015-10-05T19:05:30Z","updated_at":"2015-10-05T19:05:30Z","html_url":"https://github.com/Shopify/resque/pull/9#discussion_r41183562","pull_request_url":"https://api.github.com/repos/Shopify/resque/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/Shopify/resque/pulls/comments/41183562"},"html":{"href":"https://github.com/Shopify/resque/pull/9#discussion_r41183562"},"pull_request":{"href":"https://api.github.com/repos/Shopify/resque/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/Shopify/resque/pulls/9","id":46712840,"html_url":"https://github.com/Shopify/resque/pull/9","diff_url":"https://github.com/Shopify/resque/pull/9.diff","patch_url":"https://github.com/Shopify/resque/pull/9.patch","issue_url":"https://api.github.com/repos/Shopify/resque/issues/9","number":9,"state":"open","locked":false,"title":"metrics: performance enhancements and new metrics","user":{"login":"Sirupsen","id":97400,"avatar_url":"https://avatars.githubusercontent.com/u/97400?v=3","gravatar_id":"","url":"https://api.github.com/users/Sirupsen","html_url":"https://github.com/Sirupsen","followers_url":"https://api.github.com/users/Sirupsen/followers","following_url":"https://api.github.com/users/Sirupsen/following{/other_user}","gists_url":"https://api.github.com/users/Sirupsen/gists{/gist_id}","starred_url":"https://api.github.com/users/Sirupsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sirupsen/subscriptions","organizations_url":"https://api.github.com/users/Sirupsen/orgs","repos_url":"https://api.github.com/users/Sirupsen/repos","events_url":"https://api.github.com/users/Sirupsen/events{/privacy}","received_events_url":"https://api.github.com/users/Sirupsen/received_events","type":"User","site_admin":false},"body":"For Shopify the p99 response time for `stats.txt` and `/overview` is ~1.6s and the median ~1s. This is because when calling `Resque::Workers#all` and `Resque::Workers#working` it calls `Resque::Wokers#find` for each call to make sure the worker exists. This is not necessary for those method calls because they only operate on the workers in the working set. It does widen the race for returning workers that may have been pruned, but that race is already present.\r\n\r\nThe solution to this problem is to give `#find` an extra argument to skip this check when initializing the worker.\r\n\r\nThis also adds `Resque#queue_sizes` and `Resque#sample_queues` which are useful to get information back about the state of the queues. For Shopify employees you can see examples of using [this in ActiveFailover](https://github.com/Shopify/activefailover/blob/master/lib/activefailover/task/transfer_jobs.rb). However, it is also useful for monitoring and for chat bots so pushing it upstream is useful to share as much code as possible. E.g. in Shopify's case this would allow monitoring the # of jobs for a specific shard and shop. More generally, it'd make us able to get a good overview of the type of jobs enqueued.\r\n\r\nThese optimizations are mostly to reduce the # of network roundtrips since this is extremely costly over VPN or between data centers which is a common scenario for us now.\r\n\r\n@dylanahsmith @eapache @camilo @fw42","created_at":"2015-10-03T20:39:07Z","updated_at":"2015-10-05T19:05:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"69fab4284f65ae246a7a177799f88fb7371150fd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Shopify/resque/pulls/9/commits","review_comments_url":"https://api.github.com/repos/Shopify/resque/pulls/9/comments","review_comment_url":"https://api.github.com/repos/Shopify/resque/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Shopify/resque/issues/9/comments","statuses_url":"https://api.github.com/repos/Shopify/resque/statuses/101bdc7224f11b67462bdd08cf9b47757fbf0a7d","head":{"label":"Shopify:performance-metrics","ref":"performance-metrics","sha":"101bdc7224f11b67462bdd08cf9b47757fbf0a7d","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":19742633,"name":"resque","full_name":"Shopify/resque","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/resque","description":"Resque is a Redis-backed Ruby library for creating background jobs, placing them on multiple queues, and processing them later.","fork":true,"url":"https://api.github.com/repos/Shopify/resque","forks_url":"https://api.github.com/repos/Shopify/resque/forks","keys_url":"https://api.github.com/repos/Shopify/resque/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/resque/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/resque/teams","hooks_url":"https://api.github.com/repos/Shopify/resque/hooks","issue_events_url":"https://api.github.com/repos/Shopify/resque/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/resque/events","assignees_url":"https://api.github.com/repos/Shopify/resque/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/resque/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/resque/tags","blobs_url":"https://api.github.com/repos/Shopify/resque/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/resque/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/resque/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/resque/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/resque/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/resque/languages","stargazers_url":"https://api.github.com/repos/Shopify/resque/stargazers","contributors_url":"https://api.github.com/repos/Shopify/resque/contributors","subscribers_url":"https://api.github.com/repos/Shopify/resque/subscribers","subscription_url":"https://api.github.com/repos/Shopify/resque/subscription","commits_url":"https://api.github.com/repos/Shopify/resque/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/resque/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/resque/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/resque/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/resque/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/resque/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/resque/merges","archive_url":"https://api.github.com/repos/Shopify/resque/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/resque/downloads","issues_url":"https://api.github.com/repos/Shopify/resque/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/resque/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/resque/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/resque/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/resque/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/resque/releases{/id}","created_at":"2014-05-13T14:37:55Z","updated_at":"2015-02-09T19:38:14Z","pushed_at":"2015-10-03T20:39:07Z","git_url":"git://github.com/Shopify/resque.git","ssh_url":"git@github.com:Shopify/resque.git","clone_url":"https://github.com/Shopify/resque.git","svn_url":"https://github.com/Shopify/resque","homepage":"http://github.com/blog/542-introducing-resque","size":3426,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"Shopify:master","ref":"master","sha":"6e2890ebf8eaba7dd568cad8af7a63162f0f5aaa","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":19742633,"name":"resque","full_name":"Shopify/resque","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/resque","description":"Resque is a Redis-backed Ruby library for creating background jobs, placing them on multiple queues, and processing them later.","fork":true,"url":"https://api.github.com/repos/Shopify/resque","forks_url":"https://api.github.com/repos/Shopify/resque/forks","keys_url":"https://api.github.com/repos/Shopify/resque/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/resque/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/resque/teams","hooks_url":"https://api.github.com/repos/Shopify/resque/hooks","issue_events_url":"https://api.github.com/repos/Shopify/resque/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/resque/events","assignees_url":"https://api.github.com/repos/Shopify/resque/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/resque/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/resque/tags","blobs_url":"https://api.github.com/repos/Shopify/resque/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/resque/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/resque/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/resque/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/resque/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/resque/languages","stargazers_url":"https://api.github.com/repos/Shopify/resque/stargazers","contributors_url":"https://api.github.com/repos/Shopify/resque/contributors","subscribers_url":"https://api.github.com/repos/Shopify/resque/subscribers","subscription_url":"https://api.github.com/repos/Shopify/resque/subscription","commits_url":"https://api.github.com/repos/Shopify/resque/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/resque/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/resque/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/resque/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/resque/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/resque/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/resque/merges","archive_url":"https://api.github.com/repos/Shopify/resque/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/resque/downloads","issues_url":"https://api.github.com/repos/Shopify/resque/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/resque/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/resque/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/resque/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/resque/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/resque/releases{/id}","created_at":"2014-05-13T14:37:55Z","updated_at":"2015-02-09T19:38:14Z","pushed_at":"2015-10-03T20:39:07Z","git_url":"git://github.com/Shopify/resque.git","ssh_url":"git@github.com:Shopify/resque.git","clone_url":"https://github.com/Shopify/resque.git","svn_url":"https://github.com/Shopify/resque","homepage":"http://github.com/blog/542-introducing-resque","size":3426,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Shopify/resque/pulls/9"},"html":{"href":"https://github.com/Shopify/resque/pull/9"},"issue":{"href":"https://api.github.com/repos/Shopify/resque/issues/9"},"comments":{"href":"https://api.github.com/repos/Shopify/resque/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/Shopify/resque/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/Shopify/resque/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Shopify/resque/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/Shopify/resque/statuses/101bdc7224f11b67462bdd08cf9b47757fbf0a7d"}}}}