-
-
Notifications
You must be signed in to change notification settings - Fork 15
Description
In some circumstances, initializing time for a lambda could be quite large. it would be great to be able to configure some lambdas with a configurable number of pre-provisionned processes.
Once a lambda is pre-provisionned, it is started unconditionally in a pool. The lambda can then initialize all it wants and once initialized will stop waiting on I/O (stdin and stdout). Upon invocation, one lambda from the pool would be used and the standard input will be written to and standard output will be read to, motioning the lambda forward. Once a lambda from the pool is taken, a new lambda would be started to refill the pool.
edit: This is incompatible with MethodEnv, PathEnv, InputHeaders and Query.
Implementation could be:
- in lambda interface add
Start()andStop()functions that notifies when the lambda is made available and the lambda is destroyed. Start()should probably be called intrusted-cgi/application/platform/platform.go
Line 211 in c76c262
func (platform *platform) setupLambda(lambda application.Lambda) error { Stop()should be probably called fromtrusted-cgi/application/platform/platform.go
Line 180 in c76c262
func (platform *platform) Remove(uid string) { Start()should run a specialized invoke function where stdin and stdout are pipes. The other end of pipes should be stored in a pool data structure as well as a context cancel function (for lambda timeout)Invoke()should either take a running lambda from the pool and connect the pipes (io.Copy for that), ensure the cancel function is called at the timeout event, or if there is nothing on the pool, should invoke a new lambda instanceStop()should cancel all running lambda instances in the pool- When updating the lambda manifest
SetManifest()andreloadManifest()the pool should be adjusted