On the Apinizer platform Load Balancer Servers between Gateway and API are the endpoint addresses of your Backend API that run on more than one server.

Figure: Routing

  • The Request Routing server is installed with default values ​​when the gateway is created. If you want to edit, click the Routing button in the message area between Gateway and API on the Gateway Formatting screen. In the Request Routing window that opens, the fields that are described below are entered.

    • Algorithm: Selects the algorithm for load balancing. The table in which the application servers are located is managed.
    • Connect Timeout (ms) : The time to connect to a server is given in milliseconds. If the server cannot connect during this time, the request is forwarded to another server.
    • Read Timeout (ms) : If no response is returned from the server during this time, in milliseconds, the request is forwarded to another server.
    • Error Code for Retry: If the API returns any of the error codes specified here, the request is forwarded to the other servers.
    • Retry Count: The number of times the same server will be run is entered.
    • Failover Retry Count: If unsuccessful trials are in progress, the amount of time to stop after most attempts is entered.
    • Circuit Breaker: Activates the Circuit Breaker when this option is selected.
  • Click the Save button to perform the operation.

Circuit Breaker

When the circuit breaker option is activated, it monitors the current endpoints in a load distribution system.If there is any abnormality in endpoint responses, it stops the access to the endpoint for a while to ensure that clients receive consistent answers.

For this purpose, the Circuit Breaker feature is activated in the Routing policy.

Error Window (ms): Indicates the monitoring time for errors of endpoints. For example, in the case of 30000 errors in the last 30 seconds are followed.

Error Threshold : Specifies how many errors cannot be tolerated within the time period followed. Percentage can be specified or counted. The circuit breaker is activated when the threshold is exceeded.

Sleep Window (ms): Indicates how long a new request will not be sent to the endpoint monitored by the circuit breaker being activated.

Half Open: If the “half-open” option is turned on after the time specified by this option, a “1” request is sent to the corresponding endpoint, and if the returned result is incorrect, this endpoint is taken as more “passive” than the duration (no new request). If the half-open option is off, the values of the corresponding endpoint are reset and continue to monitor during the Error Window.

For example:

Error Window: 30000ms

Error Threshold :%50

Sleep Window : 60000ms

Half Open: In case of error in 51% of the messages returned from the end point in the last 30 seconds, the circuit breaker is activated, takes this endpoint to pass for 60 seconds ve sends the first request to this endpoint when 60 seconds pass. If the rotating response is faulty, this endpoint sleeps for another 60 seconds, If successful, it resets the tracking values and activates the endpoint and continues monitoring.

Request Routing Algorithms; Round Robin - The gateway requests are distributed according to the list of addresses that are ordered. The load balancer directs incoming requests according to the address order in the list. At the end of the list, the load balancer returns to the top of the list and the same cycle continues. LRU (Least Recently Used) - The load balancer routes the incoming request to the server that has not been used for the longest time between servers. Weighted - The user assigns weight to the servers. This weight is taken into account in the order of requests to the servers respectively. Random - Requests are routed to randomly selected servers.