Skip to content
Realtime

设置

Realtime Settings that allow you to configure your Realtime usage.

设置 #

🌐 Settings

Usage page navigation bar

你可以在仪表板的实时设置屏幕中设置以下选项。关于你的计划允许的上限,请参见 实时限制;速率和负载限制只有在你们组织的消费上限被禁用时才能编辑。有关以下错误,请参见 操作错误代码。

🌐 You can set the following settings using the Realtime Settings screen in your Dashboard. For the ceilings your plan allows, see Realtime Limits; the rate and payload limits are only editable while your organization's spend cap is disabled. For the errors below, see Operational Error Codes.

启用实时服务 #

🌐 Enable Realtime service

类型: 切换 · 选项: 启用, 禁用 · 默认: 启用

确定你的项目是否启用了实时服务。

🌐 Determines if the Realtime service is enabled or disabled for your project.

  • 已启用:正常操作。
  • 已禁用:已连接的客户端会被断开,新连接会被 403 和 Realtime was disabled for this tenant 拒绝,加入时会收到 RealtimeDisabledForTenant,广播 REST 请求会被 403 拒绝。Realtime 还会释放它为你的项目持有的数据库连接和 Postgres 变更复制槽,并在你再次启用后首次连接时重新打开它们。

允许公开访问通道 #

🌐 Allow public access to channels

类型: 切换 · 选项: 启用, 禁用 · 默认: 启用

确定 Realtime 是否允许公共通道,或者将你的项目限制为使用 Realtime 授权 的私有通道。

🌐 Determines whether Realtime allows public channels, or restricts your project to private channels with Realtime Authorization.

  • 已启用:不会运行策略检查,但任何持有你项目匿名密钥的人都可以订阅并在任何公共通道上广播。
  • 已禁用:每次连接都会根据 realtime.messages 的行级别安全策略进行检查,所以每次连接都会消耗一次授权查询。没有将 config.private 设置为 true 的客户端会被 PrivateOnly 拒绝。没有策略的情况下,客户端可以连接,但不会收到任何消息。

数据库连接池大小 #

🌐 Database connection pool size

类型: 连接数量 · 范围: 1 到你的数据库的 max_connections · 默认值: 根据计算大小而异

确定用于实时授权 RLS 检查的连接数量。结果会按客户端缓存,因此每次加入私有通道、每次 access_token 刷新以及每次私有广播 REST 请求都会使用连接池。

🌐 Determines the number of connections used for Realtime Authorization RLS checking. Results are cached per client, so the pool is used on each private channel join, each access_token refresh, and each private Broadcast REST request.

  • 太低:检查队列和超时。客户端会收到 IncreaseConnectionPool,广播被丢弃,状态调用失败。一旦 30 秒窗口内的超时次数达到连接池大小,后续检查会立即失败,甚至不会访问数据库。
  • 太高了:连接池与你的应用竞争数据库的 max_connections。如果 Realtime 的总需求不合适,它会拒绝使用 DatabaseLackOfConnections 启动。

请查看 数据库连接 了解每种计算大小的默认设置。

🌐 See Database connections for the defaults per compute size.

Postgres 更改连接池大小 #

🌐 Postgres Changes connection pool size

类型: 连接数 · 范围: 1 到 20 · 默认: 2

确定在客户端订阅时用于创建 Postgres Changes 订阅的连接数量。这只在创建订阅时使用;流式传输更改使用的是另一个连接。

🌐 Determines the number of connections used to create Postgres Changes subscriptions when clients subscribe. It's only used while subscriptions are created; streaming the changes uses a separate connection.

  • 太低:在高峰期间,订阅创建会超时。客户端会收到带有 Too many database timeouts 的 postgres_changes 系统错误,并在 5 到 10 秒后重试。
  • 太高:它和其他所有实时池计入同一个连接预算。

如果有很多客户端同时订阅,比如部署后或大规模重新连接时,就提高这个值。

🌐 Raise this value if many clients subscribe at the same time, such as after a deploy or a mass reconnect.

最大并发客户端 #

🌐 Max concurrent clients

类型: 客户数量 · 范围: 1 到你套餐的并发连接上限 · 默认: 你套餐的上限

确定可以连接的最大客户端数量。一个客户端指一个 WebSocket 连接,无论它加入了多少通道。

🌐 Determines the maximum number of clients that can be connected. A client is one WebSocket connection, no matter how many channels it joins.

  • 太低:新连接会被 429 和 Too many connected users 拒绝。已有客户端不受影响。
  • 太高:每个连接都会消耗实时节点的内存,所以这个设置起到容量和成本控制的作用。

每秒最大事件数 #

🌐 Max events per second

类型: 每秒事件数 · 范围: 1 到你计划的每秒消息数上限 · 默认值: 你计划的上限

确定每秒可以发送的最大事件数量,以过去一分钟的滚动平均值测量。一个事件是客户端发送或接收的消息,所以一次广播给100个订阅者算作100个事件。

🌐 Determines the maximum number of events per second that can be sent, measured as a rolling average over the previous minute. An event is a message sent by a client or delivered to one, so one broadcast to 100 subscribers counts as 100 events.

  • 太低:超过平均值的通道会被 Too many messages per second 关闭,而 supabase-js 会通过重新加入来恢复。广播的 REST 请求会被 429 拒绝;这些响应带有 x-rate-limit 和 x-rate-limit-remaining 头,你可以先用它们来减慢速度。
  • 太高了:Realtime 会停止限制广播分发,这会取消对无限循环或大量重新连接的保护,同时提高你在 Realtime 上的花费上限。

每秒最大存在事件数 #

🌐 Max presence events per second

类型: 每秒事件数 · 范围: 1 到你套餐的 每秒存在消息 上限 · 默认: 你套餐的上限

确定每秒可以发送的最大在线事件数,使用与 每秒最大事件数 相同的滚动平均值,但在事件发送前进行检查,而不是在发送后。

🌐 Determines the maximum number of presence events per second that can be sent, using the same rolling average as Max events per second but checked before the event is sent rather than after delivery.

  • 太低:存在跟踪和同步失败,通道已关闭,错误代码为 Too many presence messages per second。
  • 太高:快速的 track 和 untrack 循环会产生在线风暴,因为每次变化都会广播给通道中的每个客户端,并且也会计入每秒最大事件数。

最大有效载荷大小(KB) #

🌐 Max payload size in KB

类型: 大小(KB) · 范围: 1 到你计划的 广播负载大小 上限 · 默认: 你计划的上限

确定可以发送的最大有效载荷大小(KB)。

🌐 Determines the maximum payload size in KB that can be sent.

  • 太低:过大的广播会被丢弃,发送者只有在设置了 ack_broadcast 为 true 时才会知道。广播的 REST 请求会被 422 拒绝,而过大的存在 track 会用 Track message size exceeded 关闭通道。
  • 太大了:大消息会增加每个订阅者的内存和带宽使用,因为每条消息都会发送到通道上的所有客户端。Postgres 变更的有效负载有一个单独的限制。