# LoadBalancingConfig

<div class="jsdoc-content"><header>
    
        <h2><span class="attribs"><span class="type-signature"></span></span>
            <span class="ancestors"><a href="index.html">policies/loadBalancing</a>~</span>LoadBalancingConfig<span class="signature">()</span><span class="type-signature"></span></h2>
        
            <div class="class-description"><p>This class represents the options of the rust driver Default Load Balancing Policy.
This option will be used to configure that policy.
You can find more about this policy in the documentation:
https://rust-driver.docs.scylladb.com/stable/load-balancing/default-policy.html</p></div>
        
    
</header>


    
        

    
    </div>

## Constructor

<div class="jsdoc-content">
    

    
    <h4 class="name" id="LoadBalancingConfig"><span class="type-signature"></span>new LoadBalancingConfig<span class="signature">()</span><span class="type-signature"></span></h4>
    

    















<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/policies/load-balancing.js#L740" target="_blank" rel="noopener">policies/load-balancing.js, line 740</a></p></div>




















    
    

    

    

    

    

    

    

    
        </div>

## Members

<div class="jsdoc-content">

        
            
<h4 class="name" id="allowList"><span class="type-signature">(nullable) </span>allowList<span class="type-signature"> :Array&lt;string></span></h4>




<div class="description">
    <p>The hosts address in the format ipAddress:port.
When the list is provided, only hosts from this list may get connected to
(whether they will get connected to or not depends on the other policy options).</p>
</div>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">Array&lt;string></span>


        </li>
    </ul>





<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/policies/load-balancing.js#L840" target="_blank" rel="noopener">policies/load-balancing.js, line 840</a></p></div>






        
            
<h4 class="name" id="enableShufflingReplicas"><span class="type-signature">(nullable) </span>enableShufflingReplicas<span class="type-signature"> :boolean</span></h4>




<div class="description">
    <p>Sets whether this policy should shuffle replicas when token-awareness
is enabled. Shuffling can help distribute the load over replicas, but
can reduce the effectiveness of caching on the database side (e.g.
for reads).</p>
<p>This option is enabled by default. If disabled, replicas will be chosen
in some random order that is chosen when the load balancing policy
is created and will not change over its lifetime.</p>
</div>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">boolean</span>


        </li>
    </ul>





<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/policies/load-balancing.js#L831" target="_blank" rel="noopener">policies/load-balancing.js, line 831</a></p></div>






        
            
<h4 class="name" id="permitDcFailover"><span class="type-signature">(nullable) </span>permitDcFailover<span class="type-signature"> :boolean</span></h4>




<div class="description">
    <p>Sets whether this policy permits datacenter failover, i.e. ever attempts
to send requests to nodes from a non-preferred datacenter.</p>
<p>In the event of a datacenter outage or network failure, the nodes
in that datacenter may become unavailable, and clients may no longer
be able to access data stored on those nodes. To address this,
the <code>DefaultPolicy</code> supports datacenter failover, which allows routing
requests to nodes in other datacenters if the local nodes are unavailable.</p>
<p>Datacenter failover can be enabled in <code>DefaultPolicy</code> setting this flag.
When it is set, the policy will prefer to return alive remote replicas
if datacenter failover is permitted.</p>
</div>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">boolean</span>


        </li>
    </ul>





<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/policies/load-balancing.js#L818" target="_blank" rel="noopener">policies/load-balancing.js, line 818</a></p></div>






        
            
<h4 class="name" id="preferDatacenter"><span class="type-signature">(nullable) </span>preferDatacenter<span class="type-signature"> :string</span></h4>




<div class="description">
    <p>Sets the datacenter to be preferred by this policy.</p>
<p>Allows the load balancing policy to prioritize nodes based on their location.
When a preferred datacenter is set, the policy will treat nodes in that
datacenter as &quot;local&quot; nodes, and nodes in other datacenters as &quot;remote&quot; nodes.
This affects the order in which nodes are returned by the policy when
selecting replicas for read or write operations. If no preferred datacenter
is specified, the policy will treat all nodes as local nodes.</p>
<p>When datacenter failover is disabled (<code>permitDcFailover</code> is set to false),
the default policy will only include local nodes in load balancing plans.
Remote nodes will be excluded, even if they are alive and available
to serve requests.</p>
</div>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">string</span>


        </li>
    </ul>





<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/policies/load-balancing.js#L760" target="_blank" rel="noopener">policies/load-balancing.js, line 760</a></p></div>






        
            
<h4 class="name" id="preferRack"><span class="type-signature">(nullable) </span>preferRack<span class="type-signature"> :string</span></h4>




<div class="description">
    <p>This option cannot be used without setting <code>preferDatacenter</code>.</p>
<p><code>preferDatacenter</code> and <code>preferRack</code> set the datacenter and rack to be preferred by this policy.</p>
<p>Allows the load balancing policy to prioritize nodes based on their location
as well as their availability zones in the preferred datacenter.</p>
<p>When a preferred rack is set, the policy will first return replicas in the local rack
in the preferred datacenter, and then the other replicas in the datacenter.</p>
</div>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">string</span>


        </li>
    </ul>





<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/policies/load-balancing.js#L774" target="_blank" rel="noopener">policies/load-balancing.js, line 774</a></p></div>






        
            
<h4 class="name" id="tokenAware"><span class="type-signature">(nullable) </span>tokenAware<span class="type-signature"> :boolean</span></h4>




<div class="description">
    <p>Sets whether this policy is token-aware (balances load more consciously) or not.</p>
<p>Token awareness refers to a mechanism by which the driver is aware
of the token range assigned to each node in the cluster. Tokens
are assigned to nodes to partition the data and distribute it
across the cluster.</p>
<p>When a user wants to read or write data, the driver can use token awareness
to route the request to the correct node based on the token range of the data
being accessed. This can help to minimize network traffic and improve
performance by ensuring that the data is accessed locally as much as possible.</p>
<p>In the case of <code>DefaultPolicy</code>, token awareness is enabled by default,
meaning that the policy will prefer to return alive local replicas
if the token is available. This means that if the client is requesting data
that falls within the token range of a particular node, the policy will try
to route the request to that node first, assuming it is alive and responsive.</p>
<p>Token awareness can significantly improve the performance and scalability
of applications built on Scylla. By using token awareness, users can ensure
that data is accessed locally as much as possible, reducing network overhead
and improving throughput.</p>
</div>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">boolean</span>


        </li>
    </ul>





<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/policies/load-balancing.js#L801" target="_blank" rel="noopener">policies/load-balancing.js, line 801</a></p></div></div>
