Throttling messages
Use client-side throttling to manage message frequency.
The Supabase clients include functionality for throttling messages.
Managing client-side throttling#
You can customize the client-side throttling when creating the client:
_12import { createClient } from '@supabase/supabase-js'_12_12const SUPABASE_URL = 'https://<project>.supabase.co'_12const SUPABASE_ANON_KEY = '<your-anon-key>'_12_12const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {_12 realtime: {_12 params: {_12 eventsPerSecond: 2,_12 },_12 },_12})
Default client throttling#
By default the Supabase clients throttles messages to 10 messages per-second (1 message every 100 milliseconds). This is a soft-limit provided as a safe-guard when you're getting started. You'll rarely need to send more messages than this.
Each client has their own throttling behavior. If you instantiate two clients, by default you would send 20 messages per-second to your project.
Project Quotas#
Each Broadcast and Presence message counts towards your Project Quotas.
It's common to unintentionally flood the Realtime service with messages. For example, tracking mouse movents without throttling would send hundreds of events per second. It's rare that you need so many messages. Updating a mouse movement even a few times per second is usually enough for the human eye.
The throttling parameter protects against these unintended floods.