{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","settings":"","results":{"codes":[]},"params":[]},"next":{"description":"","pages":[]},"title":"Estimate and manage your cloud costs","type":"basic","slug":"estimate-and-manage-your-cloud-costs","excerpt":"","body":"##Overview\n\nIn this tutorial, you will learn how cloud costs are incurred on the CGC, and the steps you should take to estimate your project cloud costs in advance of scaling up analyses.\n\nLearning to estimate and manage your cloud costs will prepare you to effectively budget for your research projects. These estimates can be included in grant proposals, or be used to request cloud credits offered by the National Institutes of Health.\n\n##Background\n\nThe Platform is a [multi-cloud](https://www.sevenbridges.com/be-cloud-agnostic/) bioinformatics solution. This means that you can run compute jobs on regions of both Amazon Web Service (AWS) and Google Cloud Platform (GCP) (Figure 1). By running analyses on the cloud in the location where data is stored, it saves you time that would otherwise be spent copying large datasets. This multi-cloud functionality can also lead to cost savings, since data egress charges can be avoided. These concepts will be expanded upon throughout this tutorial.\n\nNew Platform users may be accustomed to working with an on-site HPC system or local server. Local systems require a large investment in hardware, software, and maintenance, and these costs may seem invisible on a day-to-day basis. By comparison, cloud computing operates under a “pay as you go” model, where you are charged only for the resources you need, when you need them. This represents a cultural shift for performing computational research. However, by keeping some simple principles in mind, you can easily estimate and manage your cloud costs.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/3d66d7b-Screenshot_2021-09-02_at_10.58.00.png\",\n        \"Screenshot 2021-09-02 at 10.58.00.png\",\n        682,\n        341,\n        \"#333\"\n      ],\n      \"caption\": \"Figure 1. CGC is a multi-cloud Platform where the cloud costs are passed directly to users.\",\n      \"sizing\": \"original\"\n    }\n  ]\n}\n[/block]\nOne significant advantage of using the CGC for your computational research is that you can leverage existing datasets that are hosted in the cloud. CGC hosts the rich [The Cancer Genome Atlas (TCGA)](https://www.cancer.gov/about-nci/organization/ccg/research/structural-genomics/tcga) dataset.\n\nHosted data is stored in the cloud and is made available to users on the CGC based on data access controls. This means that users can access the hosted data and run analyses on it without the need to spend time and resources downloading large datasets, or pay for storage costs.\n\n##What will incur costs?\n\nWhen estimating the cost of using the CGC, there are two types of costs to keep in mind:\n1. data storage, including inputs, outputs, intermediate files, and transfer of data;\n2. computational costs of the analysis. Both types of costs will be explored in more detail below. \n\n###Data Storage\n\nStorage costs are incurred by the user when files are stored on the CGC. Users can upload/import data to the CGC using several mechanisms (see documentation on [Uploading Data](doc:uploading-to-the-cgc)). Once the data is uploaded, data storage becomes an ongoing cost. \n\nThe primary sources of storage costs include:\n\n1. **Your own data** - Data uploaded to projects on the CGC through the GUI, API, or Seven Bridges Command Line Interface (CLI) are housed in storage buckets (AWS S3, or GCS) based on the cloud region assigned to a project at its creation.\n\n    **Example**: A researcher uploads sequencing data in the form of `.fastq` files to the CGC.  \n    \n\n2. **Workflow output data** - Files generated by running an analysis on uploaded or hosted data will incur storage costs. Running a workflow or tool on hosted data generates a derived file. This file derived from a hosted dataset will accrue storage costs the same way an uploaded file, or a file derived from an uploaded file, would. Example: You run a [fastqc workflow](https://cgc.sbgenomics.com/public/apps/admin/sbg-public-data/fastqc-analysis) on .fastq data uploaded to your project. The output .html report and .zip files from the workflow accrues storage costs in addition to the input .fastq file.\n\n  **Example**: You merge two hosted .vcf files from a hosted study into a single, larger, .vcf file using [bcftools merge](https://cgc.sbgenomics.com/public/apps/admin/sbg-public-data/bcftools-merge). Only the output .vcf file accrues storage costs since the input vcf files were from hosted studies.\n\n  **Note**: Transferring data out of the cloud incurs data egress charges set by the cloud provider. Both [AWS](https://aws.amazon.com/blogs/aws/aws-data-transfer-prices-reduced/) and [Google Cloud](https://cloud.google.com/storage/pricing#price-tables) charge for data egress and publish this information online.\n\n### Computational jobs\n\nThe second major source of cloud costs on the CGC is computational jobs. Computational jobs on the CGC are executed using AWS or GCP compute instances. Compute instances provide a defined model and number of CPU cores and memory (RAM) on which to execute a computational job. Pricing for instances is set by the cloud provider.\n\nThe following costs are relevant to computational jobs:\n\n1. **Workflow instance pricing** - Instances used to run workflows or tools are charged according to the type of instance and run-time of the job. Tools within a workflow may run on different instance types. Default instance types may also be overridden if a given computational job requires more resources.\n\n    **Example**: When running a variant calling workflow, [different instance types](https://aws.amazon.com/ec2/instance-types/) are used for alignment and variant calling steps. The cost passed onto users is the total cost for the time spent on each instance.\n\n2. **Interactive Notebook ([Data Cruncher](doc:about-data-cruncher)) instance pricing** - The CGC offers Jupyterlab Notebooks, RStudio, and SAS as part of the Data Cruncher feature. These environments enable users to perform iterative, interactive, and data visualization tasks on the cloud where their data is already located. Each environment has a default instance type set for launching a notebook; however, users can customize the instance type if they require more CPUs or memory. Data Cruncher instances are billed by the type of instance and the time used.\n\n    **Example**: After running various workflows, you want to both explore the dataset and generate summary figures using R or Python in an interactive notebook. The cost passed on to you is the total cost for time spent on each instance.\n\n    **Note**: A minor component of the computational costs passed on to users is the storage of temporary files on compute instances. These temporary runtime files are not saved to the user’s project at the completion of a computational job. These temporary storage costs, often a minor fraction of the compute costs for a given job, are included in the cost for the computational job and may be queried using the Seven Bridges API through the R or Python libraries.\n\n##Steps to estimate cloud costs\n\nEstimating your storage and compute costs begins with understanding your data. The section below provides guidance on how to estimate compute costs for Common Workflow Language (CWL) tools and workflows offered on the CGC, as well as for user-created custom CWL tools.\n\nThis section also explains how to estimate costs when working in interactive notebooks, and how to estimate storage costs. Examples are provided for all scenarios. \n\n###Understand your data\n\nThe first step to estimate your analysis and storage costs is to understand your data by answering the following questions:\n\n**Where is your data located?**\n\nIs your data hosted, or will it be uploaded to the CGC? This has consequences for how much you should expect for storage costs.\n\n**How big is your data?**\n\nThe size of data can vary dramatically depending on many factors, including what type of files they are. It is important to remember that using an “average” file size means that some files will be larger or smaller than that average, and this variation can be significant. We recommend understanding the range of data sizes, and how many files there are, in addition to the average size for both your input and output data files.\n\n**How long will your data be stored on the CGC?**\n\nSome files, like workflow outputs that are very time-consuming, are potentially expensive to regenerate,  and may be important to store on the CGC for a long period of time. However, if a file is quick and/or inexpensive to regenerate, or if it is a raw data file that can be easily reacquired from its source, it may be reasonable to delete it rather than store it. The costs of regenerating a file are often less than the costs of storage in cloud computing.\n\nBy thoroughly understanding the types of data you plan on analyzing, you can eliminate many sources of uncertainty.\n\n###Estimate tool/workflow costs\n\nRunning CWL tools and workflows are one of the main sources of costs on the CGC, and it is relatively straightforward to estimate the cost for these computational jobs. How we recommend doing this varies depending on whether you use pre-configured CWL apps from the Public Apps Gallery, or custom developed CWL workflows and tools.\n\n####Benchmarking for tools and workflows from the Public Apps Gallery\n\n\nThe CGC [Public Apps Gallery](https://cgc.sbgenomics.com/public/apps) hosts hundreds of popular bioinformatics tools. Each tool and workflow includes a detailed description and benchmarking information for time, computation, and cost.\n\nThis benchmarking information can be used to estimate your anticipated costs for using that tool or a similar custom tool. To estimate costs, we recommend plotting the run-time and/or cost compared to the input file size.\n\nThis will also enable you to see whether or not the runtime or cost of the tool scales linearly. We suggest rounding your estimates up by a minimum of 30% over the calculated cost to anticipate any issues that should arise, rerunning with different settings, unexpected workflow failures due to problems with the input files, etc. For accurate estimations, we recommend running a representative set of files you plan to use for analysis, then extrapolating the costs from the results.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/a63c189-Screenshot_2021-09-06_at_10.15.31.png\",\n        \"Screenshot 2021-09-06 at 10.15.31.png\",\n        935,\n        182,\n        \"#eaeaec\"\n      ],\n      \"caption\": \"Figure 2. Benchmarking information from the RNA-seq alignment - STAR 2.5.4b workflow.\",\n      \"sizing\": \"original\"\n    }\n  ]\n}\n[/block]\n**Example**: You plan to run the STAR RNAseq alignment workflow on 4 samples to assay highly-expressed genes, each of the samples are paired-end. Each file is roughly 4 GB in size, which is nearly the middle scenario detailed in the benchmarking information in Figure 2 above. This adds up to $0.60 x 4 = $2.40. We recommend planning for unforeseen problems (like failed Task runs), and adding an additional 30%, totaling $3.12. \n\nWhen extrapolating beyond the bounds of the benchmarking information it is important to understand whether the particular app scales linearly. For apps that scale linearly, plotting the benchmarking information and fitting a line to the data will provide a reasonable estimate of the run cost. Note that these benchmarks hold true for the instance types provided in the benchmarking table. If the user changes the instance type, then these benchmarks will no longer be accurate.\n\n####Benchmarking apps on your data\n\nWhile benchmarking information available on the CGC is a helpful budgeting tool, we recommend testing with your actual data. This is necessary when bringing your own CWL apps to the CGC, and when running apps from the **Public Apps Gallery** that lack sufficient benchmarking information. In this situation we recommend the following:\n\n1. **Pick a representative but small subset of files** -  in addition to picking a small subset, make sure that it captures the range of input file sizes seen in the real set of files. If your input files vary dramatically in size, you want to make sure that you don’t ignore this fact and underestimate the cost to run the full set.\n\n2. **Run this subset of analyses to create your own benchmarking information for your tool** - After running, use the cost monitoring tools detailed in earlier sections to summarize the cost of this smaller set of files.\n\n3. **Scale up the cost to the larger full set of files you wish to run** - Example: You have 40 pairs of whole-genome bisulfite sequencing fastq files to process using a CWL workflow. The files vary in size from 2 GB to 40 GB, distributed around an average of 20 GB. You select a subset of 5 pairs of fastqs that have a similar range of sizes and the same average size. You then run the workflow on these samples. The average cost of the tasks was $50. Using the average task price you then scale up to the remaining 35 tasks with $1,750 in expected workflow execution costs. To account for unexpected errors or issues that might arise, we recommend adding a 30% buffer and budgeting a total of $2,275.\n\n###Estimate Data Cruncher interactive notebook costs\n\n[Data Cruncher](doc:about-data-cruncher) is an interactive analysis tool, bringing Jupyter, RStudio, and SAS to the Seven Bridges cloud Platform. Calculating costs for running an interactive notebook in Data Cruncher depends only on the instance type and time spent in the environment to perform your analysis.\n\n**Example**: You have prototyped an analysis locally and determined that the default AWS c5.2xlarge instance will suit your needs. The current pricing for this instance is $0.48 per hour and you expect to explore this dataset for approximately 3 hours. This will incur $1.44 in expenses, which we will increase to $1.88 to account for unexpected findings which make your analysis take extra time.\n\n**Note**: Data Cruncher sessions can be set-up to continue running even if your web browser is no longer viewing the page. While this is useful for long-running analyses, it will continue accruing costs until the Data Cruncher session is closed. For this reason, the default settings for Data Cruncher include a time-out. Be careful to make sure you end an analysis when desired if you disable this feature.\n\n###Estimate Storage Costs\n\nStorage is an ongoing cost. This means that monthly storage costs will be charged to the billing group associated with a given project housing the files in question. Hosted data does not incur charges, but files derived from hosted data do. If files are copied between multiple projects, you are only charged once for each file, as long as the projects are a part of the same billing group.\n\nThe best way to understand how much data is stored in a project is to [export a manifest](doc:format-of-a-manifest-file) from the Files tab and calculate the cumulative file size. Please note whether you have duplicated data in your project since this could result in overestimation.\n\n**Example**: You have 5 TB of derived data stored in a project with the location set to AWS-us-east-1. Seven Bridges data incurs $0.021 per GB per month in storage costs for the AWS-us-east-1 cloud location. Therefore, you would expect 5000 GB x $0.021 = $105 to be your monthly storage price.\n\n##Best practices for efficient cloud computing \n\nBy following some simple best practices you can reduce your cloud costs, sometimes dramatically.\n\n###Tools and Workflows\n\n####Efficient workflow design\n\n  * **Re-use rather than re-compute intermediate files** - In certain situations, it makes sense to create multiple versions of workflows that allow starting from an intermediate step. This allows you to avoid repeating computationally-intensive steps in an analysis to do a different downstream processing step.\n    **Example**: You have a complex whole-exome sequencing workflow. There are several steps run to call variants on an input .bam file after read alignment to the reference genome. There are also quality control checks to perform on the .bam file. It makes sense to split up the workflow: one workflow to perform read alignment, outputting a .bam file and any QC metrics you wish to use, and another workflow to perform the downstream variant calling steps. This is more efficient than repeating the alignment step again to call the variants.\n\n  * **Use appropriate instance types** - the CGC allows you to choose instance types for each step in a workflow, as well as override the default options. If you understand the size of data you are working with, you may be able to reduce the price by choosing a cheaper instance. Likewise, you don’t need to select larger instances with features (GPUs for example) or storage in excess of what you need. \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/26492f6-choosing-custom-instance0type.png\",\n        \"choosing-custom-instance0type.png\",\n        992,\n        278,\n        \"#333\"\n      ],\n      \"caption\": \"Figure 3. Selecting a custom instance will change the price that you are charged for running a workflow.\",\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\n  * **Use multithreading options where available** - Many tools within workflows have options for multithreading. It is usually advisable to saturate the available CPU cores/threads on a given instance. This will reduce the run-time, and therefore price, of your job.\n\n  * **Use scattering and batching** - Batching will enable you to group workflow runs over a large number of input files based on the files themselves, or a metadata field that is associated with that file. This optimizes your workflows for run-time, enabling many workflow runs to be carried out simultaneously, without needing to manually click through the job submission page multiple times.\n\n  Scattering is configured within the CWL of the workflow itself. A tool is passed a list of inputs on one port, and one job will be created on the same instance for each input in the list. This helps saturate the available resources on an instance, making sure you are taking advantage of all the compute power that you are paying for.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/c6127cc-Screenshot_2021-09-06_at_16.53.24.png\",\n        \"Screenshot 2021-09-06 at 16.53.24.png\",\n        743,\n        356,\n        \"#f3f6f1\"\n      ],\n      \"caption\": \"Figure 4. Scattering a workflow saturates available CPU cores on this AWS instance.\",\n      \"sizing\": \"original\"\n    }\n  ]\n}\n[/block]\n  * **Use preemptible instances** - By default, instances use on-demand pricing. However, they can also be configured to use [“spot” instances](doc:about-spot-instances). These are preemptible based on bid price and demand. Their pricing does fluctuate, however, it is typically much cheaper than on-demand pricing. There is very little downside to using them on the CGC, as there is a built-in retry mechanism. If your job or a portion of your workflow) is interrupted, it will be retried at on-demand pricing.\n\n  * **Turn on memoization** - [Memoization](doc:about-memoization) allows you to reuse pre-computed inputs to workflow steps. This is relevant if you are running a long workflow and it fails due to a step late in the workflow. In this situation, if memoization is turned on the workflow would restart from the point at which it failed, using the intercreatemediate files saved to the instance, potentially saves money and time.\n\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/355f797-create-a-project.png\",\n        \"create-a-project.png\",\n        591,\n        640,\n        \"#333\"\n      ],\n      \"caption\": \"Figure 5. Spot instances and memoization can be turned on from the project creation dialog. They are also configurable per task, or within the project settings after creation.\"\n    }\n  ]\n}\n[/block]\n###Data Cruncher interactive analysis\n\nData Cruncher is best used for quick, interactive work, such as when you want to explore a dataset, create a visualization, or prototype workflows. Spot instances are not available in Data Cruncher due to their interactive nature.\n\n**Select an appropriate instance type**\n\nAs with workflow tasks, Data Cruncher costs will heavily depend on the instance type that you select at task creation. This is able to be selected from the task creation dialog.\n\n\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/034af79-create-new-data-cruncher-analysis.png\",\n        \"create-new-data-cruncher-analysis.png\",\n        556,\n        476,\n        \"#333\"\n      ],\n      \"caption\": \"Figure 6. Data Cruncher instance type selection.\"\n    }\n  ]\n}\n[/block]\n**Keep the suspend timer turned on**\n\nThe suspend time feature keeps your task from running over an extended period unexpectedly. Without it, the instance will continue running until it is shut down by a user, even if your browser closes (it is running on a cloud instance hosted by AWS or GCP).\n\n**Consider porting repeated tasks to CWL workflows**\n\nWhile a one-off analysis in Data Cruncher with interactive visualizations can be a great way to understand and explore your data, this can become limiting if you are running the same tasks many times. Due to the lack of spot instance availability with interactive analysis, it makes sense to turn commonly performed tasks into workflows described with CWL.\n\n###Storage\n\nWhile straightforward to calculate, storage can add up to a large expense. This is especially true when you run several tasks and output files begin to grow within your projects.\n\n  * **Delete unused files or ones which are cheap to regenerate** - Rather than saving everything, when it is safe to delete a file, whether that is because it is no longer needed or is cheap to generate again through a workflow or tool, delete it.\n  * **Use compressed files when possible** - Many common file formats have a compressed variant. Or they can be compressed into a .zip or .gz file. Common examples include .fastq.gz (vs .fastq), .bam (vs .sam), or .bcf (.vcf).\n  * **Remember where your data is located** - While multiple copies of the same file do not incur additional charges, this also means that you will continue being charged for a file until every copy of it in various projects is deleted. \n  * **Use [Volumes](doc:volumes) to bring data to the CGC** - Users can avoid being charged for storage by the Platform if their data is already hosted on AWS S3 or Google Cloud Storage and they connect that existing storage using the Volumes feature. In this situation, users would pay AWS or Google Cloud Platform directly. This can be useful to avoid being charged again for data already hosted on one of those cloud platforms.\n\n##Cost tracking on the CGC\n\nThe CGC enables you to monitor your cloud costs at the level of individual analyses (tasks), projects, and billing groups. Each will be explained in more detail below.\n\n###Cost monitoring at the task level\n\nThe CGC shows the cost incurred by all tasks (workflows and tools) which are finished running, whether these tasks completed successfully or ended with an error. The Task summary pages remain indefinitely within the project including the cost information.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/0d4f550-task-price-showin-on-task-page.jpg\",\n        \"task-price-showin-on-task-page.jpg\",\n        931,\n        549,\n        \"#333\"\n      ],\n      \"caption\": \"Figure 7. The Task price is shown in the top section of the Task page\"\n    }\n  ]\n}\n[/block]\n###Cost monitoring at the project and billing group levels\n\nTo see more detailed cost summaries, you can navigate to the Payments page by clicking on your user name on the top right corner of the interface.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/26dca39-accessing-the-payments-page.jpg\",\n        \"accessing-the-payments-page.jpg\",\n        609,\n        338,\n        \"#333\"\n      ],\n      \"caption\": \"Figure 8. Finding the Payments page.\"\n    }\n  ]\n}\n[/block]\nThe Payments page shows the billing groups of which you are currently a member. All users start off with a Pilot Funds billing group. \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/484fcea-pilot-funds.jpg\",\n        \"pilot-funds.jpg\",\n        708,\n        336,\n        \"#333\"\n      ],\n      \"caption\": \"Figure 9. The Payments page lists the billing groups that the current user account has access to\"\n    }\n  ]\n}\n[/block]\nClicking on the name of the billing group opens the **Current Usage** page. Here, the breakdown of computational jobs vs storage costs, and the total amount of funds remaining for a billing group are summarized.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/331429e-payments-page-detailed-view.png\",\n        \"payments-page-detailed-view.png\",\n        1343,\n        707,\n        \"#333\"\n      ],\n      \"caption\": \"Figure 10. The Current Usage page gives users a snapshot of available funds, charges for completed computational jobs, and total storage costs charged to a particular billing group.\"\n    }\n  ]\n}\n[/block]\nClicking on the **Spending Details** on the left side of the interface provides a breakdown of these charges at a per-project level. Using this information a user can clearly see which projects are responsible for large amounts of charges and projects which have negligible impact on their costs.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/ddfa28a-spending-details.png\",\n        \"spending-details.png\",\n        1523,\n        1052,\n        \"#333\"\n      ]\n    }\n  ]\n}\n[/block]\nUsing all of these built-in cost monitoring options allows you to understand your analysis and storage costs. If you have been awarded cloud credits, these pages also help you understand your costs relative to how many credits you have remaining in your billing group. This is helpful in budgeting, and prioritizing which projects and billing groups to utilize for ongoing analyses.\n\n##Funding your computational research\n\nThere are several options to provide funding information to cover your cloud costs. We aim for transparency in pricing, allowing you to directly see any costs passed to you without markup, we also aim for transparency in billing and making it easy to track these costs. Several funding mechanisms are available and described in more detail below. \n\n###Pilot funds\n\nAs a new user, you will receive $300 in credits for use on the CGC. The $300 credit allows you to use all the features of the CGC: you can create any number of projects, collaborate with as many people as you'd like, and execute full data analyses.\n\n###Budget for cloud costs in your grant\n\nResearchers who plan to work on cloud platforms should budget for cloud costs as part of their research proposals. We recommend writing a budget justification that provides information about anticipated storage and compute costs, with expected costs for the various kinds of analyses that will be performed. \n\n###Payment options\n\nIndividual users or labs can pay for their own cloud costs. Users can pre-pay for anticipated cloud costs or elect to “pay-as-you-go” and be billed on a monthly basis. To set up a billing group, contact [support:::at:::sevenbridges.com](mailto:[email protected]).\n\nPayments can be made by check, wire transfer, or credit card. Seven Bridges will create your billing group after you provide a point of contact for billing and their contact information; a title for the billing group; and your preferred payment method. If your organization needs a purchase order number on the invoice, please provide this as well.\n\n###To summarize\n\nBy keeping these principles in mind you can effectively estimate, budget for your analyses, and avoid any billing surprises. We welcome you to contact [[email protected]](mailto:[email protected]) if you have further questions about funding your research projects.","updates":[],"order":11,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"619e224ea4c5360243ba72f1","createdAt":"2021-11-24T11:30:22.361Z","user":"5dbff97bc91e080029778657","category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"TUTORIALS","slug":"tutorials","order":1,"from_sync":false,"reference":false,"_id":"56fbb83d8f21c817002af880","version":"55faf11ba62ba1170021a9aa","createdAt":"2016-03-30T11:27:57.862Z","__v":0,"project":"55faf11ba62ba1170021a9a7"},"version":{"version":"1.0","version_clean":"1.0.0","codename":"","is_stable":true,"is_beta":true,"is_hidden":false,"is_deprecated":false,"categories":["55faf11ca62ba1170021a9ab","55faf8f4d0e22017005b8272","55faf91aa62ba1170021a9b5","55faf929a8a7770d00c2c0bd","55faf932a8a7770d00c2c0bf","55faf94b17b9d00d00969f47","55faf958d0e22017005b8274","55faf95fa8a7770d00c2c0c0","55faf96917b9d00d00969f48","55faf970a8a7770d00c2c0c1","55faf98c825d5f19001fa3a6","55faf99aa62ba1170021a9b8","55faf99fa62ba1170021a9b9","55faf9aa17b9d00d00969f49","55faf9b6a8a7770d00c2c0c3","55faf9bda62ba1170021a9ba","5604570090ee490d00440551","5637e8b2fbe1c50d008cb078","5649bb624fa1460d00780add","5671974d1b6b730d008b4823","5671979d60c8e70d006c9760","568e8eef70ca1f0d0035808e","56d0a2081ecc471500f1795e","56d4a0adde40c70b00823ea3","56d96b03dd90610b00270849","56fbb83d8f21c817002af880","573c811bee2b3b2200422be1","576bc92afb62dd20001cda85","5771811e27a5c20e00030dcd","5785191af3a10c0e009b75b0","57bdf84d5d48411900cd8dc0","57ff5c5dc135231700aed806","5804caf792398f0f00e77521","58458b4fba4f1c0f009692bb","586d3c287c6b5b2300c05055","58ef66d88646742f009a0216","58f5d52d7891630f00fe4e77","59a555bccdbd85001bfb1442","5a2a81f688574d001e9934f5","5b080c8d7833b20003ddbb6f","5c222bed4bc358002f21459a","5c22412594a2a5005cc9e919","5c41ae1c33592700190a291e","5c8a525e2ba7b2003f9b153c","5cbf14d58c79c700ef2b502e","5db6f03a6e187c006f667fa4","5f894c7d3b0894006477ca01","6176d5bf8f59c6001038c2f7"],"_id":"55faf11ba62ba1170021a9aa","releaseDate":"2015-09-17T16:58:03.490Z","createdAt":"2015-09-17T16:58:03.490Z","project":"55faf11ba62ba1170021a9a7","__v":48},"project":"55faf11ba62ba1170021a9a7","__v":0,"parentDoc":null}

Estimate and manage your cloud costs


##Overview In this tutorial, you will learn how cloud costs are incurred on the CGC, and the steps you should take to estimate your project cloud costs in advance of scaling up analyses. Learning to estimate and manage your cloud costs will prepare you to effectively budget for your research projects. These estimates can be included in grant proposals, or be used to request cloud credits offered by the National Institutes of Health. ##Background The Platform is a [multi-cloud](https://www.sevenbridges.com/be-cloud-agnostic/) bioinformatics solution. This means that you can run compute jobs on regions of both Amazon Web Service (AWS) and Google Cloud Platform (GCP) (Figure 1). By running analyses on the cloud in the location where data is stored, it saves you time that would otherwise be spent copying large datasets. This multi-cloud functionality can also lead to cost savings, since data egress charges can be avoided. These concepts will be expanded upon throughout this tutorial. New Platform users may be accustomed to working with an on-site HPC system or local server. Local systems require a large investment in hardware, software, and maintenance, and these costs may seem invisible on a day-to-day basis. By comparison, cloud computing operates under a “pay as you go” model, where you are charged only for the resources you need, when you need them. This represents a cultural shift for performing computational research. However, by keeping some simple principles in mind, you can easily estimate and manage your cloud costs. [block:image] { "images": [ { "image": [ "https://files.readme.io/3d66d7b-Screenshot_2021-09-02_at_10.58.00.png", "Screenshot 2021-09-02 at 10.58.00.png", 682, 341, "#333" ], "caption": "Figure 1. CGC is a multi-cloud Platform where the cloud costs are passed directly to users.", "sizing": "original" } ] } [/block] One significant advantage of using the CGC for your computational research is that you can leverage existing datasets that are hosted in the cloud. CGC hosts the rich [The Cancer Genome Atlas (TCGA)](https://www.cancer.gov/about-nci/organization/ccg/research/structural-genomics/tcga) dataset. Hosted data is stored in the cloud and is made available to users on the CGC based on data access controls. This means that users can access the hosted data and run analyses on it without the need to spend time and resources downloading large datasets, or pay for storage costs. ##What will incur costs? When estimating the cost of using the CGC, there are two types of costs to keep in mind: 1. data storage, including inputs, outputs, intermediate files, and transfer of data; 2. computational costs of the analysis. Both types of costs will be explored in more detail below. ###Data Storage Storage costs are incurred by the user when files are stored on the CGC. Users can upload/import data to the CGC using several mechanisms (see documentation on [Uploading Data](doc:uploading-to-the-cgc)). Once the data is uploaded, data storage becomes an ongoing cost. The primary sources of storage costs include: 1. **Your own data** - Data uploaded to projects on the CGC through the GUI, API, or Seven Bridges Command Line Interface (CLI) are housed in storage buckets (AWS S3, or GCS) based on the cloud region assigned to a project at its creation. **Example**: A researcher uploads sequencing data in the form of `.fastq` files to the CGC. 2. **Workflow output data** - Files generated by running an analysis on uploaded or hosted data will incur storage costs. Running a workflow or tool on hosted data generates a derived file. This file derived from a hosted dataset will accrue storage costs the same way an uploaded file, or a file derived from an uploaded file, would. Example: You run a [fastqc workflow](https://cgc.sbgenomics.com/public/apps/admin/sbg-public-data/fastqc-analysis) on .fastq data uploaded to your project. The output .html report and .zip files from the workflow accrues storage costs in addition to the input .fastq file. **Example**: You merge two hosted .vcf files from a hosted study into a single, larger, .vcf file using [bcftools merge](https://cgc.sbgenomics.com/public/apps/admin/sbg-public-data/bcftools-merge). Only the output .vcf file accrues storage costs since the input vcf files were from hosted studies. **Note**: Transferring data out of the cloud incurs data egress charges set by the cloud provider. Both [AWS](https://aws.amazon.com/blogs/aws/aws-data-transfer-prices-reduced/) and [Google Cloud](https://cloud.google.com/storage/pricing#price-tables) charge for data egress and publish this information online. ### Computational jobs The second major source of cloud costs on the CGC is computational jobs. Computational jobs on the CGC are executed using AWS or GCP compute instances. Compute instances provide a defined model and number of CPU cores and memory (RAM) on which to execute a computational job. Pricing for instances is set by the cloud provider. The following costs are relevant to computational jobs: 1. **Workflow instance pricing** - Instances used to run workflows or tools are charged according to the type of instance and run-time of the job. Tools within a workflow may run on different instance types. Default instance types may also be overridden if a given computational job requires more resources. **Example**: When running a variant calling workflow, [different instance types](https://aws.amazon.com/ec2/instance-types/) are used for alignment and variant calling steps. The cost passed onto users is the total cost for the time spent on each instance. 2. **Interactive Notebook ([Data Cruncher](doc:about-data-cruncher)) instance pricing** - The CGC offers Jupyterlab Notebooks, RStudio, and SAS as part of the Data Cruncher feature. These environments enable users to perform iterative, interactive, and data visualization tasks on the cloud where their data is already located. Each environment has a default instance type set for launching a notebook; however, users can customize the instance type if they require more CPUs or memory. Data Cruncher instances are billed by the type of instance and the time used. **Example**: After running various workflows, you want to both explore the dataset and generate summary figures using R or Python in an interactive notebook. The cost passed on to you is the total cost for time spent on each instance. **Note**: A minor component of the computational costs passed on to users is the storage of temporary files on compute instances. These temporary runtime files are not saved to the user’s project at the completion of a computational job. These temporary storage costs, often a minor fraction of the compute costs for a given job, are included in the cost for the computational job and may be queried using the Seven Bridges API through the R or Python libraries. ##Steps to estimate cloud costs Estimating your storage and compute costs begins with understanding your data. The section below provides guidance on how to estimate compute costs for Common Workflow Language (CWL) tools and workflows offered on the CGC, as well as for user-created custom CWL tools. This section also explains how to estimate costs when working in interactive notebooks, and how to estimate storage costs. Examples are provided for all scenarios. ###Understand your data The first step to estimate your analysis and storage costs is to understand your data by answering the following questions: **Where is your data located?** Is your data hosted, or will it be uploaded to the CGC? This has consequences for how much you should expect for storage costs. **How big is your data?** The size of data can vary dramatically depending on many factors, including what type of files they are. It is important to remember that using an “average” file size means that some files will be larger or smaller than that average, and this variation can be significant. We recommend understanding the range of data sizes, and how many files there are, in addition to the average size for both your input and output data files. **How long will your data be stored on the CGC?** Some files, like workflow outputs that are very time-consuming, are potentially expensive to regenerate, and may be important to store on the CGC for a long period of time. However, if a file is quick and/or inexpensive to regenerate, or if it is a raw data file that can be easily reacquired from its source, it may be reasonable to delete it rather than store it. The costs of regenerating a file are often less than the costs of storage in cloud computing. By thoroughly understanding the types of data you plan on analyzing, you can eliminate many sources of uncertainty. ###Estimate tool/workflow costs Running CWL tools and workflows are one of the main sources of costs on the CGC, and it is relatively straightforward to estimate the cost for these computational jobs. How we recommend doing this varies depending on whether you use pre-configured CWL apps from the Public Apps Gallery, or custom developed CWL workflows and tools. ####Benchmarking for tools and workflows from the Public Apps Gallery The CGC [Public Apps Gallery](https://cgc.sbgenomics.com/public/apps) hosts hundreds of popular bioinformatics tools. Each tool and workflow includes a detailed description and benchmarking information for time, computation, and cost. This benchmarking information can be used to estimate your anticipated costs for using that tool or a similar custom tool. To estimate costs, we recommend plotting the run-time and/or cost compared to the input file size. This will also enable you to see whether or not the runtime or cost of the tool scales linearly. We suggest rounding your estimates up by a minimum of 30% over the calculated cost to anticipate any issues that should arise, rerunning with different settings, unexpected workflow failures due to problems with the input files, etc. For accurate estimations, we recommend running a representative set of files you plan to use for analysis, then extrapolating the costs from the results. [block:image] { "images": [ { "image": [ "https://files.readme.io/a63c189-Screenshot_2021-09-06_at_10.15.31.png", "Screenshot 2021-09-06 at 10.15.31.png", 935, 182, "#eaeaec" ], "caption": "Figure 2. Benchmarking information from the RNA-seq alignment - STAR 2.5.4b workflow.", "sizing": "original" } ] } [/block] **Example**: You plan to run the STAR RNAseq alignment workflow on 4 samples to assay highly-expressed genes, each of the samples are paired-end. Each file is roughly 4 GB in size, which is nearly the middle scenario detailed in the benchmarking information in Figure 2 above. This adds up to $0.60 x 4 = $2.40. We recommend planning for unforeseen problems (like failed Task runs), and adding an additional 30%, totaling $3.12. When extrapolating beyond the bounds of the benchmarking information it is important to understand whether the particular app scales linearly. For apps that scale linearly, plotting the benchmarking information and fitting a line to the data will provide a reasonable estimate of the run cost. Note that these benchmarks hold true for the instance types provided in the benchmarking table. If the user changes the instance type, then these benchmarks will no longer be accurate. ####Benchmarking apps on your data While benchmarking information available on the CGC is a helpful budgeting tool, we recommend testing with your actual data. This is necessary when bringing your own CWL apps to the CGC, and when running apps from the **Public Apps Gallery** that lack sufficient benchmarking information. In this situation we recommend the following: 1. **Pick a representative but small subset of files** - in addition to picking a small subset, make sure that it captures the range of input file sizes seen in the real set of files. If your input files vary dramatically in size, you want to make sure that you don’t ignore this fact and underestimate the cost to run the full set. 2. **Run this subset of analyses to create your own benchmarking information for your tool** - After running, use the cost monitoring tools detailed in earlier sections to summarize the cost of this smaller set of files. 3. **Scale up the cost to the larger full set of files you wish to run** - Example: You have 40 pairs of whole-genome bisulfite sequencing fastq files to process using a CWL workflow. The files vary in size from 2 GB to 40 GB, distributed around an average of 20 GB. You select a subset of 5 pairs of fastqs that have a similar range of sizes and the same average size. You then run the workflow on these samples. The average cost of the tasks was $50. Using the average task price you then scale up to the remaining 35 tasks with $1,750 in expected workflow execution costs. To account for unexpected errors or issues that might arise, we recommend adding a 30% buffer and budgeting a total of $2,275. ###Estimate Data Cruncher interactive notebook costs [Data Cruncher](doc:about-data-cruncher) is an interactive analysis tool, bringing Jupyter, RStudio, and SAS to the Seven Bridges cloud Platform. Calculating costs for running an interactive notebook in Data Cruncher depends only on the instance type and time spent in the environment to perform your analysis. **Example**: You have prototyped an analysis locally and determined that the default AWS c5.2xlarge instance will suit your needs. The current pricing for this instance is $0.48 per hour and you expect to explore this dataset for approximately 3 hours. This will incur $1.44 in expenses, which we will increase to $1.88 to account for unexpected findings which make your analysis take extra time. **Note**: Data Cruncher sessions can be set-up to continue running even if your web browser is no longer viewing the page. While this is useful for long-running analyses, it will continue accruing costs until the Data Cruncher session is closed. For this reason, the default settings for Data Cruncher include a time-out. Be careful to make sure you end an analysis when desired if you disable this feature. ###Estimate Storage Costs Storage is an ongoing cost. This means that monthly storage costs will be charged to the billing group associated with a given project housing the files in question. Hosted data does not incur charges, but files derived from hosted data do. If files are copied between multiple projects, you are only charged once for each file, as long as the projects are a part of the same billing group. The best way to understand how much data is stored in a project is to [export a manifest](doc:format-of-a-manifest-file) from the Files tab and calculate the cumulative file size. Please note whether you have duplicated data in your project since this could result in overestimation. **Example**: You have 5 TB of derived data stored in a project with the location set to AWS-us-east-1. Seven Bridges data incurs $0.021 per GB per month in storage costs for the AWS-us-east-1 cloud location. Therefore, you would expect 5000 GB x $0.021 = $105 to be your monthly storage price. ##Best practices for efficient cloud computing By following some simple best practices you can reduce your cloud costs, sometimes dramatically. ###Tools and Workflows ####Efficient workflow design * **Re-use rather than re-compute intermediate files** - In certain situations, it makes sense to create multiple versions of workflows that allow starting from an intermediate step. This allows you to avoid repeating computationally-intensive steps in an analysis to do a different downstream processing step. **Example**: You have a complex whole-exome sequencing workflow. There are several steps run to call variants on an input .bam file after read alignment to the reference genome. There are also quality control checks to perform on the .bam file. It makes sense to split up the workflow: one workflow to perform read alignment, outputting a .bam file and any QC metrics you wish to use, and another workflow to perform the downstream variant calling steps. This is more efficient than repeating the alignment step again to call the variants. * **Use appropriate instance types** - the CGC allows you to choose instance types for each step in a workflow, as well as override the default options. If you understand the size of data you are working with, you may be able to reduce the price by choosing a cheaper instance. Likewise, you don’t need to select larger instances with features (GPUs for example) or storage in excess of what you need. [block:image] { "images": [ { "image": [ "https://files.readme.io/26492f6-choosing-custom-instance0type.png", "choosing-custom-instance0type.png", 992, 278, "#333" ], "caption": "Figure 3. Selecting a custom instance will change the price that you are charged for running a workflow.", "sizing": "full" } ] } [/block] * **Use multithreading options where available** - Many tools within workflows have options for multithreading. It is usually advisable to saturate the available CPU cores/threads on a given instance. This will reduce the run-time, and therefore price, of your job. * **Use scattering and batching** - Batching will enable you to group workflow runs over a large number of input files based on the files themselves, or a metadata field that is associated with that file. This optimizes your workflows for run-time, enabling many workflow runs to be carried out simultaneously, without needing to manually click through the job submission page multiple times. Scattering is configured within the CWL of the workflow itself. A tool is passed a list of inputs on one port, and one job will be created on the same instance for each input in the list. This helps saturate the available resources on an instance, making sure you are taking advantage of all the compute power that you are paying for. [block:image] { "images": [ { "image": [ "https://files.readme.io/c6127cc-Screenshot_2021-09-06_at_16.53.24.png", "Screenshot 2021-09-06 at 16.53.24.png", 743, 356, "#f3f6f1" ], "caption": "Figure 4. Scattering a workflow saturates available CPU cores on this AWS instance.", "sizing": "original" } ] } [/block] * **Use preemptible instances** - By default, instances use on-demand pricing. However, they can also be configured to use [“spot” instances](doc:about-spot-instances). These are preemptible based on bid price and demand. Their pricing does fluctuate, however, it is typically much cheaper than on-demand pricing. There is very little downside to using them on the CGC, as there is a built-in retry mechanism. If your job or a portion of your workflow) is interrupted, it will be retried at on-demand pricing. * **Turn on memoization** - [Memoization](doc:about-memoization) allows you to reuse pre-computed inputs to workflow steps. This is relevant if you are running a long workflow and it fails due to a step late in the workflow. In this situation, if memoization is turned on the workflow would restart from the point at which it failed, using the intercreatemediate files saved to the instance, potentially saves money and time. [block:image] { "images": [ { "image": [ "https://files.readme.io/355f797-create-a-project.png", "create-a-project.png", 591, 640, "#333" ], "caption": "Figure 5. Spot instances and memoization can be turned on from the project creation dialog. They are also configurable per task, or within the project settings after creation." } ] } [/block] ###Data Cruncher interactive analysis Data Cruncher is best used for quick, interactive work, such as when you want to explore a dataset, create a visualization, or prototype workflows. Spot instances are not available in Data Cruncher due to their interactive nature. **Select an appropriate instance type** As with workflow tasks, Data Cruncher costs will heavily depend on the instance type that you select at task creation. This is able to be selected from the task creation dialog. [block:image] { "images": [ { "image": [ "https://files.readme.io/034af79-create-new-data-cruncher-analysis.png", "create-new-data-cruncher-analysis.png", 556, 476, "#333" ], "caption": "Figure 6. Data Cruncher instance type selection." } ] } [/block] **Keep the suspend timer turned on** The suspend time feature keeps your task from running over an extended period unexpectedly. Without it, the instance will continue running until it is shut down by a user, even if your browser closes (it is running on a cloud instance hosted by AWS or GCP). **Consider porting repeated tasks to CWL workflows** While a one-off analysis in Data Cruncher with interactive visualizations can be a great way to understand and explore your data, this can become limiting if you are running the same tasks many times. Due to the lack of spot instance availability with interactive analysis, it makes sense to turn commonly performed tasks into workflows described with CWL. ###Storage While straightforward to calculate, storage can add up to a large expense. This is especially true when you run several tasks and output files begin to grow within your projects. * **Delete unused files or ones which are cheap to regenerate** - Rather than saving everything, when it is safe to delete a file, whether that is because it is no longer needed or is cheap to generate again through a workflow or tool, delete it. * **Use compressed files when possible** - Many common file formats have a compressed variant. Or they can be compressed into a .zip or .gz file. Common examples include .fastq.gz (vs .fastq), .bam (vs .sam), or .bcf (.vcf). * **Remember where your data is located** - While multiple copies of the same file do not incur additional charges, this also means that you will continue being charged for a file until every copy of it in various projects is deleted. * **Use [Volumes](doc:volumes) to bring data to the CGC** - Users can avoid being charged for storage by the Platform if their data is already hosted on AWS S3 or Google Cloud Storage and they connect that existing storage using the Volumes feature. In this situation, users would pay AWS or Google Cloud Platform directly. This can be useful to avoid being charged again for data already hosted on one of those cloud platforms. ##Cost tracking on the CGC The CGC enables you to monitor your cloud costs at the level of individual analyses (tasks), projects, and billing groups. Each will be explained in more detail below. ###Cost monitoring at the task level The CGC shows the cost incurred by all tasks (workflows and tools) which are finished running, whether these tasks completed successfully or ended with an error. The Task summary pages remain indefinitely within the project including the cost information. [block:image] { "images": [ { "image": [ "https://files.readme.io/0d4f550-task-price-showin-on-task-page.jpg", "task-price-showin-on-task-page.jpg", 931, 549, "#333" ], "caption": "Figure 7. The Task price is shown in the top section of the Task page" } ] } [/block] ###Cost monitoring at the project and billing group levels To see more detailed cost summaries, you can navigate to the Payments page by clicking on your user name on the top right corner of the interface. [block:image] { "images": [ { "image": [ "https://files.readme.io/26dca39-accessing-the-payments-page.jpg", "accessing-the-payments-page.jpg", 609, 338, "#333" ], "caption": "Figure 8. Finding the Payments page." } ] } [/block] The Payments page shows the billing groups of which you are currently a member. All users start off with a Pilot Funds billing group. [block:image] { "images": [ { "image": [ "https://files.readme.io/484fcea-pilot-funds.jpg", "pilot-funds.jpg", 708, 336, "#333" ], "caption": "Figure 9. The Payments page lists the billing groups that the current user account has access to" } ] } [/block] Clicking on the name of the billing group opens the **Current Usage** page. Here, the breakdown of computational jobs vs storage costs, and the total amount of funds remaining for a billing group are summarized. [block:image] { "images": [ { "image": [ "https://files.readme.io/331429e-payments-page-detailed-view.png", "payments-page-detailed-view.png", 1343, 707, "#333" ], "caption": "Figure 10. The Current Usage page gives users a snapshot of available funds, charges for completed computational jobs, and total storage costs charged to a particular billing group." } ] } [/block] Clicking on the **Spending Details** on the left side of the interface provides a breakdown of these charges at a per-project level. Using this information a user can clearly see which projects are responsible for large amounts of charges and projects which have negligible impact on their costs. [block:image] { "images": [ { "image": [ "https://files.readme.io/ddfa28a-spending-details.png", "spending-details.png", 1523, 1052, "#333" ] } ] } [/block] Using all of these built-in cost monitoring options allows you to understand your analysis and storage costs. If you have been awarded cloud credits, these pages also help you understand your costs relative to how many credits you have remaining in your billing group. This is helpful in budgeting, and prioritizing which projects and billing groups to utilize for ongoing analyses. ##Funding your computational research There are several options to provide funding information to cover your cloud costs. We aim for transparency in pricing, allowing you to directly see any costs passed to you without markup, we also aim for transparency in billing and making it easy to track these costs. Several funding mechanisms are available and described in more detail below. ###Pilot funds As a new user, you will receive $300 in credits for use on the CGC. The $300 credit allows you to use all the features of the CGC: you can create any number of projects, collaborate with as many people as you'd like, and execute full data analyses. ###Budget for cloud costs in your grant Researchers who plan to work on cloud platforms should budget for cloud costs as part of their research proposals. We recommend writing a budget justification that provides information about anticipated storage and compute costs, with expected costs for the various kinds of analyses that will be performed. ###Payment options Individual users or labs can pay for their own cloud costs. Users can pre-pay for anticipated cloud costs or elect to “pay-as-you-go” and be billed on a monthly basis. To set up a billing group, contact [[email protected]](mailto:[email protected]). Payments can be made by check, wire transfer, or credit card. Seven Bridges will create your billing group after you provide a point of contact for billing and their contact information; a title for the billing group; and your preferred payment method. If your organization needs a purchase order number on the invoice, please provide this as well. ###To summarize By keeping these principles in mind you can effectively estimate, budget for your analyses, and avoid any billing surprises. We welcome you to contact [[email protected]](mailto:[email protected]) if you have further questions about funding your research projects.