MicroStrategy ONE

Load Balancer and Clustering for Library: Example Setup Workflow

Install and Configure Redis Server

  1. To install Redis, see Getting started with Redis.
  2. Run Redis Server.
  3. Check if Redis is working properly by sending a 'PING' command in redis-cli.

    A 'PONG' will be responded if Redis Server is good.

    Copy
    127.0.0.1:6379> ping
    PONG
    127.0.0.1:6379>

    Collaboration servers require a URL to connect to the running Redis Server for horizontal clustering purpose.

    Example: redis://redis_host_machine:6379

    Modify the Redis configuration file so it can accept external traffic.

    • In Redis configuration file (redis.conf or redis.windows-service.conf), add/change the bind entry to bind 0.0.0.0
    • Save modification and restart Redis Server

Configure Collaboration Server

  1. For all the Collaboration servers installed in different machines, set Redis Server URL, web load balancer URL, clustering mode in the configuration files:

    Copy
    {
    "port": 3000,
    "dataSource": {"username": "mstr_collab","password": "xxx"},
    "logging": true,
    "authorizationServerUrl":"<web_load_balancer_url>/api",
    "scaling": "horizontal","redisServerUrl": 
    "<redis_server_url>",
    .......
    }
  2. Save configuration files and restart Collaboration servers.
  3. Make sure all the Collaboration servers are running properly by visiting their individual /status URL. It will tell the actual state of the Collaboration server instance. For example, the Collaboration server below is actually paused due to unreachable Postgres and Redis servers.

    Copy
    {
    "version":"11.0.0.720",
    "enableTls":false,
    "scaling":"horizontal",
    "logging":true,
    "state":"paused",
    "reason":"The following dependent services are unavailable: DB Service, Redis Server",
    "main":
    {
    "cpu":{"current":0,"max":17},
    "memory":{"current":62758912,"max":85626880},
    "connections":{"total":12,"current":4,"max":11},
    "messages":{"processed":5},
    "restCalls":{"received":3},
    "up_since":"2018-4-18 02:12:42","pid":900
    }
    }

Configure Web Load Balancer Server

The load balancer must utilize "sticky sessions" to ensure that clients are directed to the instance which established the initial session. It should also support the Web Socket protocol (wss:), which relies on the HTTP 1.1 Upgrade protocol.

For example, following is the configuration for Horizontally clustered Collaboration servers, when using NGINX as web load balancer.

Copy
......

http {
    ......

    upstream collabServer {
    ip_hash;             # this is a must, ensures that we are sticky to the IP to enable a correct socket.io handshake
    server collabServer1:3000;    # provide the list of the Collaboration servers from here
    server collabServer2:3000;
    server collabServer3:3000;
    }
    
    location /socket.io/ {                    # API Pattern for socket.io handshake
        proxy_http_version 1.1;                # Required for proper HTTP upgrade protocol
        proxy_set_header Upgrade $http_upgrade;     # This is a Hop-by-Hop header–must pass through manually
        proxy_set_header Connection "upgrade";      # Another hop-by-hop header
        proxy_pass http://collabServer/socket.io/;      # Directs the request to a server in upstream "collabServer"
    }

    location /status {                    # forward the /status API to one server from the CollabServer list
        proxy_pass http://collabServer/status;
    }

    ......

}

......