简体   繁体   English

AWS RDS只读副本与应用程序的交互

[英]AWS RDS read replicas interaction with application

I am very new to cloud computing. 我对云计算非常陌生。 I have never worked with MySQL outside of 1 instance. 我从未在1个实例之外使用MySQL。 I am trying to understand how AWS RDS read replicas work with my application. 我正在尝试了解AWS RDS读取副本如何与我的应用程序一起使用。 For example say I have 1 master and 2 read replicas. 例如,说我有1个主副本和2个只读副本。 I then from my application server send the query to AWS: 然后,我从我的应用程序服务器将查询发送到AWS:

SELECT * FROM users where username = 'bob';

How does this work now? 现在如何运作? Do I need to include more into my code to choose a certain read replica or does AWS automatically reroute the request or how does it work? 我是否需要在代码中包含更多内容以选择特定的只读副本,或者AWS是否自动重新路由请求或它如何工作?

Amazon does not currently provide any sort of load balancing or other traffic distribution across RDS servers. Amazon当前不跨RDS服务器提供任何类型的负载平衡或其他流量分配。 When you send queries to the primary RDS endpoint, 100% of that traffic goes to the primary RDS server. 当您向主RDS端点发送查询时,该流量的100%会流向主RDS服务器。 You would have to architect your system to open connections to each server and distribute the queries across the different database servers. 您将必须设计您的系统以打开与每个服务器的连接,并将查询分布在不同的数据库服务器之间。

To do this in a way that is transparent to your application, you could setup an HAProxy instance between your application and the database that manages the traffic distribution. 要以对应用程序透明的方式执行此操作,可以在应用程序和管理流量分配的数据库之间设置HAProxy实例。

Use of Elastic Load Balancers to distribute RDS traffic is an often requested feature, but Amazon has given no indication that they are working on this feature at this time. 经常需要使用Elastic Load Balancer分配RDS流量,但是Amazon暂时没有表示他们正在使用此功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM