OpenFaaS Lab 5

Autoscaling your function

Posted by Krystian Wojcicki on Monday, July 29, 2019 Tags: Guide   1 minute read

Lab 5

  • Scaling

To show off the scaling we will a very simple echo function

git clone https://github.com/alexellis/echo-fn \
 && cd echo-fn \
 && faas-cli template store pull golang-http \
 && faas-cli deploy \
  --label com.openfaas.scale.max=10 \
  --label com.openfaas.scale.min=1 --gateway $ip:31112

As one can see the minimum number of function replicas will be 1, while the maximum is 10.

The scaling is handled by OpenFaas based on Prometheus R.E.D (requests, errors, duration) metrics. By default uses rps as its scaling metric but is is completely configurable.

Now head over to the UI to confirm there is only 1 replica up and running.

Run the following snippet and watch the replicas go up and then back down

for i in {0..10000};
do
   echo -n "Post $i" | faas-cli invoke go-echo --gateway $ip:31112 && echo;
done;

scaling