Documentation
¶
Overview ¶
Package functions implements core logic for active monitoring, load balancing, and auto-scaling of back-end services.
Package functions implements core logic for active monitoring, load balancing, and auto-scaling of back-end services.
Package functions implements core logic for active monitoring, load balancing, and auto-scaling of back-end services.
Package functions implements core logic for active monitoring, load balancing, and auto-scaling of back-end services.
Package functions implements core logic for active monitoring, load balancing, and auto-scaling of back-end services.
Index ¶
- func AMLB()
- func AutoScaler()
- func CallContainers()
- func CloseReplicas(containerID string) (string, error)
- func CreateReplicas(imageName string, containerPort string, networkName string) (*structers.Backend, error)
- func GetInfoAboutReplica(containerID string) (*structers.ReplicaStats, error)
- func NextAPISuffix(cli *client.Client, ctx context.Context, serviceName, parentName string) (int, error)
- func ProxyHandler() http.HandlerFunc
- func ScaleDown()
- func ScaleUp()
- func StartHealthChecker()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AMLB ¶
func AMLB()
Active Monitoring Load Balancer (AMLB) periodically monitors the containers and decides whether to scale up or down based on CPU and memory usage. It enforces the minimum and maximum replica counts and performs a single scaling action at a time. The check is done every ScaleInterval (default is 15s).
func AutoScaler ¶
func AutoScaler()
AutoScaler periodically checks the request volume and adjusts the number of replicas according to the configured thresholds. If the request count is greater than the scale up threshold and there are less than the maximum number of replicas, it starts a new replica. If the request count is less than the scale down threshold and there are more than the minimum number of replicas, it removes one replica. The check is done every ScaleInterval (default is 15s).
func CallContainers ¶
func CallContainers()
CallContainers loads the containers of the returned project by loadComposeFile. it creates one set of db, and n sets of the api.
func CloseReplicas ¶
CloseReplicas closes the replica with the given id, it first stop the container and then shut it down
func CreateReplicas ¶
func CreateReplicas(imageName string, containerPort string, networkName string) (*structers.Backend, error)
CreateReplicas spins up one new container instance of your API, listening on the given hostPort, and returns a Backend pointing to it.
func GetInfoAboutReplica ¶
func GetInfoAboutReplica(containerID string) (*structers.ReplicaStats, error)
gets the cpu and memory of a given container id
func NextAPISuffix ¶
func NextAPISuffix(cli *client.Client, ctx context.Context, serviceName, parentName string) (int, error)
NextAPISuffix it extract the name of the container, and gets the number of the last created one. Note: it needs the container to follow this formate <parentName>-<N> (Docker compose/ microservice)
func ProxyHandler ¶
func ProxyHandler() http.HandlerFunc
ProxyHandler it handles the traffic and direct it to the selected backend from pickBackendAndIncrement and passes the request to it
func ScaleDown ¶
func ScaleDown()
ScaleDown tears down the newest container—never going below MinReplicas.
func StartHealthChecker ¶
func StartHealthChecker()
Types ¶
This section is empty.