Skip to Content

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.

Pre-requisites:

  1. SAP HANA Developer Edition on AWS
  2. 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).

Steps:

  1. Create a new Spot Request using your base AMI
  2. 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
  3. 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.
  4. 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.]SpotInstances.jpg
  5. The status of your new AMI will change to “available” after successful completion.
  6. Remove the association between the Elastic IP and the Spot Instance.
  7. 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.

http://scn.sap.com/community/developer-center/hana/blog/2013/06/23/preventing-the-deletion-of-ebs-volumes-during-the-termination-of-aws-spot-instances

To report this post you need to login first.

6 Comments

You must be Logged on to comment or reply to a post.

  1. Bill Timm

    Hi Nilesh,

    Something else you can do to help manage cost is to create am Amazon CloudWatch alarm with action.  For example, you could create an alarm with an action to stop the instance when average CPU utilization drops below 10% for certain number or periods in a certain amount of time (see link below for details). This would be similar to a motion sensing light switch automatically turning off a light after you have left the room.

    http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/UsingAlarmActions.html

    Regards,

    Bill

    (0) 
    1. Nilesh Bhosale Post author

      Hi Bill,

      Thanks for the useful tip. I did not realise until now that alarms provide an option to stop the instance as well.

      Regards,

      Nilesh

      (0) 
  2. Mani Sekaran Muthu

    Nilesh,

    In your second paragraph, you say “there is a way around this to ensure you dont lose your long hours’ work.”  But the steps you outlined for saving work between sessions may work only for user-initiated termination of spot instances. Termination of spot instances could also be AWS-initiated because of price, capacity, or other reasons (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances-bid-status.html#spot-instances-bid-status-lifecycle) — in this case your would lose all the work your have done in your session before the termination.

    The method I describe in my blog, which you referenced in this blog, would save the work you have done up until termination time in your session, regardless of whether the termination is AWS-initiated or user-initiated.

    Thanks.

    (0) 
    1. Wolfgang Röckelein

      You can now request spot instances lasting for at least 1-6 hours. So can rely on that and as long you create the new AMI before the requested end you will be fine.

      (0) 
  3. Gregory Misiorek

    Hi there,

    it’s weird and i have never done it before, but let me give it a shot as it’s Halloween, so who knows. i’m going to respond to a comment that hasn’t made it yet or is not any longer here:

    i may not have all the facts and probably am missing something, but this blog needs updating to the latest “architecture” of #AWSHANA. this architecture is different from what it was during the last summer in one important aspect. what is different is that both server and client are now running as AWS instances.

    i have created AMI’s for both twice and in both cases i was unable to connect from the client to the server. i think it’s due to missing key pairs as they get wiped out when the original instance request is terminated and creating new ones is not accepted by the hana (linux) server. (windows) client seems ok as it only requires reentering the password, but for some reason the server cannot be connected to. until there are persisted AMI’s that can have spot requests created for them and the connection is made successfully, i don’t see a way of using spot pricing (which is but a fraction of the regular pricing).

    if the above can be corrected i will be more than happy to be wrong about this.

    everyone, enjoy your #awshana !

    thx,

    greg

    (0) 

Leave a Reply