Skip to content

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

1.1 KB
Raw Blame
import {
  COMPUTE_LABELS,
  THROUGHPUT_TABLE_HEADINGS,
} from '../../components/RealtimeLimitsEstimator/RealtimeLimitsEstimator.constants'
import throughputTable from '../../data/realtime/throughput.json'

type Row = {
  computeAddOn: string
  rls: boolean
  concurrency: number
  maxDBChanges: number
  maxMessagesPerClient: number
  totalMessagesPerSecond: number
  p95Latency: number
}

const headerRow = `| ${THROUGHPUT_TABLE_HEADINGS.join(' | ')} |`
const dividerRow = `| ${THROUGHPUT_TABLE_HEADINGS.map(() => '---').join(' | ')} |`

const renderGroup = (computeAddOn: string): string => {
  const rows = (throughputTable as Row[]).filter((l) => l.computeAddOn === computeAddOn)
  return `#### ${COMPUTE_LABELS[computeAddOn] ?? computeAddOn}

${headerRow}
${dividerRow}
${rows
  .map(
    (l) =>
      `| ${l.rls ? 'Yes' : 'No'} | ${l.concurrency.toLocaleString()} | ${l.maxDBChanges} | ${l.maxMessagesPerClient} | ${l.totalMessagesPerSecond.toLocaleString()} | ${l.p95Latency}ms |`
  )
  .join('\n')}`
}

export const RealtimeLimitsEstimator = (): string =>
  [...new Set((throughputTable as Row[]).map((l) => l.computeAddOn))].map(renderGroup).join('\n\n')