如何在自定义的基于MVC的PHP应用程序中管理读取和写入AWS Aurora主机端点?

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

How do I manage read and write AWS Aurora host endpoints in custom MVC based PHP application?

问题

我有一个基于自定义MVC的PHP应用程序,数据库使用AWS RDS Aurora MySQL。为了负载均衡,我创建了数据库的读取副本,并希望将读取查询发送到数据库的读取副本,将写入查询发送到RDS数据库的写入实例,但我不想在应用程序级别更新任何内容。是否有一种从AWS RDS进行负载均衡的方式?我希望避免更新代码,因为这是一个有点旧的自定义MVC框架。

英文:

I have a custom MVC based PHP application and for database I am using AWS RDS aurora mysql.
To load balance I have created a read replica of the database and I want to send read queries to read replica and write queries to writer instance of RDS database but I don't want to update anything on application level.

Is there any way to do this from AWS RDS to load balance? I want to avoid updating code as its a custom MVC framework which is a bit old code.

答案1

得分: 2

No, 您的应用程序必须更新连接字符串以利用读取副本。

RDS读取副本 - 用例

  • 您有一个承载正常负载的生产数据库。
  • 您想要运行一个独立的报告应用程序,以对生产数据进行一些分析。
  • 您创建一个读取副本来在那里运行新的工作负载。
  • 您更新报告应用程序中的连接字符串,
    使其对读取副本进行读取数据库调用。
  • 生产应用程序不受影响。
  • 读取副本仅用于SELECT(=读取)类型的语句
    (不包括INSERT、UPDATE、DELETE)。
英文:

No, Your Application must update the connection string to leverage read replicas.

RDS Read Replicas – Use Cases

  • You have a production database that is taking on a normal load.
  • You want to run a separate reporting application to run some analytics on production data.
  • You create a Read Replica to run the new workload there.
  • You update the connection strings in your reporting application to
    make read database calls to Read Replica.
  • The production application is unaffected.
  • Read replicas are used for SELECT (=read) only kind of statements
    (not INSERT, UPDATE, DELETE)

答案2

得分: 0

以下是已翻译的内容:

如果您的应用程序对某些毫秒级延迟的结果满意(即读取可能会看到略有滞后的数据),以下是几篇博客文章,描述了用于进行读写拆分的中间件:

Heimdall 宣称它能智能地确定滞后时间,并在决定如何路由读取查询时考虑它。

(我尚未评估这两个代理的性能,因此没有得出任何结论。)

英文:

If your application results are OK with the latency of some number of milliseconds (i.e. a read might see data that is just slightly stale), here are a couple of blog posts that describe middleware to do the read-write splitting:

https://aws.amazon.com/blogs/database/how-to-use-proxysql-with-open-source-platforms-to-split-sql-reads-and-writes-on-amazon-aurora-clusters/

https://aws.amazon.com/blogs/apn/using-the-heimdall-proxy-to-split-reads-and-writes-for-amazon-aurora-and-amazon-rds/

Heimdall advertises that it can intelligently figure out what the lag is and account for it when deciding how to route the read queries.

(I haven't evaluated either of those proxies to reach any conclusions of my own.)

huangapple
  • 本文由 发表于 2023年5月7日 10:10:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76191932.html
匿名

发表评论

匿名网友

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

确定