[英]Multi Region Postgres Latency Issue Azure
Architecture which we are using currently is as below我们目前使用的架构如下
Private Web App Services hosted in US Region and India Region.私有 Web 美区和印度区托管的应用服务。 Both the apps are behind the respective App Gateway, this app Gateway is behind the front door which helps us serve the request from the nearest app gateway.这两个应用程序都在各自的应用程序网关后面,这个应用程序网关在前门后面,帮助我们处理来自最近应用程序网关的请求。 But Both apps uses the same postgres which is present in US region.但是这两个应用程序都使用美国地区存在的相同 postgres。
Now our issue is when we hit the api from US response time is less then 2sec whereas when we hit the api from India region it takes 70sec.现在我们的问题是,当我们从美国地区拨打 api 时,响应时间少于 2 秒,而当我们从印度地区拨打 api 时,则需要 70 秒。
How can we reduce the latency?我们怎样才能减少延迟?
Actually, the problem is the APIs does write operation due to which we cannot a read replica.实际上,问题是 API 执行写操作,因此我们无法读取副本。
There a few things you can do您可以做一些事情
1- Add a cache layer to both regions and rather than querying directly on DB, check if the data is available in the cache first, and if it's not, get it from DB and add to the cache layer. 1- 向两个区域添加一个缓存层,而不是直接在数据库上查询,首先检查数据是否在缓存中可用,如果不可用,则从数据库中获取数据并添加到缓存层。
2- Add a secondary database on India region which will be a read only. 2- 在印度地区添加一个只读的辅助数据库。
PS: You may have stale data with both approaches so you should sync properly according to your requirements PS:这两种方法都可能有过时的数据,所以你应该根据你的要求正确同步
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.