Skip to content

All about Supabase Egress

什么是出口?

Egress(也称为带宽)是指从你的项目向连接的客户端传输的任何网络数据包/字节,也就是离开 Supabase 平台的数据。在 Supabase 中,Egress 包括通过数据 API(PostgREST)、存储、实时、认证、边缘函数、数据库和 Supavisor 发送的任何数据。

🌐 Egress (also known as bandwidth) is any amount of network packets/bytes being streamed to a connected client from your project, i.e. data that is leaving the Supabase platform. Egress in Supabase includes any data sent from the data API (PostgREST), Storage, Realtime, Auth, Edge Functions, Database and Supavisor.

你可以在出口中阅读关于统一出口、包含额度以及如何理解使用情况的内容。

🌐 You can read about Unified egress, included quota, and how to understand usage in the egress.

你可以查看 Billing Dashboard 来了解出口使用情况。或者,项目报告 中也有一些与出口相关的统计数据。你可以创建自定义报告来查看每日出口情况。

🌐 You can review the Billing Dashboard for egress usage. Alternatively, the project reports have a few egress related stats. You can create a custom report to look into daily egress.

  • 示例:自定义报告 -> 添加/移除图表 -> 数据库 API -> API 出口。

image

什么在导致出口?

虽然指出疏散的确切原因可能不那么简单,但你可以采取各种步骤来确定这些问题的来源:

🌐 While pointing out the exact cause for egress may not be straightforward, there are various steps you can take to determine the source of these issues:

  • 计费仪表板查看你在项目和组织层面的出口使用情况
  • 日志浏览器 中选择“热门路径”将帮助你识别查询频繁的路径
  • 通过在查询性能报告中找到最常被请求的查询:https://app.supabase.com/project/_/advisors/query-performance
  • Supavisor 出口是独立于客户端的。单个查询和 Supavisor 出口之间没有直接关联,所以更难调试和识别。但你可以利用上一步链接中显示的常用查询,同时该链接也显示了平均返回行数,这有助于识别返回行数较多的查询。虽然这不会专门显示 Supavisor 查询,但可以让你大致了解哪些查询返回了很多行,这也会有帮助。
  • 对于存储出口,所有涉及存储相关请求以下载/查看你的存储项目的外发流量都被视为存储出口。我们在日志探索器里有一个“存储出口请求”的模板,你可以用它来获取每个存储对象的请求数量。
  • 如果你使用 Supavisor 连接从数据库中拉取 1MB 的数据到你的边缘函数,但只发送 100KB 回给用户,那么你会有从 Supavisor 到你的边缘函数的出口流量,加上从边缘函数到用户的流量

你怎么减少外流?

  • 查询时减少选择的字段或条目数量
  • 通过优化客户端代码减少查询/调用次数,或者使用缓存来减少请求/查询次数:https://github.com/psteinroe/supabase-cache-helpers/
  • 如果是更新或插入查询,而且你不需要返回整行数据,可以配置你的ORM或查询不要返回整行
  • 如果通过 Supavisor 进行手动备份,删除不需要的表格和/或减少备份频率
  • 对于存储,如果你开始使用 Smart CDN,存储外发流量可以减少。你也可以使用 Supabase 图片转换 来优化图片并减少外发流量。

缓存与非缓存出口

我们区分缓存和非缓存的出站流量。缓存出站流量只适用于 Supabase 存储,指的是通过我们的 CDN 提供并命中缓存的流量。而非缓存出站流量则指未从缓存提供、需要向源服务器发出新请求的流量。

🌐 We differentiate between cached and uncached egress. Cached egress, which only applies to Supabase Storage, refers to egress that is served via our CDN and hits the cache. Uncached egress, on the other hand, refers to egress that is not served from the cache and requires a fresh request to the origin server.

你的计划包括缓存和非缓存出口流量的配额,而且它们是独立的。如果你超过配额,缓存出口的费用也更便宜。

🌐 Your plan includes a quota for both cached and uncached egress and these are independent. Cached egress is also cheaper in case you exceed your quota.