I have a usecase in which i'm using GCE instances as NSQ consumers to work on async processes. This hostgroup have an autoscaling configured when the CPU is above 60% which usually gets triggered when there were alot of messages being consumed at that time. Following is the config:
However as per my understanding, once the average CPU goes below 60% for 15 seconds (based on the cooldown period), the instances will start to downscale and get terminated. Instant termination of the instance would cause the NSQ messages that were being consumed to be requeued(because of not sending the FIN command) causing a double process for the same message. Or sometimes the messages may even get lost.
I would like to know if there a way to maybe signal the instance that it is going to get downscaled? so there service could atleast do a graceful shutdown attempt.
Any other suggestions would be helpful as well