Supabase与数据库位于同一网络中以减少延迟。

huangapple go评论60阅读模式
英文:

Supabase functions in same network as database to reduce latency

问题

我正在尝试使用Supabase,并且在早期阶段遇到了以下问题:似乎没有办法将我的应用程序存储在与我的Supabase数据库相同的网络上?

这意味着我的中间层API端点每次想要从PostgreSQL获取数据时都会浪费300毫秒的时间。某些端点可能需要多次与PostgreSQL通信,迅速累积到超过1秒的响应时间。

我多年来一直在使用的典型架构是将数据库和应用程序服务器放在同一个虚拟专用网络中,以便它们可以以约2毫秒的延迟进行通信,而不是300毫秒。是否有类似的方法可用于Supabase?

英文:

I'm playing around with Supabase and pretty early on I'm getting stuck with the following issue: it doesn't seem to be a way to store my application on the same network as my supabase database?

This means my middle layer API endpoints will waste 300ms every time they want to fetch data from PostgreSQL. Some endpoints can communicate with PostgreSQL a few times, quickly adding up to >1 second response time.

The typical architecture that I've been using for years is to have the database and the application servers in the same virtual private network so that they can communicate with a ~2ms latency instead of 300ms, is there a similar approach that's doable with supabase?

答案1

得分: 1

  1. 选择在接近您的Supabase实例的AWS区域上运行您的应用程序 - 每个Supabase实例都只是AWS上的一个EC2实例,您应该能够在首次创建项目时选择要托管数据库的区域。将您的应用程序放在AWS的同一区域应显著降低延迟。

  2. 自行托管Supabase - 您始终可以自行托管Supabase,这将使您有自由将应用程序放在同一网络中。您可以按照Supabase自行托管指南此处

英文:

I think you have two options:

  1. Have your application run on AWS with region close to your Supabase instance - Every Supabase instance is just a EC2 instance on AWS, and you should be able to choose which region you want to host your database when you first create your project. Having your application on AWS in the same region should bring down the latency significantly.

  2. Self host Supabase - You can always self host Supabase, which would give you the freedom to put your application in the same network. You can follow the Supabase self hosting guide here.

huangapple
  • 本文由 发表于 2023年6月19日 13:46:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76503899.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定