How to save state when preempted on a Google preemptible instance?

此生再无相见时 提交于 2019-12-08 03:30:28

You may want to use shutdown scripts for this:

Create and run shutdown scripts that allow you to execute commands right before an instance is terminated or restarted, on a best-effort basis. This is useful if you rely on automated scripts to start up and shut down instances, allowing your instances time to clean up or perform tasks, such as exporting logs, or syncing with other systems.

If you have a managed instance group that is being autoscaled, shutdown scripts can be useful because if an instance is shut down due to autoscaling, the shutdown script performs any actions you define before the instance is terminated. For example, your shutdown script might copy processed data or back up any logs.

Shutdown scripts function very similarly to startup scripts; much of the documentation for startup scripts also applies for shutdown scripts.

However, since you have limited time to do the work, consider using persistent external storage systems which won't be deleted when your instance is preempted, e.g., Google Cloud Storage, Google Cloud Bigtable, Google Cloud Datastore, or others.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!