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

Integrate Azure Functions deployment with In-Vitro #569

Open
wants to merge 1 commit into
base: main
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
6 changes: 6 additions & 0 deletions azurefunctions_setup/azurefunctionsconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# azurefunctionsconfig.yaml
azurefunctionsconfig:
resource_group: ExperimentResourceGroup # Name of the resource group
storage_account_name: invitrostorage # Name of the storage account
function_app_name: invitrofunctionapp # Name of the function app
location: EastUS # Region where the resources will be created
15 changes: 15 additions & 0 deletions azurefunctions_setup/host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
}
}
8 changes: 8 additions & 0 deletions azurefunctions_setup/local.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "python",
"AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
"AzureWebJobsStorage": ""
}
}
71 changes: 71 additions & 0 deletions azurefunctions_setup/shared_azure_workload/azureworkload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import time
import os
import socket
import json
from typing import Dict

# Global variables for IterationsMultiplier and hostname
IterationsMultiplier = 102 # Assuming similar cloud benchmark setup
hostname = socket.gethostname()

# Simulate the busySpin function
def busy_spin(runtime_milli: int):
total_iterations = IterationsMultiplier * runtime_milli
for _ in range(total_iterations):
# Simulate a math-heavy operation
sqrt_of_10 = 10 ** 0.5

# Convert TraceFunctionExecution
def trace_function_execution(start: float, time_left_milliseconds: int) -> str:
time_consumed_milliseconds = int((time.time() - start) * 1000)
if time_consumed_milliseconds < time_left_milliseconds:
time_left_milliseconds -= time_consumed_milliseconds
if time_left_milliseconds > 0:
busy_spin(time_left_milliseconds)

return f"OK - {hostname}"

# The handler function for Azure Functions (Python)
import azure.functions as func
import logging

def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info("Processing request.")

start_time = time.time()

# Parse JSON request body
try:
req_body = req.get_json()
logging.info(f"Request body: {req_body}")
except ValueError:
logging.error("Invalid JSON received.")
return func.HttpResponse(
json.dumps({"error": "Invalid JSON"}),
status_code=400,
mimetype="application/json"
)

runtime_milliseconds = req_body.get('RuntimeInMilliSec', 1000)
memory_mebibytes = req_body.get('MemoryInMebiBytes', 128)

logging.info(f"Runtime requested: {runtime_milliseconds} ms, Memory: {memory_mebibytes} MiB")

# Trace the function execution (busy work simulation)
result_msg = trace_function_execution(start_time, runtime_milliseconds)

# Prepare the response
response = {
"DurationInMicroSec": int((time.time() - start_time) * 1_000_000),
"MemoryUsageInKb": memory_mebibytes * 1024,
"Message": result_msg
}

logging.info(f"Response: {response}")

return func.HttpResponse(
json.dumps(response),
status_code=200,
mimetype="application/json"
)

18 changes: 18 additions & 0 deletions azurefunctions_setup/shared_azure_workload/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": ["post"]
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
],
"scriptFile": "azureworkload.py"
}

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
azure-functions
28 changes: 28 additions & 0 deletions cmd/config_azure_trace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"Seed": 42,

"Platform": "AzureFunctions",
"InvokeProtocol" : "http1",
"EndpointPort": 80,

"BusyLoopOnSandboxStartup": false,

"TracePath": "data/traces/example",
"Granularity": "minute",
"OutputPathPrefix": "data/out/experiment",
"IATDistribution": "exponential",
"CPULimit": "1vCPU",
"ExperimentDuration": 15,
"WarmupDuration": 0,

"IsPartiallyPanic": false,
"EnableZipkinTracing": false,
"EnableMetricsScrapping": false,
"MetricScrapingPeriodSeconds": 15,
"AutoscalingMetric": "concurrency",

"GRPCConnectionTimeoutSeconds": 15,
"GRPCFunctionTimeoutSeconds": 900,

"DAGMode": false
}
3 changes: 2 additions & 1 deletion cmd/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func main() {
"Dirigent-RPS",
"Dirigent-Dandelion-RPS",
"Dirigent-Dandelion",
"AzureFunctions",
}

if !slices.Contains(supportedPlatforms, cfg.Platform) {
Expand Down Expand Up @@ -150,7 +151,7 @@ func parseYAMLSpecification(cfg *config.LoaderConfiguration) string {
case "firecracker":
return "workloads/firecracker/trace_func_go.yaml"
default:
if cfg.Platform != "Dirigent" && cfg.Platform != "Dirigent-RPS" && cfg.Platform != "Dirigent-Dandelion-RPS" && cfg.Platform != "Dirigent-Dandelion" {
if cfg.Platform != "Dirigent" && cfg.Platform != "Dirigent-RPS" && cfg.Platform != "Dirigent-Dandelion-RPS" && cfg.Platform != "Dirigent-Dandelion" && cfg.Platform != "AzureFunctions" {
log.Fatal("Invalid 'YAMLSelector' parameter.")
}
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ require (
golang.org/x/net v0.31.0
golang.org/x/text v0.20.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v2 v2.4.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWn
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
Loading
Loading