【发布时间】:2021-01-06 09:14:50
【问题描述】:
风险建模系统使用缩放计算系统,该系统根据计算系统的当前负载或利用率实施自动缩放策略。
系统以实例给定的多个计算实例开始。系统每秒轮询实例以查看该秒的平均利用率,并执行如下所示的缩放。一旦采取任何行动,系统将停止轮询 10 秒。在此期间,实例的数量不会改变。
平均利用率 > 60%:如果加倍的值不超过 2 * 10^8,则将实例数加倍。这是一个动作。如果实例数超过此限制加倍,则不执行任何操作。
平均利用率
25%
将该系统每秒的平均利用率值作为一个数组确定时间范围结束时的实例数。
例如,系统从实例 = 2 开始。平均利用率为 averageUtil = [25, 23, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 76, 80] .
在第一秒,利用率为 25,因此不采取任何行动。
At the second second, averageUtil[1] = 23 < 25, so instances = 2 / 2 = 1. The next 10 seconds, averageUtil[2]..averageUtil[11], no polling is done.
在 averageUtil(12] = 76, 76 > 60 时,实例数增加了一倍。没有更多的读数需要考虑,2 是最终答案。
Example 1:
Input: averageUtil=[1, 3, 5, 10, 80]
Output: 2
Explanation:
Here instance = 1 and averageUtil = [5, 10, 80]. At the 1st and 2nd seconds of the time period, no action will be taken, Even though the utilization is less than 25%, the number of instance is 1. During the 3rd second, the no of instance will be doubled to 2.
Constraints:
1 <= instances <= 10^5
1 <= n <= 10^5
1 <= averageUtil[i] <= 10
【问题讨论】:
标签: python python-3.x data-structures