iisgoogle-cloud-platformload-balancinghttp-erroriis-10

GCP load balancer 502 server error and "backend_connection_closed_before_data_sent_to_client" IIS 10


I have GCP load balancer with 4 IIS 10 web servers. Sporadically it comes with 502-Server error. In the logs it shows it is because of backend_connection_closed_before_data_sent_to_client. I have read thru the article https://cloud.google.com/compute/docs/load-balancing/http/ and it says keepalive timout need to be set to 620 seconds for nginx and apache. How do I do the same in IIS 10.


Solution

  • Figured this out after raising a ticket google cloud team. I am putting it here so that others can benefit.

    Step 1 : Set the timeouts in Google Cloud Load Balancer

    There are two timeout settings in Google cloud load balancer.

    1. Timeout and
    2. Connection draining timeout.

    See the screenshot below. Load balancer settings

    Both the above settings need to be the same. In our case, there are a number of long running requests and it is set to 1800 seconds.

    Step 2: Set the connection timeout in IIS 20 second greater than the load balancer setting

    Under IIS Site name - go to Advanced settings and then set the Connection Time-out value to 20 seconds more than the load balancer timeout. In my case 1820.

    IIS Settings

    The idea is that the IIS connection should not timeout before load balancer. If it times out then it may leads to backend_connection_closed_before_data_sent_to_client error.