zhangyue19921010 opened a new pull request #10524: URL: https://github.com/apache/druid/pull/10524
<!-- Thanks for trying to help us make Apache Druid be the best it can be! Please fill out as much of the following information as is possible (where relevant, and remove it when irrelevant) to help make the intention and scope of this PR clear in order to ease review. --> <!-- If you are a committer, follow the PR action item checklist for committers: https://github.com/apache/druid/blob/master/dev/committer-instructions.md#pr-and-issue-action-item-checklist-for-committers. --> ### Description <!-- Describe the goal of this PR, what problem are you fixing. If there is a corresponding issue (referenced above), it's not necessary to repeat the description here, however, you may choose to keep one summary sentence. --> <!-- Describe your patch: what did you change in code? How did you fix the problem? --> <!-- If there are several relatively logically separate changes in this PR, create a mini-section for each of them. For example: --> <!-- In each section, please describe design decisions made, including: - Choice of algorithms - Behavioral aspects. What configuration values are acceptable? How are corner cases and error conditions handled, such as when there are insufficient resources? - Class organization and design (how the logic is split between classes, inheritance, composition, design patterns) - Method organization and design (how the logic is split between methods, parameters and return types) - Naming (class, method, API, configuration, HTTP endpoint, names of emitted metrics) --> In druid, users need to set 'taskCount' when submit Kafka ingestion supervisor. It has a few limitations : 1. When supervisor is running, we can't modify the task count number. We may meet data lag during sudden peak traffic period. Users have to re-submit the supervisor with a larger task number, aiming to catch up Kafka delay. But if there are too many supervisors, this re-submit operation is very complicated. In addition do scale in action manually after sudden traffic peak. 2. In order to avoid Kafka lag during regular traffic peak, users have to set a large task count in supervisors. So that it will cause the waste of resource during regular traffic off-peak. For example, <img width="1479" alt="traffic-pattern" src="https://user-images.githubusercontent.com/69956021/96677861-09cda080-13a3-11eb-9a88-d18ead0906db.png"> Here is our traffic pattern. We have to set taskCount to 8, avoiding Kafka lag during traffic peak. At other times, 2 tasks are enough. This PR provides the ability of auto scaling the number of Kafka ingest tasks based on Lag metrics when supervisors are running. Enable this feature and ingest tasks will auto scale out during traffic peak and scale in during traffic off-peak. Here are the designs of this PR: The work flow of supervisor controller based on druid source code <img width="1324" alt="屏幕快照 2020-10-21 下午1 44 54" src="https://user-images.githubusercontent.com/69956021/96679250-de988080-13a5-11eb-9d72-4c9396ef1177.png"> As the picture shows, SupervisorManger controls all the supervisors in OverLord Service. Each Kafka Supervisor serially consume notices in LinkedBlockingQueue. Notice is an interface. RunNotice, ShutdownNotice and RestNotice are implementations of this interface. We design a new implementation named DynamicAllocationTasksNotice. We create a new Timer(lagComputationExec) to collect Kafka lags at fix rate and create a new Timer(allocationExec) to check and do scale action at fix rate, as shown below <img width="1132" alt="屏幕快照 2020-10-21 下午1 45 11" src="https://user-images.githubusercontent.com/69956021/96679313-02f45d00-13a6-11eb-9f36-04630cddf4ff.png"> For allocationExec details , <img width="460" alt="屏幕快照 2020-10-21 下午1 45 36" src="https://user-images.githubusercontent.com/69956021/96679355-143d6980-13a6-11eb-9a8f-9f413d819472.png"> Furthermore, We expand the ioConfig spec and add new parameters to control the scale behave, for example ```json "ioConfig": { "topic": "dummy_topic", "inputFormat": null, "replicas": 1, "taskCount": 1, "taskDuration": "PT3600S", "consumerProperties": { "bootstrap.servers": "xxx,xxx,xxx" }, "dynamicAllocationTasksProperties": { "enableDynamicAllocationTasks": true, "metricsCollectionIntervalMillis": 30000, "metricsCollectionRangeMillis": 600000, "scaleOutThreshold": 6000000, "triggerSaleOutThresholdFrequency": 0.3, "scaleInThreshold": 1000000, "triggerSaleInThresholdFrequency": 0.9, "dynamicCheckStartDelayMillis": 300000, "dynamicCheckPeriod": 60000, "taskCountMax": 6, "taskCountMin": 2, "scaleInStep": 1, "scaleOutStep": 2, "minTriggerDynamicFrequencyMillis": 600000 }, "pollTimeout": 100, "startDelay": "PT5S", "period": "PT30S", "useEarliestOffset": false, "completionTimeout": "PT1800S", "lateMessageRejectionPeriod": null, "earlyMessageRejectionPeriod": null, "lateMessageRejectionStartDateTime": null, "stream": "dummy_topic", "useEarliestSequenceNumber": false } ``` | Property | Description | Default | | ------------- | ------------- | ------------- | | enableDynamicAllocationTasks | whether enable this feature or not | false | | metricsCollectionIntervalMillis | Content Cell | 10000 | | metricsCollectionRangeMillis | Content Cell | 60000 | | scaleOutThreshold | Content Cell | 5000000 | | triggerSaleOutThresholdFrequency | Content Cell | 0.3 | | scaleInThreshold | Content Cell | 6000000 | | triggerSaleInThresholdFrequency | Content Cell | 0.8 | | dynamicCheckStartDelayMillis | Content Cell | 300000 | | dynamicCheckPeriod | Content Cell | 600000 | | taskCountMax | Content Cell | 8 | | taskCountMin | Content Cell | 1 | | scaleInStep | Content Cell | 1 | | scaleOutStep | Content Cell | 2 | | minTriggerDynamicFrequencyMillis | Content Cell | 1200000 | Effect evaluation : We have deployed this feature in our Production Environment For traffic regular pattern : <hr> This PR has: - [ ] been self-reviewed. - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.) - [ ] added documentation for new or modified features or behaviors. - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links. - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/licenses.yaml) - [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader. - [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met. - [ ] added integration tests. - [ ] been tested in a test Druid cluster. <!-- Check the items by putting "x" in the brackets for the done things. Not all of these items apply to every PR. Remove the items which are not done or not relevant to the PR. None of the items from the checklist above are strictly necessary, but it would be very helpful if you at least self-review the PR. --> <hr> ##### Key changed/added classes in this PR * `MyFoo` * `OurBar` * `TheirBaz` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
