# DCU calculation

DCU (DataFlint Compute Unit) Is measurement unit for spark usage, which is a similar concept to DBU (DataBricks Unit)

The formula for DCU is: (Core/Hour usage \* 0.05) + (GiB Memory/Hour usage \* 0.005)

**Core/Hour:** is the number of cores allocated for your app in hours measurement.\
For example: Application that allocated 1 core for one hour will consume 1 core/hour, which will be the same as an application that allocated 6 cores for 10 minutes.

**GiB Memory/Hour:** is the number of memory in GiB units allocated for your app in hours measurement\
For example: Application that allocated 1 GiB for one hour will consume 1 GiB memory/hour, which will be the same as an application that allocated 6 GiB for 10 minutes.

**Core/hour and GiB memory/hour ratios:**  because we want to look at app resource usage as one metric and not as 2 (core/hour and GiB memory/hour) we need a formula to convert this 2 metrics into 1 metric. We chose for the ratio to multiply each metric is the EMR serverless cost in US East for X86 server, and removed round it up to get more easy-to-understand numbers (0.052624 -> 0.05, 0.0057785 -> 0.005)

<figure><img src="https://2982210886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fcg8pTm3VgVaeMncRl8LP%2Fuploads%2FjwZq1EnZ7QYjoWw5lqOI%2Fimage.png?alt=media&#x26;token=25abb718-0345-4d71-a6d3-e67e6962f093" alt=""><figcaption><p>See <a href="https://aws.amazon.com/emr/pricing/">https://aws.amazon.com/emr/pricing/</a></p></figcaption></figure>

So 1 DFU if using EMR serverless will roughly cost 1$. On other platforms is still a good base unit to compare app's performance, but will not be equal to exactly 1$.

**Example calculation:** 100 core/hour usage and 1000 GiB memory/hour usage is (100 \* 0.05) + (1000 \* 0.005) = 10 DCU

**Example from DataFlint UI:**

<figure><img src="https://2982210886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fcg8pTm3VgVaeMncRl8LP%2Fuploads%2F2iE5LCYCWHrm2yrql3BI%2Fimage.png?alt=media&#x26;token=64d48897-c926-4a37-8af7-bfbcb033ae13" alt="" width="330"><figcaption></figcaption></figure>
