Skip to content

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

fix: add messages per second limit to realtime settings (#39235)

Filipe Cabaçoad7c66a6421d
diff --git a/apps/docs/content/guides/realtime/settings.mdx b/apps/docs/content/guides/realtime/settings.mdx
index 9675d92b5bb..5ea09ac0028 100644
--- a/apps/docs/content/guides/realtime/settings.mdx
+++ b/apps/docs/content/guides/realtime/settings.mdx
@@ -27,3 +27,4 @@ You can set the following settings using the Realtime Settings screen in your Da
- Database connection pool size: Determines the number of connections used for Realtime Authorization RLS checking
{/* supa-mdx-lint-disable-next-line Rule004ExcludeWords */}
- Max concurrent clients: Determines the maximum number of clients that can be connected
+- Max events per second: Determines the maximum number of events per second that can be sent
diff --git a/apps/docs/public/img/guides/platform/realtime/realtime-settings--dark.png b/apps/docs/public/img/guides/platform/realtime/realtime-settings--dark.png
index b9ee8747b55..8d3d73e420b 100644
Binary files a/apps/docs/public/img/guides/platform/realtime/realtime-settings--dark.png and b/apps/docs/public/img/guides/platform/realtime/realtime-settings--dark.png differ
diff --git a/apps/docs/public/img/guides/platform/realtime/realtime-settings--light.png b/apps/docs/public/img/guides/platform/realtime/realtime-settings--light.png
index 3587df9ebd2..fbb18d03013 100644
Binary files a/apps/docs/public/img/guides/platform/realtime/realtime-settings--light.png and b/apps/docs/public/img/guides/platform/realtime/realtime-settings--light.png differ
diff --git a/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx b/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx
index 606d9df0910..26071ec4cd8 100644
--- a/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx
+++ b/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx
@@ -86,8 +86,8 @@ export const RealtimeSettings = () => {
.min(1)
.max(maxConn?.maxConnections ?? 100),
max_concurrent_users: z.coerce.number().min(1).max(50000),
+ max_events_per_second: z.coerce.number().min(1).max(10000),
// [Joshen] These fields are temporarily hidden from the UI
- // max_events_per_second: z.coerce.number().min(1).max(50000),
// max_bytes_per_second: z.coerce.number().min(1).max(10000000),
// max_channels_per_client: z.coerce.number().min(1).max(10000),
// max_joins_per_second: z.coerce.number().min(1).max(5000),
@@ -117,6 +117,7 @@ export const RealtimeSettings = () => {
private_only: !data.allow_public,
connection_pool: data.connection_pool,
max_concurrent_users: data.max_concurrent_users,
+ max_events_per_second: data.max_events_per_second,
})
}
@@ -245,6 +246,36 @@ export const RealtimeSettings = () => {
Max concurrent clients
</FormSectionLabel>
}
+ >
+ <FormSectionContent loaders={1} loading={isLoading} className="!gap-y-2">
+ <FormControl_Shadcn_>
+ <Input_Shadcn_ {...field} type="number" value={field.value || ''} />
+ </FormControl_Shadcn_>
+ <FormMessage_Shadcn_ />
+ </FormSectionContent>
+ </FormSection>
+ )}
+ />
+ </CardContent>
+ <CardContent>
+ <FormField_Shadcn_
+ control={form.control}
+ name="max_events_per_second"
+ render={({ field }) => (
+ <FormSection
+ className="!p-0 !py-2"
+ header={
+ <FormSectionLabel
+ description={
+ <p className="text-foreground-lighter text-sm !mt-1">
+ Sets maximum number of events per second that can be sent to your
+ Realtime service
+ </p>
+ }
+ >
+ Max events per second
+ </FormSectionLabel>
+ }
>
<FormSectionContent loaders={1} loading={isLoading} className="!gap-y-2">
<FormControl_Shadcn_>
@@ -270,7 +301,7 @@ export const RealtimeSettings = () => {
</p>
</div>
<div className="flex-grow flex items-center justify-end">
- {false ? (
+ {isFreePlan ? (
<UpgradePlanButton source="realtimeSettings" plan="Pro" />
) : (
<ToggleSpendCapButton />
@@ -287,46 +318,11 @@ export const RealtimeSettings = () => {
{/*
[Joshen] The following fields are hidden from the UI temporarily while we figure out what settings to expose to the users
- - Max events per second
- Max bytes per second
- Max channels per client
- Max joins per second
*/}
- {/* <CardContent>
- <FormField_Shadcn_
- control={form.control}
- name="max_events_per_second"
- render={({ field }) => (
- <FormSection
- className="!p-0 !py-2"
- header={
- <FormSectionLabel
- description={
- <p className="text-foreground-lighter text-sm !mt-1">
- Sets maximum number of events per second rate per channel limit
- </p>
- }
- >
- Max events per second
- </FormSectionLabel>
- }
- >
- <FormSectionContent loading={isLoading} className="!gap-y-2">
- <FormControl_Shadcn_>
- <Input_Shadcn_
- {...field}
- type="number"
- disabled={!canUpdateConfig}
- value={field.value || ''}
- />
- </FormControl_Shadcn_>
- <FormMessage_Shadcn_ />
- </FormSectionContent>
- </FormSection>
- )}
- />
- </CardContent> */}
{/* <CardContent>
<FormField_Shadcn_
control={form.control}
@@ -440,6 +436,7 @@ export const RealtimeSettings = () => {
)}
/>
</CardContent> */}
+
<CardFooter className="justify-between">
<div>
{isPermissionsLoaded && !canUpdateConfig && (
diff --git a/apps/studio/pages/project/[ref]/realtime/settings.tsx b/apps/studio/pages/project/[ref]/realtime/settings.tsx
index 664d64d0376..5cffb3785b0 100644
--- a/apps/studio/pages/project/[ref]/realtime/settings.tsx
+++ b/apps/studio/pages/project/[ref]/realtime/settings.tsx
@@ -9,11 +9,7 @@ import { DocsButton } from 'components/ui/DocsButton'
import { DOCS_URL } from 'lib/constants'
const RealtimePoliciesPage: NextPageWithLayout = () => {
- return (
- <ScaffoldContainer>
- <RealtimeSettings />
- </ScaffoldContainer>
- )
+ return <RealtimeSettings />
}
RealtimePoliciesPage.getLayout = (page) => (
@@ -22,10 +18,9 @@ RealtimePoliciesPage.getLayout = (page) => (
<PageLayout
title="Realtime Settings"
subtitle="Configure your project's Realtime settings"
- // [Joshen] Scaffolding for now - once docs for this is ready
- primaryActions={<DocsButton href={`${DOCS_URL}/guides/realtime/authorization`} />}
+ primaryActions={<DocsButton href={`${DOCS_URL}/guides/realtime/settings`} />}
>
- {page}
+ <ScaffoldContainer>{page}</ScaffoldContainer>
</PageLayout>
</RealtimeLayout>
</DefaultLayout>