NATS Multiple Server Setup
This article explains how to setup NATS across multiple servers. The are a number of solutions you can implement to use multiple servers/databases to improve performance and distribute the work load across multiple servers.
Database Server(s)
NATS supports the ability of querying a secondary "slave" database when running any non-essential reports. You can have as many slave databases attached to your master NATS database as you want at no extra charge from us. Using a slave database will greatly improve performance on both your join pages and on your reporting pages, as they will not be fighting for the same database resources when they are both running at the same time.
To use a slave database in NATS, your host must first create the slave database in MySQL and set up replication between the two. Replication is how the master and slave databases keep data up-to-date between each other. MySQL's official documentation on replication can be found here.
(NOTE: NATS Tech Support CANNOT and WILL NOT do this step as it this is something that is set up outside of the NATS system)
Once replication is set up by your host, the next step is to tell NATS how to connect to the primary slave database. Before you start this next step, you need to get the following information from your host:
- The hostname/address of the slave database
- The username for the slave database
- The password for the slave database
- The name of the slave database
Then in your includes/config.php file, add the following lines:
$config['STATS_DB_SERVER'] = 'localhost'; //replace localhost with address/hostname of where slave database lives $config['STATS_DB_USER'] = 'access'; //replace access with the username for slave database $config['STATS_DB_PASSWORD'] = 'my_password'; //replace my_password with the password for slave database $config['STATS_DB_DB'] = 'db_name'; //replace db_name with the name of the slave database
THE FOLLOWING STEP ONLY APPLIES TO USERS OF NATS V4
THE FOLLOWING STEP IS OPTIONAL
If you have multiple slave databases replicating from your master NATS database, you can have NATS automatically choose one of your slave databases at random when a user hits a page/script that uses the slave database(s). You can add an array of slave databases to your includes/config.php file in the following manner:
$config['DB_REPORTING_SERVERS'] = Array( "0" => Array( 'SERVER' => 'localhost', //replace localhost with address of where first slave database lives 'USER' => 'access1', //replace access1 with the username for the first slave database 'PASSWORD' => 'password1', //replace password1 with the password for first slave database 'DB' => 'slave_name1' //replace slave_name1 with the name of the first slave database ), "1" => Array( 'SERVER' => 'localhost', //replace localhost with address of where second slave database lives 'USER' => 'access2', //replace access2 with the username for the second slave database 'PASSWORD' => 'password2', //replace password2 with the password for second slave database 'DB' => 'slave_name2' //replace slave_name2 with the name of the second slave database ) //continue in this manner for as many slave databases you wish to configure );
Load Balancing Web Files
(coming soon...)