Clear all

Connection draining in GCP  


Ganesh A
Noble Member
Joined: 4 months ago
Posts: 1170
24/03/2021 11:08 am  

I need to make sure that I enable connection draining on GCP so that if at all I remove a VM instance, the processes in progress get completed. How can I enable this?

Noble Member
Joined: 4 months ago
Posts: 1179
24/03/2021 11:09 am  

Connection draining is a process that ensures that existing, in-progress requests are given time to complete when a VM is removed from an instance group.

To enable connection draining, you set a connection draining timeout on the backend service. 

The timeout duration must be from 1 to 3600 seconds.

To enable connection draining on a new or existing backend service by using the --connection-draining-timeout flag.

For example, when updating a backend service, provide the flag with your request:

gcloud compute backend-services update [BACKEND_SERVICE] \
    --connection-draining-timeout [CONNECTION_TIMEOUT_SECS]


  • [BACKEND_SERVICE] is the backend service for this request.

  • [CONNECTION_TIMEOUT_SECS] is the number of seconds to wait before instances are terminated, between 0 - 3600 seconds, inclusively. A setting of 0 disables connection draining. This timeout duration applies to all instance groups that are part of the backend service.