Skip to content

Commit

Permalink
fix(slimfaas): metrics (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-chervet authored Jan 2, 2025
1 parent fda13cd commit f1f05f3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
![SlimFaas.png](https://github.com/AxaFrance/SlimFaas/blob/main/documentation/SlimFaas.png)

Why use SlimFaas?
- Scale to 0 after a period of inactivity (work with deployment and statefulset)
- Scale up : compatible with HPA (Horizontal Auto Scaler) and Keda (SlimFaas integrated autonomous Scale Up coming soon)
- Scale
- to 0 after a period of inactivity (work with deployment and statefulset)
- up from 0 to n at start
- up from n to n+m : compatible with HPA (Horizontal Auto Scaler) and Keda + Prometheus via /metrics routes (SlimFaas integrated autonomous Scale Up coming soon)
- Synchronous HTTP calls
- Asynchronous HTTP calls
- Allows you to limit the number of parallel HTTP requests for each underlying function
Expand Down
19 changes: 17 additions & 2 deletions src/SlimFaas/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@

return httpClientHandler;
});
// Export metrics from all HTTP clients registered in services
builder.Services.UseHttpClientMetrics();

serviceCollectionSlimFaas.AddSingleton<IMasterService, MasterSlimDataService>();

Expand Down Expand Up @@ -252,6 +254,7 @@
serverOptions.ListenAnyIP(uri.Port);
foreach (int slimFaasPort in slimFaasPorts)
{
Console.WriteLine($"Slimfaas listening on port {slimFaasPort}");
serverOptions.ListenAnyIP(slimFaasPort, listenOptions =>
{
listenOptions.Protocols = HttpProtocols.Http1AndHttp2;
Expand Down Expand Up @@ -295,12 +298,24 @@
{
await context.Response.WriteAsync("OK");
}
else
{
await next.Invoke();
}
});

startup.Configure(app);
app.UseRouting();

app.UseHttpMetrics(options =>
{
// This will preserve only the first digit of the status code.
// For example: 200, 201, 203 -> 2xx
options.ReduceStatusCodeCardinality();
});
app.UseMetricServer();
app.UseHttpMetrics();

startup.Configure(app);


app.Run(async context =>
{
Expand Down
7 changes: 4 additions & 3 deletions src/SlimFaas/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
"ASPNETCORE_ENVIRONMENT": "Development",
"NAMESPACE": "slimfaas-demo",
"HOSTNAME": "slimfaas-1",
"MOCK_KUBERNETES_FUNCTIONS": "{\"Functions\":[{\"Name\":\"fibonacci1\",\"NumberParallelRequest\":1},{\"Name\":\"fibonacci2\",\"NumberParallelRequest\":1}]}",
"MOCK_KUBERNETES_FUNCTIONS": "{\"Functions\":[{\"Name\":\"fibonacci1\",\"NumberParallelRequest\":1},{\"Name\":\"fibonacci2\",\"NumberParallelRequest\":1}],\"Slimfaas\":[{\"Name\":\"slimfaas-1\"}]}",
"SLIMFAAS_PORT": "5002",
"SLIMDATA_DIRECTORY": "C:\\Demo4",
"BASE_SLIMDATA_URL": "http://localhost:3262/"
"BASE_SLIMDATA_URL": "http://localhost:3262/",
"SLIMDATA_CONFIGURATION": "{\"coldStart\":\"true\"}"
}
},
"http_2": {
Expand All @@ -24,7 +25,7 @@
"ASPNETCORE_ENVIRONMENT": "Development",
"NAMESPACE": "slimfaas-demo",
"HOSTNAME": "slimfaas-2",
"MOCK_KUBERNETES_FUNCTIONS": "{\"Functions\":[{\"Name\":\"fibonacci1\",\"NumberParallelRequest\":1},{\"Name\":\"fibonacci2\",\"NumberParallelRequest\":1}]}",
"MOCK_KUBERNETES_FUNCTIONS": "{\"Functions\":[{\"Name\":\"fibonacci1\",\"NumberParallelRequest\":1},{\"Name\":\"fibonacci2\",\"NumberParallelRequest\":1}],\"Slimfaas\":[{\"Name\":\"slimfaas-1\"}]}",
"SLIMFAAS_PORT": "5001",
"SLIMDATA_DIRECTORY": "C:\\Demo4",
"BASE_SLIMDATA_URL": "http://localhost:3263/"
Expand Down

0 comments on commit f1f05f3

Please sign in to comment.