Fix creation of redundant pods on heavy load cold start (#232)

Modifies function specialization so that concurrent requests for the same function cause only one pod to be created.
This commit is contained in:
yang qf
2017-06-19 18:56:38 -07:00
committed by Soam Vasani
parent 3328014ee6
commit ce4d3ac42d
3 changed files with 96 additions and 17 deletions
+2 -3
View File
@@ -438,7 +438,7 @@ func (gp *GenericPool) GetFuncSvc(m *fission.Metadata) (*funcSvc, error) {
if gp.useSvc {
svcName := fmt.Sprintf("svc-%v", m.Name)
if len(m.Uid) > 0 {
svcName += ("-" + m.Uid)
svcName += "-" + m.Uid
}
labels := gp.labelsForFunction(m)
@@ -472,8 +472,7 @@ func (gp *GenericPool) GetFuncSvc(m *fission.Metadata) (*funcSvc, error) {
err, existingFsvc := gp.fsCache.Add(*fsvc)
if err != nil {
// Some other thread beat us to it -- return the other thread's fsvc and clean up
// our own. TODO: this is grossly inefficient, improve it with some sort of state
// machine
// our own.
log.Printf("func svc already exists: %v", existingFsvc.podName)
go func() {
gp.kubernetesClient.Core().Pods(gp.namespace).Delete(fsvc.podName, nil)