Select Language:
If your server-side application subscribes to an SNS topic when it starts and unsubscribes when it shuts down properly, that’s a good practice to keep things tidy. However, if the application gets forcibly terminated—like using a command such as ‘kill -9’—it might not have the chance to run the cleanup code. This can leave some subscriptions dangling.
So, what happens to those leftover SNS subscriptions? Amazon SNS doesn’t automatically remove subscriptions if the application crashes or is killed unexpectedly. These subscriptions will remain active until you manually remove them or they expire because of a policy you set, if any.
To prevent this issue, consider implementing a way to handle cleanup even if your application doesn’t shut down normally. One method is to regularly check and clean up any subscriptions that shouldn’t be active anymore. Some also set up monitoring or alarms to alert you if there are a lot of unused subscriptions.
Another approach is to design your system so that subscriptions are tied to resources that automatically expire or are cleaned up after a certain period. Alternatively, you can keep track of your application’s subscriptions in your database, and periodically verify that the active ones match your records.
In summary, if you want to make sure there are no stray subscriptions left behind, you shouldn’t rely solely on normal shutdown procedures. Instead, add some extra checks or cleanup routines that run periodically or upon application restart. That way, you keep things tidy and avoid leaving unused subscriptions hanging around in your AWS environment.



