The "Advanced Settings" feature in VergeCloud CDN allows for precise management of user traffic and load balancing behavior. This feature can be accessed after selecting the domain within the VergeCloud CDN panel under the "Traffic" section and then navigating to "Advanced Settings".
For instance, a business operating a web application may experience variable traffic patterns. By employing the Round Robin algorithm, they can evenly distribute incoming requests across three servers, optimizing resource utilization. Conversely, a gaming platform might use the Client IP Hash algorithm to ensure players maintain a stable connection to the same server, enhancing the gaming experience by preserving session data.
This section allows you to select the algorithm that determines how requests are distributed among origin servers.
The Round Robin algorithm is the most straightforward load balancing technique, distributing user requests in a cyclical manner. For example, if you have six users (u1, u2, u3, u4, u5, u6) and three servers (s1, s2, s3), the requests will be allocated as follows: u1 to s1, u2 to s2, u3 to s3, u4 back to s1, u5 to s2, and u6 to s3. This algorithm is effective when requests are predictable, and server capabilities are similar. If one server possesses greater capacity, you may implement a weighted round robin strategy to leverage its strength.
This algorithm routes user requests to specific servers based on the hash value of the user's IP address. When a request is received, the Load Balancer computes a hash from the IP address, determining which server will handle the request. This method ensures that requests from the same IP are consistently directed to the same server, maintaining session continuity, which is vital for applications requiring session-specific data.
By enabling this option, if a request encounters errors such as Connection Refused or Connection Error, the request will be automatically routed to the next available server, preventing the primary server's error message from reaching the user. This feature is accessible to Growth plans and above.
Activating this feature will temporarily remove a server from the rotation if it exceeds five error responses, redirecting traffic for 15 seconds. You can modify the error threshold and timeout duration in the settings. This feature is also available in Growth plans and above.
Enabling this setting keeps the connections to the origin server open for reuse, significantly reducing the number of new connections and the load on the servers. In HTTP/1.0, a new connection is established for each request, but HTTP/1.1 supports Keep-Alive Connections by default, which helps enhance website performance by minimizing latency and conserving CPU resources.
To configure the advanced load balancing settings in VergeCloud CDN via API, you can utilize the following sample curl request:
curl --location --request PATCH 'https://napi.vergecloud.com/cdn/4.0/domains/yourdomain.com/load-balancers/settings' \
--header 'authority: napi.vergecloud.com' \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: API KEY' \
--header 'Content-Type: text/plain' \
--data '{"method":"cluster_chash","next_upstream_tcp":"on","protocol":"https","keepalive":"on","max_fails":5,"fail_timeout":"10s"}'
In this request, the method key is critical for determining the load balancing type, with values cluster-rr
for Round Robin and cluster-chash
for Client IP Hash. The next_upstream_tcp key governs the error handling feature, accepting values on
or off
. The max_fails and fail_timeout keys manage the "Stop Sending Traffic to Faulty Server" feature, requiring a positive integer and a time duration, respectively. Finally, the keepalive key is for maintaining connections with the origin server, accepting on
or off
values.
To validate the configuration of your advanced settings, you can use tools such as dig
, curl
, or browser-based checks. Here’s how to test:
dig
to check DNS propagation and ensure that traffic is directed correctly.dig yourdomain.com
curl
to test connectivity and response from the specified servers.curl -I https://yourdomain.com