Galeb is an open source Router as a Service software.
View Source

Features

Balance Methods

Use different methods to balancing your traffic like consistent-hash, leastconn and round-robin. Set this just with a configuration into API Rest.

/URI

Routing traffic by URI

Route specific parts of your website using URI rules. For example, you can route "/path" to different servers of main page.

WebSockets

The protocol makes more interaction between a browser and a website possible, facilitating live content and the creation of real-time games.

API

Dynamic Configuration

You can modify the configuration any time. There is no need to restart or to signal that the configuration has changed.

Metrics

Collect metrics like request status code, active connections and request time. Send to statsd and use this to improve your services.

Healthcheck

If a backend stops responding, it will be flagged as dead and will activate the healthcheck manager to bring to life when respond.

Micro Services

Using this architecture we have the facility to update and scale each service and also improves fault isolation.

HTTP/2 Ready

Enables a more efficient use of network resources and allowing multiple concurrent exchanges on the same connection.

Getting Started

The following instructions may help you get started with galeb in a standalone environment.

External Dependencies

  • Java 8 should be installed and in the PATH

1. Installation

From the shell:

$ git clone --recursive https://github.com/globocom/galeb
$ cd galeb
$ mvn clean install

2. Using Router

From the shell:

$ cd galeb-router && \
mvn exec:exec < /dev/null > /dev/null 2>&1 &

3. Using API (Router)

From the shell:

$ cd galeb-api && \
mvn exec:exec < /dev/null > /dev/null 2>&1 &

4. Using HealthChecherk

From the shell:

$ cd galeb-healthchecker && \
mvn exec:exec < /dev/null > /dev/null 2>&1 &

5. Using Metrics

From the shell:

$ cd galeb-metrics && \
mvn exec:exec < /dev/null > /dev/null 2>&1 &

6. Configuring a vhost (API)

When galeb starts, it starts the routemanager too, that is our configuration API. Now you can just send a POST to create new routes. With a GET you can see the initial state of your router.

The format of this message is as follows:

$ curl http://127.0.0.1:9090/farm
{
    virtualHosts: [],
    backendPools: [],
    pk: -1,
    id: "",
    parentId: "",
    createdAt: 0000000000000,
    modifiedAt: 0000000000000,
    properties: {},
    entityType: "farm",
    hash: "0",
    version: 0
}

Now let's take an example, I want to proxify requests to 2 backends for the hostname 'www.galeb.com'. The 2 backends IP are 192.168.0.10 and 192.168.0.20 and they serve the HTTP traffic on the port 80.

Here are the steps I will follow:

6.1. Create the virtualhost and associate an identifier 'www.galeb.io':

$ curl -XPOST http://127.0.0.1:9090/virtualhost -d '
{
    id: "www.galeb.io",
    properties: {},
    version: 1
}'

API will respond always "Accepted" to success because we use EventBus to queue messages

6.2. Create your backend pool.

$ curl -XPOST http://127.0.0.1:9090/backendpool -d '
{
    id: "backendpool_galeb",
    properties: {
        loadBalancePolicy: "LeastConn"
    },
    version: 2
}'

If you want use different balance method use the properties field. Default loadBalancePolicy is RoundRobin but we have Least Conn, IPHash, RoundRobin and Random.

6.3. Associate the 2 backends:

$ curl -XPOST http://127.0.0.1:9090/backend -d '
{
    id: "http://192.168.0.10:80",
    parentId: "backendpool_galeb",
    properties: {},
    version: 3
}'

$ curl -XPOST http://127.0.0.1:9090/backend -d '
{
    id: "http://192.168.0.20:80",
    parentId: "backendpool_galeb",
    properties: {},
    version: 4
}'

6.4. Create your rule to associate virtualhost with backend pool:

$ curl -XPOST http://127.0.0.1:9090/rule -d '
{
    id: "galeb_io_rule_default",
    parentId: "www.galeb.io",
    properties: {
        targetType: "BackendPool",
        ruleType: "UriPath",
        targetId: "backendpool_galeb",
        match: "/"
    },
    version: 5
}'

6.5. Review the configuration:

$ curl http://127.0.0.1:9090/farm
{
    virtualHosts: [
        {
            rules: [
                {
                    pk: -1,
                    id: "galeb_io_rule_default",
                    parentId: "www.galeb.io",
                    createdAt: 0000000000000,
                    modifiedAt: 0000000000000,
                    properties: {
                        targetType: "BackendPool",
                        ruleType: "UriPath",
                        targetId: "backendpool_galeb",
                        match: "/"
                    },
                    entityType: "rule",
                    hash: "0",
                    version: 5
                }
            ],
            pk: -1,
            id: "www.galeb.io",
            parentId: "",
            createdAt: 0000000000000,
            modifiedAt: 0000000000000,
            properties: {

            },
            entityType: "virtualhost",
            hash: "0",
            version: 1
        }
    ],
    backendPools: [
        {
            backends: [
                {
                    health: "HEALTHY",
                    connections: 0,
                    pk: -1,
                    id: "http://192.168.0.10:80",
                    parentId: "backendpool_galeb",
                    createdAt: 0000000000000,
                    modifiedAt: 0000000000000,
                    properties: {

                    },
                    entityType: "backend",
                    hash: "0",
                    version: 3
                },
                {
                    health: "HEALTHY",
                    connections: 0,
                    pk: -1,
                    id: "http://192.168.0.20:80",
                    parentId: "backendpool_galeb",
                    createdAt: 0000000000000,
                    modifiedAt: 0000000000000,
                    properties: {

                    },
                    entityType: "backend",
                    hash: "0",
                    version: 4
                }
            ],
            pk: -1,
            id: "backendpool_galeb",
            parentId: "",
            createdAt: 0000000000000,
            modifiedAt: 0000000000000,
            properties: {
                loadBalancePolicy: "LeastConn"
            },
            entityType: "backendpool",
            hash: "0",
            version: 2
        }
    ],
    pk: -1,
    id: "",
    parentId: "",
    createdAt: 0000000000000,
    modifiedAt: 0000000000000,
    properties: {

    },
    entityType: "farm",
    hash: "0",
    version: 5
}

While the server is running, any of these steps can be re-run without messing up with the traffic.

Our Amazing Team

Meet our great team

fernandocarolo

Fernando Carolo

fredericosap

Frederico Pinto

tuxmonteiro

Marcelo Teixeira Monteiro

igorfernandes

Igor Fernandes Ribeiro

tibgra

Tiago Braga Machado