I am writing this article to help others who have been trying to find clear answers on how to drain a service in Citrix Netscaler 9.3 or greater. The content in this article is from both my hands on experience and from Citrix support
When you need to take a server out of service for maintenance, I recommend opening a SSH session to the Netscaler and typing in the command: stat service
to list the number of connections each service hosted by the server has open. The service name needs to be the name listed for the service on the Netscaler, for example: stat service WebServer-http
You can find the number of connections used by the service by looking at the current client connections and current server connection lines. This is good information to have when you start so you know how many connections are present. Below is a screen shot of what the output from the stat service command would look like.
In the Netsclaer GUI, open the service. By default the “Down State Flush” is selected. What this does is if you disable the service without using a Graceful shutdown, all sessions using the service will be dropped instantly and the service will be marked “Out Of Service”. Citrix support recommends leaving this at its default setting of enabled. Click the Disable button; this will then open a window that will allow you to select Graceful shutdown and Wait Time value in seconds.
When you select Graceful shutdown, all current connections are honored and not dropped and no new connections are permitted. When you set the Wait Time value to 0 this means the service will wait until the last session is closed before it marks the Service as “Out Of Service” For example, if you set the Wait Time value to 3600 seconds, this means the Netscaler will wait 3600 seconds (one hour) before setting the service as "Out Of Service". Any remaining connections would be dropped hard.
Back on the GUI you will see the service listed as “Going Out Of Service” if there are connections currently using the service.