def configure_env(settings: EnvSettings, topology: Topology): env = Environment() env.simulator_factory = settings.simulator_factory if settings.null_logger: env.metrics = OurMetrics(env, log=NullLogger()) else: env.metrics = OurMetrics(env, log=RuntimeLogger(SimulatedClock(env))) env.topology = topology env.faas = OurFaas(env, settings.scale_by_requests, settings.scale_by_requests_per_replica, settings.scale_by_queue_requests_per_replica) env.container_registry = ContainerRegistry() env.storage_index = settings.storage_index env.cluster = SimulationClusterContext(env) env.scheduler = Scheduler(env.cluster, **settings.sched_params) env.metrics_server = MetricsServer() # TODO inject resource oracle resource_monitor = ResourceMonitor( env, ResourceOracle(resources_per_node_image)) env.background_processes.append(lambda env: resource_monitor.run()) if settings.scale_by_resources: hpa_settings = settings.hpaSettings hpa = HorizontalPodAutoscaler( env, average_window=hpa_settings.average_window, reconcile_interval=hpa_settings.reconcile_interval, target_tolerance=hpa_settings.target_tolerance) env.background_processes.append(lambda env: hpa.run()) if settings.label_problem_solver_settings is not None: solver = LabelSolverProcess(settings.label_problem_solver_settings) env.background_processes.append(lambda env: solver.solve(env)) return env
# Set arrival profiles/workload pattern benchmark = ConstantBenchmark('mixed', duration=200, rps=50) # Initialize topology storage_index = StorageIndex() topology = urban_sensing_topology(ether_nodes, storage_index) # Initialize environment env = Environment() env.simulator_factory = AIPythonHTTPSimulatorFactory( get_raith21_function_characterizations(resource_oracle, fet_oracle)) env.metrics = Metrics(env, log=RuntimeLogger(SimulatedClock(env))) env.topology = topology env.faas = DefaultFaasSystem(env, scale_by_requests=True) env.container_registry = ContainerRegistry() env.storage_index = storage_index env.cluster = SimulationClusterContext(env) env.scheduler = Scheduler(env.cluster, **sched_params) sim = Simulation(env.topology, benchmark, env=env) result = sim.run() dfs = { "invocations_df": sim.env.metrics.extract_dataframe('invocations'), "scale_df": sim.env.metrics.extract_dataframe('scale'), "schedule_df": sim.env.metrics.extract_dataframe('schedule'), "replica_deployment_df":