import throughputTable from '~/data/realtime/throughput.json'
import { ChevronDown } from 'lucide-react'
import { useState } from 'react'
import {
cn,
Collapsible,
CollapsibleContent,
CollapsibleTrigger,
Label,
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
Table,
} from 'ui'
import {
COMPUTE_LABELS,
COMPUTE_OPTIONS,
THROUGHPUT_METRIC_HEADINGS,
THROUGHPUT_TABLE_HEADINGS,
} from './RealtimeLimitsEstimator.constants'
export default function RealtimeLimitsEstimater({}) {
const findTableValue = ({ computeAddOn, rls, concurrency }) => {
return throughputTable.find(
(l) => l.computeAddOn === computeAddOn && l.rls === rls && l.concurrency === concurrency
)
}
const [computeAddOn, setComputeAddOn] = useState('micro')
const [rls, setRLS] = useState(false)
const [concurrency, setConcurrency] = useState(500)
const [limits, setLimits] = useState(findTableValue({ computeAddOn, rls, concurrency }))
const [expandPreview, setExpandPreview] = useState(false)
const handleComputeAddOnSelection = (val) => {
setComputeAddOn(val)
setConcurrency(500)
setLimits(findTableValue({ computeAddOn: val, rls, concurrency: 500 }))
}
const handleRLSSelection = (value) => {
const val = value.toLowerCase() === 'true'
setRLS(val)
setConcurrency(500)
setLimits(findTableValue({ computeAddOn, rls: val, concurrency: 500 }))
}
const handleConcurrencySelection = (value) => {
const val = parseInt(value)
setConcurrency(val)
setLimits(findTableValue({ computeAddOn, rls, concurrency: val }))
}
return (
Set your expected parameters
{limits && (
Current maximum possible throughput
{THROUGHPUT_METRIC_HEADINGS.map((heading) => (
|
{heading}
|
))}
| {limits.maxDBChanges} |
{limits.maxMessagesPerClient} |
{Intl.NumberFormat().format(limits.totalMessagesPerSecond)}
|
{limits.p95Latency}ms |
)}
View raw throughput table
{throughputTable
.map((l) => l.computeAddOn)
.filter((v, i, a) => a.indexOf(v) === i)
.map((computeAddOn) => (
{COMPUTE_LABELS[computeAddOn]}
{THROUGHPUT_TABLE_HEADINGS.map((heading) => (
|
{heading}
|
))}
{throughputTable
.filter((l) => l.computeAddOn === computeAddOn)
.map((l) => (
| {l.rls ? '✅' : '🚫'} |
{Intl.NumberFormat().format(l.concurrency)}
|
{l.maxDBChanges} |
{l.maxMessagesPerClient} |
{Intl.NumberFormat().format(l.totalMessagesPerSecond)}
|
{l.p95Latency}ms |
))}
))}
)
}