Set up load balancing
With load balancing, a forwarder distributes data across several receiving instances. Each receiver gets a portion of the total data, and together the receivers hold all the data. To access the full set of forwarded data, you need to set up distributed searching across all the receivers. See About distributed search in Distributed Search.
Load balancing enables horizontal scaling for improved performance. In addition, its automatic switchover capability ensures resiliency in the face of machine outages. If a host goes down, the forwarder sends data to the next available receiver.
Load balancing can also be of use when you get data from network devices like routers. To handle syslog and other data generated across TCP port 514, a single universal forwarder can monitor port 514 and distribute the incoming data across several indexers.
Note: You should not use an external load balancer to implement load balancing between forwarders and receivers. This practice does not generate the results you would expect. Use the load balancing capability that comes with the forwarder.
How load balancing works
Forwarders perform automatic load balancing. The forwarder routes data to different indexers on a specified time or volume interval that you can specify. For example, if you have a load-balanced group that consists of indexer A, B, and C, at a specified interval, the forwarder switches the data stream to another indexer in the group at random. The forwarder might switch from indexer B to indexer A to indexer C, and so on. If one indexer is down, the forwarder immediately switches to another.
There is a data stream for each of the inputs that the forwarder monitors. The forwarder determines if it is safe for a data stream to switch to another indexer. Then, at the specified interval, it switches the data stream to the newly selected indexer. If it cannot switch the data stream to the new indexer safely, it keeps the connection to the previous indexer open and continues to send the data stream until it has been safely sent.
Universal forwarders cannot switch indexers when they monitor TCP network streams of data unless the forwarder encounters an end-of-file (EOF) or the receiving indexer goes down. At that point, the forwarder switches to the next indexer in the list. Because the universal forwarder does not parse data and identify event boundaries before forwarding the data to the indexer (unlike a heavy forwarder), it does not know when it is safe to switch to the next indexer unless it receives an EOF.
The following diagram shows a typical load-balancing scenario, in which three forwarders are sending load-balanced data across a set of two receiving indexers:
Options for configuring receiving targets for load balancing
Specify static or DNS lists for receiving indexers
When you configure a set of target receivers for load balancing, you can choose either DNS or static lists.
DNS lists provide greater flexibility and allow for simplified scaling, particularly for large deployments. Through DNS, you can change the set of receivers without needing to re-edit each forwarder outputs.conf
file.
Static lists let you specify a different port for each receiver. This is useful if you need to perform load balancing across multiple receivers that run on a single host, as each receiver can listen on a separate network port.
Choose a load balancing method
You can choose how you want the forwarders to load balance between the indexers in a load balancing list.
- By time. The default method for load balancing is how frequently the forwarders change indexers in the load balanced list. The
autoLBFrequency
setting in outputs.conf controls how often forwarders switch between indexers. The default frequency is every 30 seconds, but you can set it higher or lower.
- By volume. Another option is to set how much data a forwarder sends to an indexer before it switches between indexers in a load-balanced list. The
autoLBVolume
setting inoutputs.conf
controls the amount of data that a forwarder sends to a receiving indexer before it changes to another one. By default, this setting is not active (0 bytes.) If you set it to anything other than 0, then the forwarder will change indexers based on the amount of data that it has sent.
If you enable both settings, then the forwarder chooses an indexer based on the following logic:
- If the forwarder has sent more than
autoLBVolume
bytes of data to an indexer, it changes indexers regardless of whether or notautoLBFrequency
have passed since the last change to a receiving indexer. - If the forwarder has not sent more than
autoLBVolume
bytes of data beforeautoLBFrequency
seconds have elapsed, then it changes indexers after that time has passed.
Specify a static list target
- On a forwarder that you want to set a static list target, edit
$SPLUNK_HOME/etc/system/local/outputs.conf
. You might have to create this file beforehand. - In the
outputs.conf
file, specify each of the receivers in the target group[tcpout]
stanza. - Save the
outputs.conf
file. - Restart the forwarder. The forwarder sends data to the static list targets.
Examples of a static load-balancing configuration file
In the following example, the target group consists of three receivers, specified by IP address and receiving port number. The universal forwarder balances load between the three receivers. If one receiver goes down, the forwarder switches to another one on the list.
[tcpout: my_LB_indexers] server=10.10.10.1:9997,10.10.10.2:9996,10.10.10.3:9995
In the following example, the target group consists of four receivers, specified by IP address and receiving port number. The universal forwarder has been configured to send a specific amount of data (in this case, 1MB) to a receiver before it switches to another receiver in the list.
[tcpout: my_LB_indexers] server=10.10.10.1:9997,10.10.10.2:9996,10.10.10.3:9995,10.10.10.4:9994 autoLBVolume=1048576
In the following example, the target group consists of three receivers. one with a DNS hostname and two with IP addresses. The universal forwarder has been configured to send data to one indexer for 3 minutes (180 seconds) before switching to another receiver.
[tcpout:My_LB_Indexers] server=192.168.1.15:9997,192.168.1.179:9997,server1.mktg.example.com:9997 autoLBFrequency=180
Specify a DNS list target
- On a forwarder that you want to set a DNS list target, edit
$SPLUNK_HOME/etc/system/local/outputs.conf
. You might have to create this file beforehand. - In the
outputs.conf
file, specify a single host in the target group[tcpout]
stanza. - Save the
outputs.conf
file. - Restart the forwarder. The forwarder sends data to the DNS list targets.
- On your DNS server, create a DNS A record for each host IP address, referencing the server name you specified in
outputs.conf.
.splunkreceiver.mycompany.com A 10.10.10.1 splunkreceiver.mycompany.com A 10.10.10.2 splunkreceiver.mycompany.com A 10.10.10.3
- Reload the updated configuration on your DNS server. It might take a while for DNS changes to take effect, depending on the size of your network topology.
Examples of a DNS-based load-balancing configuration file
In the following example, the forwarder has been configured to send data to what appears to be a single host. The changes you made in DNS now have this hostname refer to three different IP addresses.
[tcpout:my_LB_indexers] server=splunkreceiver.mycompany.com:9997
The forwarder uses the DNS list to load balance, sending data in intervals, switching among the receivers specified. If a receiver is not available, the forwarder skips it and sends data to another one on the list.
If you have a topology with many forwarders, the DNS list method lets you update the set of receivers by making changes on the DNS server, without having to edit outputs.conf
.
Configure universal forwarder load balancing for horizontal scaling
When you configure load balancing for horizontal scaling, you should first determine your needs, particularly your horizontal scaling and whether or not you need failover. This helps you develop a topology based on those needs, which can include multiple forwarders as well as receivers and a search head to search across the receivers.
Set up DNS-based load balancing
This procedure assumes a topology of three universal forwarders and three receivers, and uses a DNS list to designate the receivers. For DNS-based load balancing to work, you must configure all receivers to listen on the same network port.
For more information on how to install universal forwarders, see Install the universal forwarder software in the Universal Forwarder manual.
- Configure three machines to communicate on the network. This example uses the IP addresses
10.10.10.1
,10.10.10.2
, and10.10.10.3
, but you can use addresses that are valid for your network. - Install a set of three Splunk Enterprise instances as receivers.
- Configure receiving on the receivers. Specify the same receiving port. For example:
./splunk enable listen 9997 -auth <username>:<password>
- Install a set of universal forwarders.
- On your DNS server, set up a DNS list with an A record for each receiver IP address.
splunkreceiver.mycompany.com A 10.10.10.1 splunkreceiver.mycompany.com A 10.10.10.2 splunkreceiver.mycompany.com A 10.10.10.3
- Reload the updated configuration on your DNS server. It might take a while for DNS changes to take effect, depending on the size of your network topology.
- Create an
outputs.conf
file for all the forwarders to use. This example specifies the DNS server name used in the DNS list and the port the receivers are listening on.[tcpout] defaultGroup=my_LB_indexers [tcpout:my_LB_indexers] disabled=false autoLBFrequency=40 server=splunkreceiver.mycompany.com:9997
This
outputs.conf
file uses theautoLBFrequency
attribute to set a load-balance frequency of 40 seconds. Every 40 seconds, the forwarders switch to another receiver. The default frequency is 30 seconds. - Distribute the
outputs.conf
file to all the forwarders. You can use the deployment server to handle the distribution.
Specify load balancing from the CLI
You can also use the CLI to specify load balancing. You do this when you start forwarding activity to a set of receivers, using this syntax:
./splunk add forward-server <host>:<port> -method autobalance
where <host>:<port>
is the host and receiver port of the receiver.
This example creates a load-balanced group of four receivers:
./splunk add forward-server indexer1:9997 -method autobalance ./splunk add forward-server indexer2:9997 -method autobalance ./splunk add forward-server indexer3:9997 -method autobalance ./splunk add forward-server indexer4:9997 -method autobalance
Upgrade heavy and light forwarders | Configure a forwarder to use a SOCKS proxy |
This documentation applies to the following versions of Splunk Cloud Platform™: 8.2.2112, 8.2.2201, 8.2.2202, 8.2.2203, 9.0.2205, 9.0.2208, 9.0.2209, 9.0.2303, 9.0.2305, 9.1.2308, 9.1.2312, 9.2.2403, 9.2.2406 (latest FedRAMP release), 9.3.2408
Feedback submitted, thanks!