是否需要在 Aurora DB 的应用程序端管理只读副本详细信息?
Is it necessary to manage read replica details on application side for AuroraDB?
我是 AWS 的新手,面临 RDS CPU 的使用。以下是 RDS 信息:
- 实例类型:t3.medium
- 数据库类型:Postgres
- 存储空间:50GB
我在一天中的特定时间段收到 80% CPU 使用率的警告。
因此,我正在考虑迁移到支持自动缩放的 Aurora DB,但官方文档说我必须在应用程序端管理 Aurora DB 的扩展实例。
To benefit from Aurora Auto Scaling, your applications must support connections to new Aurora Replicas. To do so, we recommend using the Aurora reader endpoint. For Aurora MySQL you can use a driver such as the MariaDB Connector/J utility. For more information, see Connecting to an Amazon Aurora DB Cluster.
https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Integrating.AutoScaling.html
以上是官方文档link。
我的问题是:
- Aurora DB 是否会在横向扩展上创建具有新端点的新副本?
- 当 RDS 横向扩展时,我真的必须管理应用程序中多个实例的连接信息吗?
- 如果是,那么我的应用程序将如何获知已经创建了多少个新副本用于读取或写入以及端点是什么?
- 有没有什么方法可以自动平衡负载,而无需在应用程序端添加额外的数据库端点?
注意:我正在 Rails 网络应用程序上使用 Ruby 访问数据库。
谢谢。
您必须在您的申请中使用 reader endpoint:
A reader endpoint for an Aurora DB cluster provides load-balancing support for read-only connections to the DB cluster. Use the reader endpoint for read operations, such as queries. [...] If the cluster contains one or more Aurora Replicas, the reader endpoint load-balances each connection request among the Aurora Replicas.
通常您无需执行任何操作,只需使用您在问题中所写的 reader 端点:
To benefit from Aurora Auto Scaling, your applications must support connections to new Aurora Replicas. To do so, we recommend using the Aurora reader endpoint.
它的工作方式是,当您解析 reader 的端点 DNS 名称时,它会随机 return 一个副本的 IP。
添加新副本后,Reader 端点也会在 AWS-side 上自动更新。这个过程对你来说是透明的。
不过应该注意,负载平衡是在 连接级别 上完成的。因此,如果您在应用程序的整个运行过程中只打开并保持一个连接,它将不会进行负载平衡。这是因为将在连接时选择要连接的副本。
我是 AWS 的新手,面临 RDS CPU 的使用。以下是 RDS 信息:
- 实例类型:t3.medium
- 数据库类型:Postgres
- 存储空间:50GB
我在一天中的特定时间段收到 80% CPU 使用率的警告。 因此,我正在考虑迁移到支持自动缩放的 Aurora DB,但官方文档说我必须在应用程序端管理 Aurora DB 的扩展实例。
To benefit from Aurora Auto Scaling, your applications must support connections to new Aurora Replicas. To do so, we recommend using the Aurora reader endpoint. For Aurora MySQL you can use a driver such as the MariaDB Connector/J utility. For more information, see Connecting to an Amazon Aurora DB Cluster.
https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Integrating.AutoScaling.html
以上是官方文档link。
我的问题是:
- Aurora DB 是否会在横向扩展上创建具有新端点的新副本?
- 当 RDS 横向扩展时,我真的必须管理应用程序中多个实例的连接信息吗?
- 如果是,那么我的应用程序将如何获知已经创建了多少个新副本用于读取或写入以及端点是什么?
- 有没有什么方法可以自动平衡负载,而无需在应用程序端添加额外的数据库端点?
注意:我正在 Rails 网络应用程序上使用 Ruby 访问数据库。
谢谢。
您必须在您的申请中使用 reader endpoint:
A reader endpoint for an Aurora DB cluster provides load-balancing support for read-only connections to the DB cluster. Use the reader endpoint for read operations, such as queries. [...] If the cluster contains one or more Aurora Replicas, the reader endpoint load-balances each connection request among the Aurora Replicas.
通常您无需执行任何操作,只需使用您在问题中所写的 reader 端点:
To benefit from Aurora Auto Scaling, your applications must support connections to new Aurora Replicas. To do so, we recommend using the Aurora reader endpoint.
它的工作方式是,当您解析 reader 的端点 DNS 名称时,它会随机 return 一个副本的 IP。
添加新副本后,Reader 端点也会在 AWS-side 上自动更新。这个过程对你来说是透明的。
不过应该注意,负载平衡是在 连接级别 上完成的。因此,如果您在应用程序的整个运行过程中只打开并保持一个连接,它将不会进行负载平衡。这是因为将在连接时选择要连接的副本。