Skip to content

Allow to pre-provision lambdas #30

@mildred

Description

@mildred

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() and Stop() functions that notifies when the lambda is made available and the lambda is destroyed.
  • Start() should probably be called in
    func (platform *platform) setupLambda(lambda application.Lambda) error {
  • Stop() should be probably called from
    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 instance
  • Stop() should cancel all running lambda instances in the pool
  • When updating the lambda manifest SetManifest() and reloadManifest() the pool should be adjusted

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions