Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building support for local deployment #142

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sebs/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def update_storage(self, deployment: str, benchmark: str, config: dict):
with self._lock:
with open(os.path.join(benchmark_dir, "config.json"), "r") as fp:
cached_config = json.load(fp)
cached_config[deployment] = {}
cached_config[deployment]["storage"] = config
with open(os.path.join(benchmark_dir, "config.json"), "w") as fp:
json.dump(cached_config, fp, indent=2)
Expand Down
3 changes: 0 additions & 3 deletions sebs/experiments/perf_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def run(self):
self.run_configuration(settings, settings["repetitions"], suffix=str(memory))

def compute_statistics(self, times: List[float]):

mean, median, std, cv = basic_stats(times)
self.logging.info(f"Mean {mean} [ms], median {median} [ms], std {std}, CV {cv}")
for alpha in [0.95, 0.99]:
Expand Down Expand Up @@ -156,7 +155,6 @@ def _run_configuration(
self._deployment_client.enforce_cold_start(
[self._function], self._benchmark
)

time.sleep(5)

results = []
Expand Down Expand Up @@ -224,7 +222,6 @@ def _run_configuration(
)

def run_configuration(self, settings: dict, repetitions: int, suffix: str = ""):

for experiment_type in settings["experiments"]:
if experiment_type == "cold":
self._run_configuration(
Expand Down
1 change: 1 addition & 0 deletions sebs/local/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def deserialize(cached_config: dict) -> "LocalFunction":
)
except docker.errors.NotFound:
raise RuntimeError(f"Cached container {instance_id} not available anymore!")
# FIXME: clear cache

def stop(self):
self.logging.info(f"Stopping function container {self._instance_id}")
Expand Down
25 changes: 16 additions & 9 deletions sebs/local/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def get_storage(self, replace_existing: bool = False) -> PersistentStorage:
"""

def shutdown(self):
pass

if hasattr(self, "storage") and self.config.shutdownStorage:
self.storage.stop()
"""
It would be sufficient to just pack the code and ship it as zip to AWS.
However, to have a compatible function implementation across providers,
Expand Down Expand Up @@ -170,8 +170,10 @@ def create_function(self, code_package: Benchmark, func_name: str) -> "LocalFunc
self.name(), code_package.language_name
),
}

container = self._docker_client.containers.run(
image=container_name,
name=func_name,
command=f"/bin/bash /sebs/run_server.sh {self.DEFAULT_PORT}",
volumes={code_package.code_location: {"bind": "/function", "mode": "ro"}},
environment=environment,
Expand Down Expand Up @@ -224,12 +226,13 @@ def create_function(self, code_package: Benchmark, func_name: str) -> "LocalFunc
)
return func

"""
FIXME: restart Docker?
"""

def update_function(self, function: Function, code_package: Benchmark):
pass
# kill existing containers
for ctr in self._docker_client.containers.list():
if ctr.name in function.name:
ctr.kill()
# deploy new containers with updated function
self.create_function(code_package, function.name)

"""
For local functions, we don't need to do anything for a cached function.
Expand All @@ -251,7 +254,8 @@ def create_trigger(self, func: Function, trigger_type: Trigger.TriggerType) -> T
return trigger

def cached_function(self, function: Function):
pass
for trigger in function.triggers(Trigger.TriggerType.LIBRARY):
trigger.logging_handlers = self.logging_handlers

def update_function_configuration(self, function: Function, code_package: Benchmark):
self.logging.error("Updating function configuration of local deployment is not supported")
Expand All @@ -268,7 +272,10 @@ def download_metrics(
pass

def enforce_cold_start(self, functions: List[Function], code_package: Benchmark):
raise NotImplementedError()
fn_names = [fn.name for fn in functions]
for ctr in self._docker_client.containers.list():
if ctr.name in fn_names:
ctr.kill()

@staticmethod
def default_function_name(code_package: Benchmark) -> str:
Expand Down