Implement a function that simulates an autoscaling system for a model-serving deployment. The simulator processes a time series of incoming request rates (requests per second) and dynamically adjusts the number of active replicas based on utilization thresholds, while tracking Service Level Agreement (SLA) compliance.
Your function should accept:
rps_series: A list of integers representing the incoming requests per second at each time stepcapacity_per_replica: An integer representing the maximum requests per second each replica can handlemin_replicas: The minimum number of replicas that must remain activemax_replicas: The maximum number of replicas allowedscale_up_threshold: A float; if utilization exceeds this value, a scale-up action is triggeredscale_down_threshold: A float; if utilization drops below this value, a scale-down action is triggeredcooldown_steps: An integer representing how many time steps must pass after a scaling action before another scaling action is permittedThe simulation starts with min_replicas active. At each time step, the system computes utilization as the ratio of incoming RPS to total capacity. An SLA violation occurs when requests exceed total capacity, and any requests beyond capacity are considered dropped. After computing metrics for the current step, the system evaluates whether to scale up or down by one replica, subject to replica bounds and the cooldown constraint. A scaling action only resets the cooldown if the replica count actually changes.
Your function should return a dictionary with:
'final_replicas': The replica count at the end of the simulation'total_sla_violations': Number of time steps where demand exceeded capacity'average_utilization': Mean utilization across all time steps, rounded to 2 decimal places'max_replicas_used': The peak replica count observed during the simulation'total_dropped_requests': Total requests that could not be served due to insufficient capacity