.. _multi_data_center_deployments:

Multi Data Center Deployments
-----------------------------

.. index:: web;web weight
.. index:: web;web weight list
.. index:: web;web weight add

Multinode clusters can be deployed in both Active/Active or Active/Standby configurations.
Active/Active configurations have all the Unified nodes enabled for transaction processing.
Active/Standby configurations have only the Unified nodes in the primary data center 
(the data center containing the Unified node with the primary database) enabled for
transaction processing.

In order to run an Active/Active configuration, the latency (RTT) between data centers 
must not exceed 20ms. For higher latencies an Active/Standby configuration must be used.

To switch to an Active/Standby configuration, do the following on all Unified nodes
in the secondary data center (the data center *not* containing the Unified node with
the primary database):

1. log into platform: 

   **ssh platform@<ip_address>**
   
#. set the worker count on the nodes in the secondary data center to zero:

   **voss workers 0**

   Setting the number of workers is persistent; in other words, this setting
   will still apply after upgrades and system restart.


For an Active/Standby configuration, the proxy server web weights
should be set to the Unified nodes on the primary data center.
This is done with the **web weight add** command.

The web weight specifies the routing and relative counts of the initial
HTTP request from the Web Proxy to a Unified Node. The
initial request could be a request such as a transaction,
or for example a GET request. Consider web weights configuration
as shown below:

::

   172.0.0.158:443: 1
   172.0.0.159:443: 1
   172.0.0.161:443: 1
   172.0.0.162:443: 1
   173.0.0.163:443: 0
   173.0.0.164:443: 0

This configuration means that the servers 
``173.0.0.163`` and ``173.0.0.164``
serve as backup servers and requests are only
routed to these if the other servers are not available.
While the other servers are available, an equal number
of requests are routed to them in a round-robin manner.
Refer to the Best Practices Guide for more details
on deployment models and web weight settings.

Consider an example where:

.. note::

   The examples below show system command output where
   the Phone Based Registration application is running.

1. Primary data center has unified nodes
   with IP addresses and ports:

   * 172.0.0.158:443
   * 172.0.0.159:443
   * 172.0.0.161:443
   * 172.0.0.162:443

  A *unified node* typically shows the following output
  for the **web weight list** command:

  ::
  
     $ web weight list
     Default service weights

      voss-deviceapi:
          phoneservices:
              172.0.0.158:8412: 1
          selfservice:
              172.0.0.158:5000: 1
          voss-deviceapi:
              172.0.0.158:9902: 1
          voss-portal:
              172.0.0.158:6001: 1
  

2. Secondary data center has unified nodes
   with IP addresses and ports:

   * 173.0.0.163:443
   * 173.0.0.164:443


The defaults of the **web weight list** command
run on the *proxy servers* is as below:

1. Primary data center proxy server:

::

   $ web weight list
   Default service weights

       phonebasedreg: 
           phoneservices:
               172.0.0.158:443: 1
               172.0.0.159:443: 1
               172.0.0.161:443: 1
               172.0.0.162:443: 1
               173.0.0.163:443: 0
               173.0.0.164:443: 0
       voss-deviceapi: 
           selfservice: 
               172.0.0.158:443: 1
               172.0.0.159:443: 1
               172.0.0.161:443: 1
               172.0.0.162:443: 1
               173.0.0.163:443: 0
               173.0.0.164:443: 0
           voss-deviceapi: 
               172.0.0.158:443: 1
               172.0.0.159:443: 1
               172.0.0.161:443: 1
               172.0.0.162:443: 1
               173.0.0.163:443: 0
               173.0.0.164:443: 0



2. Secondary data center proxy server:

::

   $ web weight list
   Default service weights

       phonebasedreg: 
           phoneservices:
               172.0.0.158:443: 0
               172.0.0.159:443: 0
               172.0.0.161:443: 0
               172.0.0.162:443: 0
               173.0.0.163:443: 1
               173.0.0.164:443: 1
       voss-deviceapi: 
           selfservice: 
               172.0.0.158:443: 0
               172.0.0.159:443: 0
               172.0.0.161:443: 0
               172.0.0.162:443: 0
               173.0.0.163:443: 1
               173.0.0.164:443: 1
           voss-deviceapi: 
               172.0.0.158:443: 0
               172.0.0.159:443: 0
               172.0.0.161:443: 0
               172.0.0.162:443: 0
               173.0.0.163:443: 1
               173.0.0.164:443: 1


In order to ensure that the secondary data center 
is configured for a Standby mode, 
change the web weights to show ``userweights``
as seen in the output on the *secondary* data center
proxy server below:

::

   $ web weight list
   Default service weights

       phonebasedreg: 
           phoneservices:
               172.0.0.158:443: 0
               172.0.0.159:443: 0
               172.0.0.161:443: 0
               172.0.0.162:443: 0
               173.0.0.163:443: 1
               173.0.0.164:443: 1
       voss-deviceapi: 
           selfservice: 
               172.0.0.158:443: 0
               172.0.0.159:443: 0
               172.0.0.161:443: 0
               172.0.0.162:443: 0
               173.0.0.163:443: 1
               173.0.0.164:443: 1
           voss-deviceapi: 
               172.0.0.158:443: 0
               172.0.0.159:443: 0
               172.0.0.161:443: 0
               172.0.0.162:443: 0
               173.0.0.163:443: 1
               173.0.0.164:443: 1

   Customized service weights
       userweights: 
           172.0.0.158:443: 1
           172.0.0.159:443: 1
           172.0.0.161:443: 1
           172.0.0.162:443: 1
           173.0.0.163:443: 0
           173.0.0.164:443: 0

As can be seen, the load balancing web weights have been
changed to the unified nodes on the 
*primary* data center.