openfaas / faas

OpenFaaS - Serverless Functions Made Simple
https://www.openfaas.com
MIT License
25.01k stars 1.93k forks source link

Feature: Add min/max scale for auto-scaling - Swarm & external providers #414

Closed alexellis closed 6 years ago

alexellis commented 6 years ago

Should be able to set a minimum scale for functions as well as the maximum (existing)

We can configure this through labels on the Docker Swarm service.

  labels:
    "com.openfaas.scale.min": "5"
    "com.openfaas.scale.max": "15"

Labels are generic so this would need faas-netes to expose some new data for the /system/function/ call too.

This will be useful for functions which are known to need to have high availability or traffic.

Implementation on Swarm:

cc @stefanprodan @ericstoekl

Initial work: https://github.com/openfaas/faas/compare/scale_with_min_values?expand=1

stefanprodan commented 6 years ago

Tested on Kubernetes with the following stack:

functions:
  nodeinfo:
    handler: node main.js
    image: functions/nodeinfo:burner
    labels:
      com.openfaas.scale.min: "5"
      com.openfaas.scale.max: "15"

It got up to 15 PODs during the load test and down to 5 after that:

screen shot 2017-11-30 at 00 14 48
alexellis commented 6 years ago

Thank you for helping to test this on Kubernetes Stefan.

That result sounds like what we want. When the settings are not present does it fallback to the old behavior?

stefanprodan commented 6 years ago

With no com.openfaas.scale.min label it goes back to one pod.

alexellis commented 6 years ago

Derek add label: enhancement

austinfrey commented 6 years ago

Is this closeable with the merge of #419?

alexellis commented 6 years ago

Derek close

alexellis commented 6 years ago

Yes thanks for helping out

YasminBZ commented 6 years ago

Hello please how i can autoscale my faas fucntion ??

YasminBZ commented 6 years ago

which command i use for example to fix the number of replica depend on the CPU usage or the number of requests ??

alexellis commented 6 years ago

@white-cloud this thread is closed - please open a new issue if you'd like support.

alexellis commented 6 years ago

Derek lock: feature completed