Reduce your HANA AWS cost by utilizing Spot Instances
I am sure many of you have been using the HANA Developer Edition on AWS for openSAP’s Software Development on HANA course. As we are into week 6 of the course (trying to spend as much time to practice the examples shared by Thomas Jung), I will try to share a quick tip to save on AWS costs.
In Week 1 Thomas pointed out that by using Spot Requests we can bid for unused capacities for Amazon instances. While working on these spot instances I realised that there is a catch. Any work that you do on the spot instance would be lost as you need to TERMINATE the instance. Why? Because, there is no option to STOP a spot instance. Thankfully, there is a way around this to ensure you dont lose your long hours’ work.
- SAP HANA Developer Edition on AWS
- An Amazon Machine Image (referred to as base AMI subsequently) taken at a suitable point of time. This must include all your development artifacts that you would like to be available in your spot instance (to be requested in subsequent steps).
- Create a new Spot Request using your base AMI
- When you create the request ensure you mark all your EBS volumes as “Delete on Termination” = TRUE. This will ensure that after you are done with using your HANA instance, these volumes don’t lie in your AWS account adding to the costs
- After you HANA instance is up and running, associate your Elastic IP to the newly created instance. You can then complete your development tasks that you planned for. Please Save & Activate everything to ensure the HANA repository is up to date.
- After your tasks are complete and you no longer need the instance, create a new Amazon Machine Image for your “Spot Instance”. [Please note that you are not creating an image of your original instance which is probably not running at this point of time.]
- The status of your new AMI will change to “available” after successful completion.
- Remove the association between the Elastic IP and the Spot Instance.
- Now you can terminate your spot instance.
Whenever you want to resume your work for HANA, you can create a new Spot Request using the new AMI created in Step 4 and use it as the Base AMI. As you keep following these steps week after week, please ensure that you remove older AMIs & snapshots to keep your costs down.
If you do not want the hassle of creating a different AMI each time, Mani Sekaran Muthu has a good blog on an alternative approach.