Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Beef up io budget section

Joshen Lim3ae477b52e18
diff --git a/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx b/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx
index 72e4c55b783..24ca3600f6d 100644
--- a/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx
@@ -2,10 +2,14 @@ import ShimmeringLoader from 'components/ui/ShimmeringLoader'
import { useInfraMonitoringQuery } from 'data/analytics/infra-monitoring-query'
import { useProjectSubscriptionQuery } from 'data/subscriptions/project-subscription-query'
import dayjs from 'dayjs'
-import UsageBarChart from './UsageBarChart'
+import { PRICING_TIER_PRODUCT_IDS } from 'lib/constants'
+import Link from 'next/link'
+import { Alert, Button } from 'ui'
import SectionContent from './SectionContent'
import SectionHeader from './SectionHeader'
-import { USAGE_CATEGORIES } from './Usage.constants'
+import { COMPUTE_INSTANCE_SPECS, USAGE_CATEGORIES } from './Usage.constants'
+import { getUpgradeUrl } from './Usage.utils'
+import UsageBarChart from './UsageBarChart'
export interface InfrastructureProps {
projectRef: string
@@ -20,6 +24,14 @@ const Infrastructure = ({ projectRef }: InfrastructureProps) => {
const endDate = new Date((current_period_end ?? 0) * 1000).toISOString()
const categoryMeta = USAGE_CATEGORIES.find((category) => category.key === 'infra')
+ const upgradeUrl = getUpgradeUrl(projectRef, subscription)
+ const isFreeTier = subscription?.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.FREE
+ const currentComputeInstance = subscription?.addons.find((addon) =>
+ addon.supabase_prod_id.includes('_instance_')
+ )
+ const currentComputeInstanceSpecs =
+ COMPUTE_INSTANCE_SPECS[currentComputeInstance?.supabase_prod_id ?? 'addon_instance_micro']
+
const { data: cpuUsageData, isLoading: isLoadingCpuUsageData } = useInfraMonitoringQuery({
projectRef,
attribute: 'cpu_usage',
@@ -44,6 +56,12 @@ const Infrastructure = ({ projectRef }: InfrastructureProps) => {
endDate,
})
+ const currentDayIoBudget = Number(
+ ioBudgetData?.data.find((x) => x.periodStartFormatted === dayjs().format('DD MMM'))?.[
+ 'disk_io_budget'
+ ] ?? 0
+ )
+
const chartMeta: any = {
cpu_usage: {
isLoading: isLoadingCpuUsageData,
@@ -81,8 +99,40 @@ const Infrastructure = ({ projectRef }: InfrastructureProps) => {
return (
<SectionContent key={attribute.key} section={attribute} lastKnownValue={lastKnownValue}>
{attribute.key === 'disk_io_budget' && (
- // [Joshen] Eventually should show the overview of the io bandwidth in mbps for burst, baseline and duration
<>
+ {/* The condition should be that if the disk io budget for TODAY has crossed some threshold */}
+ {currentDayIoBudget <= 0 ? (
+ <Alert withIcon variant="danger" title="IO Budget for today has been used up">
+ <p className="mb-4">
+ Your workload has used up all the burst IO throughput minutes during the day
+ and is running at the baseline performance. If you need consistent disk
+ performance, consider upgrading to a larger compute add-on.
+ </p>
+ <Link href={upgradeUrl}>
+ <a>
+ <Button type="danger">
+ {isFreeTier ? 'Upgrade project' : 'Change compute add-on'}
+ </Button>
+ </a>
+ </Link>
+ </Alert>
+ ) : currentDayIoBudget <= 20 ? (
+ <Alert withIcon variant="warning" title="IO Budget for today is running out">
+ <p className="mb-4">
+ Your workload is about to use up all the burst IO throughput minutes during
+ the day. Once this is completely used up, your workload will run at the
+ baseline performance. If you need consistent disk performance, consider
+ upgrading to a larger compute add-on.
+ </p>
+ <Link href={upgradeUrl}>
+ <a>
+ <Button type="warning">
+ {isFreeTier ? 'Upgrade project' : 'Change compute add-on'}
+ </Button>
+ </a>
+ </Link>
+ </Alert>
+ ) : null}
<div className="space-y-1">
<p>What is Disk IO Bandwidth?</p>
<p className="text-sm text-scale-1000">
@@ -91,6 +141,29 @@ const Infrastructure = ({ projectRef }: InfrastructureProps) => {
bandwidth.
</p>
</div>
+ <div>
+ <p className="text-sm mb-2">Overview</p>
+ <div className="flex items-center justify-between border-b py-1">
+ <p className="text-xs text-scale-1000">Current compute instance</p>
+ <p className="text-xs">{currentComputeInstance?.name ?? 'Micro'}</p>
+ </div>
+ <div className="flex items-center justify-between border-b py-1">
+ <p className="text-xs text-scale-1000">Maximum IO Bandwidth (burst limit)</p>
+ <p className="text-xs">
+ {currentComputeInstanceSpecs.maxBandwidth.toLocaleString()} Mbps
+ </p>
+ </div>
+ <div className="flex items-center justify-between border-b py-1">
+ <p className="text-xs text-scale-1000">Baseline IO Bandwidth</p>
+ <p className="text-xs">
+ {currentComputeInstanceSpecs.baseBandwidth.toLocaleString()} Mbps
+ </p>
+ </div>
+ <div className="flex items-center justify-between py-1">
+ <p className="text-xs text-scale-1000">Daily burst time limit</p>
+ <p className="text-xs">30 mins</p>
+ </div>
+ </div>
</>
)}
<div className="space-y-1">
diff --git a/studio/components/interfaces/BillingV2/Usage/Usage.constants.ts b/studio/components/interfaces/BillingV2/Usage/Usage.constants.ts
index d94ba87c7f7..7fadb438b6a 100644
--- a/studio/components/interfaces/BillingV2/Usage/Usage.constants.ts
+++ b/studio/components/interfaces/BillingV2/Usage/Usage.constants.ts
@@ -182,3 +182,49 @@ export const USAGE_CATEGORIES: {
],
},
]
+
+// [Joshen] Ideally live in common package for www as well
+export const COMPUTE_INSTANCE_SPECS: {
+ [key: string]: { maxBandwidth: number; baseBandwidth: number }
+} = {
+ addon_instance_micro: {
+ maxBandwidth: 2606,
+ baseBandwidth: 87,
+ },
+ addon_instance_small: {
+ maxBandwidth: 2606,
+ baseBandwidth: 174,
+ },
+ addon_instance_medium: {
+ maxBandwidth: 2606,
+ baseBandwidth: 347,
+ },
+ addon_instance_large: {
+ maxBandwidth: 4750,
+ baseBandwidth: 630,
+ },
+ addon_instance_xlarge: {
+ maxBandwidth: 4750,
+ baseBandwidth: 1188,
+ },
+ addon_instance_xxlarge: {
+ maxBandwidth: 4750,
+ baseBandwidth: 2375,
+ },
+ addon_instance_4xlarge: {
+ maxBandwidth: 4750,
+ baseBandwidth: 4750,
+ },
+ addon_instance_8xlarge: {
+ maxBandwidth: 9500,
+ baseBandwidth: 9500,
+ },
+ addon_instance_12xlarge: {
+ maxBandwidth: 14250,
+ baseBandwidth: 14250,
+ },
+ addon_instance_16xlarge: {
+ maxBandwidth: 19000,
+ baseBandwidth: 19000,
+ },
+}
diff --git a/studio/components/interfaces/BillingV2/Usage/Usage.utils.ts b/studio/components/interfaces/BillingV2/Usage/Usage.utils.ts
index c49951945c7..d4286819f02 100644
--- a/studio/components/interfaces/BillingV2/Usage/Usage.utils.ts
+++ b/studio/components/interfaces/BillingV2/Usage/Usage.utils.ts
@@ -42,5 +42,7 @@ export const getUpgradeUrl = (projectRef: string, subscription?: StripeSubscript
? `/project/${projectRef}/settings/billing/update/enterprise`
: subscription?.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.TEAM
? `/project/${projectRef}/settings/billing/update/team`
+ : subscription?.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.FREE
+ ? `/project/${projectRef}/settings/billing/update`
: `/project/${projectRef}/settings/billing/update/pro`
}