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
+5 -2
View File
@@ -45,9 +45,12 @@ func (fmap *functionServiceMap) lookup(f *fission.Metadata) (*url.URL, error) {
}
func (fmap *functionServiceMap) assign(f *fission.Metadata, serviceUrl *url.URL) {
err, _ := fmap.cache.Set(*f, serviceUrl)
err, old := fmap.cache.Set(*f, serviceUrl)
if err != nil {
log.Printf("error caching service url for function: %v", err)
if *serviceUrl == *(old.(*url.URL)) {
return
}
log.Printf("error caching service url for function with a different value: %v", err)
// ignore error
}
}