lb

package
v0.0.0-...-d59d7d1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2018 License: Apache-2.0 Imports: 12 Imported by: 7

README

IronFunctions LoadBalancer

Loadbalancing several IronFunctions

You can run multiple IronFunctions instances and balance the load amongst them using fnlb as follows:

fnlb --listen <address-for-incoming> --nodes <node1>,<node2>,<node3>

And redirect all traffic to the load balancer.

NOTE: For the load balancer to work all function nodes need to be sharing the same DB.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoFallbackNodeFound = errors.New("no fallback node found - whole cluster seems offline")

ErrNoFallbackNodeFound happens when the fallback routine does not manage to find a TCP reachable node in alternative to the chosen one.

Functions

func ConsistentHashReverseProxy

func ConsistentHashReverseProxy(ctx context.Context, nodes []string) *httputil.ReverseProxy

ConsistentHashReverseProxy returns a new ReverseProxy that routes URLs to the scheme, host, and base path provided in by a consistent hash algorithm. If the target's path is "/base" and the incoming request was for "/dir", the target request will be for /base/dir. ConsistentHashReverseProxy does not rewrite the Host header.

Types

type FallbackRoundTripper

type FallbackRoundTripper struct {
	// contains filtered or unexported fields
}

FallbackRoundTripper implements http.RoundTripper in a way that when an outgoing request does not manage to succeed with its original target host, it fallsback to a list of alternative hosts. Internally it keeps a list of dead hosts, and pings them until they are back online, diverting traffic back to them. This is meant to be used by ConsistentHashReverseProxy().

func NewRoundTripper

func NewRoundTripper(ctx context.Context, nodes []string) *FallbackRoundTripper

NewRoundTripper creates a new FallbackRoundTripper and triggers the internal host TCP health checks.

func (*FallbackRoundTripper) RoundTrip

func (f *FallbackRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTrip. It tried to fullfil an *http.Request to its original target host, falling back to a list of nodes in case of failure. After the first failure, it consistently delivers traffic to the fallback host, until original host is back online. If no fallback node is available, it fails with ErrNoFallbackNodeFound. In case of cascaded failure, that is, the fallback node is also offline, it will look for another online host.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL