Run Folding@Home on AWS Spot Instances with CDK
Run Folding@Home with this AWS-CDK library on AWS and never forget to shut off expensive instances. With built-in TTL for your stack, you just define the lifetime of your EC2 instances and the stack will be deleted automatically.
About Folding@Home
Folding@home is a project focused on disease research. The problems F@H is solving require many computer calculations – so you can donate your excess compute power to help their research. In that sense, you are part of a huge distributed supercomputer!
The architecture
The architecture follows this AWS blog post and leverages g4dn.xlarge Spot EC2 instances to maximise GPU vs price efficiency. Combined with a time to live mechanism you can launch your stack without having to worry about forgetting your running instances and waking up to a huge AWS bill.
Running at spot price drastically reduces the price from 0.59$ per hour to around 0.17$ in eu-west-1. That's a nice 70% in savings.
Progress
After deployment, you can go into CloudWatch logs and open the log group fahlog. You can now see the progress every one of your instances makes towards the goal of unfolding proteins. wu01 represents the work of the GPU and wu00 is the work of the CPU .
I hope you enjoy this library and together we can make a difference and help the Folding@Home program to succeed in their mission!
Big thanks to cdk-time-bomb for the TTL function and Ash Belmokadem and Vikin Shetty for debugging help!
How to deploy
- Create a new CDK app
cdk init app -l typescript
- Install CDK-Folding@Home in your CDK app
npm install cdkfoldingathome
- Open your stack.ts file in ./bin
- Import the cdkfoldingathome package
import * as folding from 'cdkfoldingathome';
- Create folding stack - important to specify accountId and region
const fah = new folding.FoldingathomeStack(app, 'folding', {
timeToLive: cdk.Duration.hours(5),
spotPrice: '0.40',
numberOfInstances: 10,
env: {
account: "754786554548",
region: "eu-west-1"
}
})
- Ready to build and deploy!
- Your stack gets destroyed once the TTL is up
- Double-check the first time to be sure your stack got really deleted 😉
I hope it all worked out for you and let me know if you have any ideas on how to improve CDK-Folding@home!
If you have any questions reach out on Github or Twitter.