英文:
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
-
选择在接近您的Supabase实例的AWS区域上运行您的应用程序 - 每个Supabase实例都只是AWS上的一个EC2实例,您应该能够在首次创建项目时选择要托管数据库的区域。将您的应用程序放在AWS的同一区域应显著降低延迟。
-
自行托管Supabase - 您始终可以自行托管Supabase,这将使您有自由将应用程序放在同一网络中。您可以按照Supabase自行托管指南此处。
英文:
I think you have two options:
-
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.
-
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论