OpenFOAM is free software for computational fluid dynamics (CFD). It offers an alternative to proprietary CFD software which incurs large upfront costs in the form of licence fees and support and maintenance contracts. Instead, OpenFOAM gives you the freedom to purchase services, such as Training, Support and Developments (to extend OpenFOAM’s capability), when you need them.
Cloud computing extends this idea to hardware. It avoids minimum spend commitments and long-term contracts, replacing large upfront expenses with low, variable payments that only apply to what you use. CFD simulations cover a range of sizes and complexity. Activity is generally interrupted by quiet periods when simulations are halted, e.g. when a simulation ends during non-working hours, or during analysis of results, preparation of a new simulation, etc. The fluctuating demand makes CFD well suited to a pay-per-use model.
Users need to understand the costs involved to get the best value from cloud and be confident that they fall within budget. This article explains the costs and provides an example of the cost of running an external aerodynamics calculation with OpenFOAM using CFD Direct From the Cloud™ (CFDDFC) on Amazon Web Services (AWS). Note: all prices quoted are as of 2016-11-11.
Cost Breakdown
CFDDFC is a complete platform, deployed on AWS Elastic Cloud Compute (EC2) virtual servers, providing OpenFOAM and other supporting software, running on the latest long-term support version of Ubuntu Linux. The charges associated with EC2 are:
- EC2 instance costs;
- data storage;
- data transfer to and from the EC2 instances;
- software costs.
EC2 Pricing: On-Demand and Spot Instances
There are 4 ways to pay for EC2 instances, with On-Demand and Spot instances being the 2 options offering a ‘pure’ pay-per-use model. Charges for a running EC2 instance (a virtual server on AWS) are incurred hourly, with a fraction of an hour billed as a whole hour [Note: from September 2017, EC2 changed to per-second billing]. On-Demand instances are sold at a fixed price where availability is guaranteed (within the limits of the SLA). Spot instances are spare EC2 instances that users can bid for, whose price fluctuates based on the supply and demand of available EC2 capacity. When a user makes a bid for a Spot instance, it is launched when the bid exceeds the current Spot market price, and continues until terminated by the user or when the Spot market price exceeds the bid. The user is charged the Spot market price — not the bid price — while the instance runs.
Spot instances can offer substantial savings over On-Demand instances, as shown in the AWS Spot Bid Advisor. For example, a c4.8xlarge
instance that includes 18 physical cores is priced at $1.675 per hour in the US-Ohio (us-east-2
) region. The Spot price history for the past 24 hours (2016-11-11) on that instance, in the same region, fluctuates between $0.20 and $0.40 per hour, with an average price of approximately $0.30 per hour, saving 82% of the On-Demand price. Savings are high because AWS must retain a significant amount of unused capacity to ensure availability of On-Demand instances. CFD is perfectly suited to take advantage of Spot instances because it can accommodate a delay on the rare occasion a bid is rejected.
Data Storage and Transfer
Data is stored using Amazon Elastic Block Store (EBS) attached to an EC2 instance. It is charged by the amount of storage provisioned in GB per month, pro-rated to the hour, until the storage is released. When running CFD with EC2, the storage can be provisioned for the duration of the simulation, with the necessary data transferred out of the instance before it is terminated and the storage is released. The cost of EBS is typically $0.10 per GB-month.
Amazon Simple Storage Service (S3) offers better value for longer term data storage. S3 pricing varies by region and frequency of access, but between $0.0125 are $0.03 per GB-month is typical. Amazon Glacier provides storage at an even lower cost of $0.007 per GB-month for data archiving.
Data transfer charges are listed as part of the On-Demand EC2 pricing. Transfer is charged at $0.09 per GB beyond the first 1 GB of data and up to the first 1 TB of a given month. This can be a significant cost which users can minimize with careful OpenFOAM configuration, e.g. setting up run-time post-processing of their simulations, rather than downloading raw case data, writing data in binary or gzip-compressed format, etc.
Software Charges
CFD Direct From the Cloud is charged as an hourly software fee, alongside the hourly fees for EC2. The software costs are a small fraction of the On-Demand charges for EC2 and are listed on the CFDDFC product page on AWS. All the software supplied with CFDDFC is free and open-source, requiring no additional fees for their use.
Use Case: External Aerodynamics around a Vehicle
We set up a simulation in OpenFOAM to run a steady-state, turbulent, incompressible flow simulation of external aerodynamics around a car with:
- a vehicle surface geometry, OBJ format, consisting of ∼3 m triangles, ∼30 MB gzip compressed;
- meshing configuration with snappyHexMesh to generate a mesh of ∼18 m cells;
- initial and boundary conditions, turbulence models and wall functions, and schemes and solver settings;
- configuration to decompose onto 18 domains for running in parallel on 18 physical cores using the
c4.8xlarge
instance; - configuration to calculate force coefficients, and VTK files of vehicle, cutting plane and streamlines for visualization.
Charge | On-Demand Instance | Spot Instance |
---|---|---|
EC2 Instance | $1.675/hr → $13.40 | ~$0.300/hr → $2.40 |
Data Storage | 20 GB → $0.02 | 20 GB → $0.02 |
Data Transfer | 10 GB → $0.90 | 10 GB → $0.90 |
Software Charges | $0.335/hr → $2.68 | $0.335/hr → $2.68 |
TOTAL | $17.00 | $6.00 |
The table above shows costs of running the simulation priced for both On-Demand and Spot instances. A c4.8xlarge
instance was used for 8 hours, running 45 minutes of mesh generation followed by 410 minutes of simulation with the simpleFoam solver, running for 2000 iterations. The case was configured to purge all except 2 time directories (with purgeWrite 2;
in the controlDict file) and to gzip-compress the field data files. Field data fitted comfortably within 5 GB of storage, and with run-time processed data such as VTK files for visualization (written every 50 iterations) system software and some spare capacity, the provisioned data storage was 20 GB. Although only a fraction of that data needed to be downloaded at the end of the simulation, we allowed for 10 GB in the calculation above.
Cloud vs On-Premises Hardware
To compare these cloud costs with the cost of on-premises hardware, we can make some very approximate cost estimates and assumptions. We can start with $5,000 for a computer with comparable specification to c4.8xlarge
(2× Intel Xeon E5-2666 v3 Haswell processors, 2.9-3.4 GHz, 64 GB RAM server). We add 100% overhead costs, covering system administration, electricity, rental space, assuming a 3-year lifetime of the the computer, giving a total cost of $10,000.
Let us assume a utilization of 8 hours per day for 220 days per year. Over 3 years, the cost of running in the cloud with On-Demand instances would be ~$11,200, comparable to on-premises costs, especially factoring in other effects such as cloud hardware upgrades during the period. The cost of using Spot instances, however, would be ~40% of the on-premises cost. On the basis of cost alone, the case for using cloud for CFD is compelling given its suitability for running on Spot instances.