Skip to content

Commit

Permalink
Reduce the readiness checks for functions
Browse files Browse the repository at this point in the history
* Significantly improves scale up time for functions (when going
  from 0 -> 1)
* Health check is hit more frequently, but should not noticibly
  impact performance
* Use the httpget probe type and leverage the watchdog /healthz
  endpoint

This could be optimized a little further if new image for doing
the http probes where created which would block on connection errors
and return immediately when the response comes back, but the best
case is < 1s improvement.

Some performance numbers.  Before (there was a timeout error):

cold start: 10.240251064300537
error calling function: Command 'echo -n "Test" | faas-cli -g http://192.168.64.78:31112 invoke hello-python' returned non-zero exit status 1.
cold start: 4.621361255645752
cold start: 5.6364970207214355
cold start: 11.648431777954102
cold start: 8.450724840164185
cold start: 9.854270935058594
cold start: 12.048357009887695
cold start: 12.24026870727539

After:

cold start: 1.8590199947357178
cold start: 1.8544681072235107
cold start: 2.065181016921997
cold start: 1.8414137363433838
cold start: 1.6598482131958008
cold start: 2.4577977657318115
cold start: 2.4510068893432617
cold start: 2.244048833847046
cold start: 2.6444039344787598

Signed-off-by: Berndt Jung <bjung@vmware.com>
  • Loading branch information
berndtj committed Jul 16, 2018
1 parent ad98775 commit c19eefa
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions handlers/deploy.go
Expand Up @@ -9,8 +9,6 @@ import (
"io/ioutil"
"log"
"net/http"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -118,16 +116,19 @@ func MakeDeployHandler(functionNamespace string, clientset *kubernetes.Clientset

func makeDeploymentSpec(request requests.CreateFunctionRequest, existingSecrets map[string]*apiv1.Secret, config *DeployHandlerConfig) (*v1beta1.Deployment, error) {
envVars := buildEnvVars(&request)
path := filepath.Join(os.TempDir(), ".lock")
probe := &apiv1.Probe{
Handler: apiv1.Handler{
Exec: &apiv1.ExecAction{
Command: []string{"cat", path},
HTTPGet: &apiv1.HTTPGetAction{
Path: "/healthz",
Port: intstr.IntOrString{
Type: intstr.Int,
IntVal: int32(watchdogPort),
},
},
},
InitialDelaySeconds: 3,
InitialDelaySeconds: 0,
TimeoutSeconds: 1,
PeriodSeconds: 10,
PeriodSeconds: 1,
SuccessThreshold: 1,
FailureThreshold: 3,
}
Expand Down

0 comments on commit c19eefa

Please sign in to comment.