{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/10089","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/10089/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/10089/comments","events_url":"https://api.github.com/repos/apache/spark/issues/10089/events","html_url":"https://github.com/apache/spark/pull/10089","id":119872234,"number":10089,"title":"[SPARK-12073] [Streaming] backpressure rate controller consumes events preferentially from lagg…","user":{"login":"JasonMWhite","id":2893818,"avatar_url":"https://avatars.githubusercontent.com/u/2893818?v=3","gravatar_id":"","url":"https://api.github.com/users/JasonMWhite","html_url":"https://github.com/JasonMWhite","followers_url":"https://api.github.com/users/JasonMWhite/followers","following_url":"https://api.github.com/users/JasonMWhite/following{/other_user}","gists_url":"https://api.github.com/users/JasonMWhite/gists{/gist_id}","starred_url":"https://api.github.com/users/JasonMWhite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JasonMWhite/subscriptions","organizations_url":"https://api.github.com/users/JasonMWhite/orgs","repos_url":"https://api.github.com/users/JasonMWhite/repos","events_url":"https://api.github.com/users/JasonMWhite/events{/privacy}","received_events_url":"https://api.github.com/users/JasonMWhite/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-12-02T05:50:02Z","updated_at":"2016-02-09T18:21:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/10089","html_url":"https://github.com/apache/spark/pull/10089","diff_url":"https://github.com/apache/spark/pull/10089.diff","patch_url":"https://github.com/apache/spark/pull/10089.patch"},"body":"…ing partitions\r\n\r\nI'm pretty sure this is the reason we couldn't easily recover from an unbalanced Kafka partition under heavy load when using backpressure.\r\n\r\n`maxMessagesPerPartition` calculates an appropriate limit for the message rate from all partitions, and then divides by the number of partitions to determine how many messages to retrieve per partition. The problem with this approach is that when one partition is behind by millions of records (due to random Kafka issues), but the rate estimator calculates only 100k total messages can be retrieved, each partition (out of say 32) only retrieves max 100k/32=3125 messages.\r\n\r\nThis PR (still needing a test) determines a per-partition desired message count by using the current lag for each partition to preferentially weight the total message limit among the partitions. In this situation, if each partition gets 1k messages, but 1 partition starts 1M behind, then the total number of messages to retrieve is (32 * 1k + 1M) = 1032000 messages, of which the one partition needs 1001000. So, it gets (1001000 / 1032000) = 97% of the 100k messages, and the other 31 partitions share the remaining 3%.\r\n\r\nAssuming all of 100k the messages are retrieved and processed within the batch window, the rate calculator will increase the number of messages to retrieve in the next batch, until it reaches a new stable point or the backlog is finished processed.\r\n\r\nWe're going to try deploying this internally at Shopify to see if this resolves our issue.\r\n\r\n@tdas @koeninger @holdenk "},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/181990835","html_url":"https://github.com/apache/spark/pull/10089#issuecomment-181990835","issue_url":"https://api.github.com/repos/apache/spark/issues/10089","id":181990835,"user":{"login":"JasonMWhite","id":2893818,"avatar_url":"https://avatars.githubusercontent.com/u/2893818?v=3","gravatar_id":"","url":"https://api.github.com/users/JasonMWhite","html_url":"https://github.com/JasonMWhite","followers_url":"https://api.github.com/users/JasonMWhite/followers","following_url":"https://api.github.com/users/JasonMWhite/following{/other_user}","gists_url":"https://api.github.com/users/JasonMWhite/gists{/gist_id}","starred_url":"https://api.github.com/users/JasonMWhite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JasonMWhite/subscriptions","organizations_url":"https://api.github.com/users/JasonMWhite/orgs","repos_url":"https://api.github.com/users/JasonMWhite/repos","events_url":"https://api.github.com/users/JasonMWhite/events{/privacy}","received_events_url":"https://api.github.com/users/JasonMWhite/received_events","type":"User","site_admin":false},"created_at":"2016-02-09T18:21:28Z","updated_at":"2016-02-09T18:21:28Z","body":"I'm not sure how to handle the mima test failure, could you point me to where to add the exclude? I'll rebase and add the exception."}}