Read config values from environment for max_conns tuning

- max_conns / idle / per host are now read from env-vars and have
defaults set to 1024 for both values
- logging / metrics are collected in the client transaction
rather than via defer (this may impact throughput)
- function cache moved to use RWMutex to try to improve latency
around locking when updating cache
- logging message added to show latency in running GetReplicas
because this was observed to increase in a linear fashion under
high concurrency
- changes tested against 3-node bare-metal 1.13 K8s cluster
with kubeadm

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (VMware)
2019-01-22 15:59:32 +00:00
committed by Alex Ellis
parent 52c27e227a
commit 299e5a5933
7 changed files with 98 additions and 22 deletions

View File

@ -6,6 +6,8 @@ package plugin
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net"
"net/http"
@ -13,10 +15,6 @@ import (
"strconv"
"time"
"fmt"
"io/ioutil"
"github.com/openfaas/faas-provider/auth"
"github.com/openfaas/faas/gateway/requests"
"github.com/openfaas/faas/gateway/scaling"
@ -62,6 +60,8 @@ type ScaleServiceRequest struct {
// GetReplicas replica count for function
func (s ExternalServiceQuery) GetReplicas(serviceName string) (scaling.ServiceQueryResponse, error) {
start := time.Now()
var err error
var emptyServiceQueryResponse scaling.ServiceQueryResponse
@ -92,6 +92,7 @@ func (s ExternalServiceQuery) GetReplicas(serviceName string) (scaling.ServiceQu
log.Println(urlPath, err)
}
} else {
log.Printf("GetReplicas took: %fs", time.Since(start).Seconds())
return emptyServiceQueryResponse, fmt.Errorf("server returned non-200 status code (%d) for function, %s", res.StatusCode, serviceName)
}
}
@ -115,6 +116,8 @@ func (s ExternalServiceQuery) GetReplicas(serviceName string) (scaling.ServiceQu
}
}
log.Printf("GetReplicas took: %fs", time.Since(start).Seconds())
return scaling.ServiceQueryResponse{
Replicas: function.Replicas,
MaxReplicas: maxReplicas,