从本地机器连接时,AWS RDS 非常缓慢 [英] AWS RDS painfully slow when connecting from local machine

查看:75
本文介绍了从本地机器连接时,AWS RDS 非常缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 AWS RDS 实例正在运行.当从我的网站(也在 AWS 上,同一区域)查询数据库时,它运行良好.但是,如果我尝试从本地开发机器连接到数据库,则执行任何查询都需要 AGES.有谁知道为什么?我已打开安全组以允许连接(同时我尝试从本地计算机连接).

解决方案

出现这样的问题可能有多种原因.有些原因可能很明显,但为了答案的完整性而提及它们.您说过查询执行速度很慢,所以我假设连接建立成功并且网络 ACL、安全组等没有问题.

原因 1:您的 Internet 连接速度太慢

这可能有多种原因.看下面...

  • 另一台使用您互联网带宽的设备
  • 您在同一台设备上进行了一些并行下载
  • 您的互联网配额已超过
  • ISP 速度问题

不管什么原因,像这样的问题会在一段时间后解决.使用

原因 3:地理网络延迟

您的网站位于同一区域,到达 RDS 实例的网络跃点数较少.但是您的本地机器可能需要多跳才能到达 RDS 并返回.一般来说,AWS 速度非常快并且网络稳定,但您可能会注意到某些协议的延迟问题.

这极不可能,但仍然可能是一个原因.

原因 4:您的网络带宽较低

要查询多条记录,您的带宽可能不足以以极快的速度返回它们.因此,您会看到数据库查询的缓慢.

I have an AWS RDS instance up and running. When the DB is queried from my website (also on AWS, same region) it runs beautifully. But, if I try to connect to the database from my local developments machine it takes AGES for any query to execute. Does anyone know why? I have opened up the security group to allow connections (while i try to connect from the local machine).

解决方案

There could be multiple reasons for a problem like this. Some reasons might be so obvious, but mentioning them for the completeness of the answer. You have said that queries execute slow, so I assume that connection establishes successfully and there is no problem with Network ACLs, Security Groups etc.

Reason 1: Your Internet Connection is too Slow

This could be due to many reasons. See the following...

  • Another device using your internet bandwidth
  • You have some parallel downloads happening in your same device
  • Your internet quota has exceeded
  • ISP speed issues

For whatever reason, a problem like this will be solved after some time. Check your internet speed using this.

Reason 2: Exceeding the maximum number of connections on RDS instance

You could be hitting a limit on the maximum number of processes for MySQL. So, when you connect and issue any command, then if the number of processes allowed to run are saturated, then you have to wait and your request goes into queue. But if you don't get a slot then after that it timeouts.

The total number of connections depends on the instance type you are using. That you can check and set in the DB parameters group option. Search for max_connections.

Reason 3: Geographical Network Latency

Your website, being on the same region has a lower number of network hops to reach the RDS instance. But You local machine might take multiple hops to reach the RDS and return back. Generally AWS is pretty fast and has a stable network but you might notice latency issues for some protocols.

This is highly unlikely, but still could be a reason.

Reason 4: Your network bandwidth is low

To query for multiple records, your bandwidth might not be enough to return them in blazing speeds. Hence, you see the slowness in database queries.

这篇关于从本地机器连接时,AWS RDS 非常缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆