On-demand instance cost for AWS resources can be reduced by 25% using no-upfront reservations or by 56% by purchasing the instance for 3 years. However the use of the spot instance market allows a reduction from 80 to 90% - but not in beanstalk.
There is however a way to reserve spot instances for elastic beanstalk through the .ebextension mechanism like we do for other types of EC2 instance customization. There are the usual problems of not being compatible with auto-scaling but this price reduction is excellent for development instances.
Enter the following .config with a spot price that is just above the lowest price across all regions for the past 3 months - so you run the lowest risk of loosing the instance. For example I reserved the new C4.Large at 0.018 which is above the normal spot of 0.0161 - however this is a lot better than the on-demand price of 0.160 - or 10% of the normal price.
Note the spot price which is a reduction of 90% on the AWS EC2 on-demand price. We will put this into the .ebextension directory in a config file
Add the following to your pom.xml if you are using "ebextensions" instead of the target ".ebextensions"
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>src/main/ebextensions</directory>
<targetPath>.ebextensions</targetPath>
<filtering>true</filtering>
</resource>
As soon as your instance is up and the war completes deployment - the healthcheck will report a good instance.
If you are running a set of development servers like 10 M3.xlarge instances at a on-demand price of $0.28/hour - this comes out to $67/day or $25,000/year. Switching to using spot instances at the current stable price in us-east-1b of $0.0321 - but lets use $0.034 - would come out to $8/day or $3000/year - a cost savings of $22,000 at 88% off. Actual savings would be more in line with $8,000 or 72% if you normally use 3yr reserved instances.
Note that you can loose your instance at any time if the lowest spot price jumps.
There are ways to get environment variables into the config files without resorting to commands or sh scripts - so we can change the spot price when we want to up the instance to a C4.8xlarge for example.
/michael
Use .ebextensions to save 90% using spot price #EC2 instances for #AWS @aws_eb elastic beanstalk @awscloud deploys
http://t.co/HoU9LOGXOq
— Michael_OBrien (@_mikeobrien) February 15, 2015
Presenting on @awscloud Elastic Beanstalk @aws_eb in a VPC for #AWS Ottawa Users Group - Feb 24 at @bitHeads Ottawa - http://t.co/YsH2dTwLUu
— Michael_OBrien (@_mikeobrien) February 20, 2015