# Oracle Functions LoadBalancer ## Loadbalancing several Oracle Functions You can run multiple Oracle Functions instances and balance the load amongst them using `fnlb` as follows: ```sh fnlb --listen --nodes ,, ``` And redirect all traffic to the load balancer. **NOTE: For the load balancer to be of use, all function nodes need to be sharing the same DB.** ## Running with docker To build a docker image for `fnlb` just run (in `fnlb/`): ``` make docker-build ``` To start the `fnlb` proxy with the addresses of functions nodes in a docker container: ```sh docker run -d --name fnlb -p 8081:8081 funcy/fnlb:latest --nodes , ``` If running locally with functions servers in docker, running with docker links can make things easier (can use local addresses). for example: ```sh docker run -d --name fn-8080 --privileged -p 8080:8080 funcy/functions:latest docker run -d --name fnlb --link fn-8080 -p 8081:8081 funcy/fnlb:latest --nodes 127.0.0.1:8080 ``` ## Operating / usage To make functions requests against the lb with the cli: ```sh API_URL=http:// fn call my/function ``` To add a functions node later: ```sh curl -sSL -X PUT -d '{"node":""}' /1/lb/nodes ``` `` should be the address of a functions server. The lb will health check this and log if it cannot reach that node as well as stop sending requests to that node until it begins passing health checks again. Any number of functions servers may be added to the load balancer. To permanently remove a functions node: ```sh curl -sSL -X DELETE -d '{"node":""}' /1/lb/nodes ``` To list functions nodes and their state: ```sh curl -sSL -X GET /1/lb/nodes ```