dongtangu6889 2018-07-22 19:41
浏览 70
已采纳

AWS RDS DB在部署时会变慢

I'm trying to implement a CMS on AWS using mostly free tier services and am doing so using PHP, and have already implemented this using PHPMyAdmin in school.


The problem:


I wanted to do this using RDS, but I've come up with a pretty strange issue.

When I upload my site to Elastic Beanstalk and try to connect to the DB from there, I face incredibly long wait times. Sometimes it returns error 504 from long wait times.

This is not an issue with the Database's speed, however. I know this because I can run this code on localhost and it works exactly as intended (see photo)

Speed on localhost

Only half a second to load!


What I think is happening:


Something must be going on while it's being executed in Elastic Beanstalk. I don't know quite what, but it's taking way too long.


Extra info:


I connect to the DB using the following code (credentials are spoofed):

$conn = mysqli_connect("mydb.cebelvm3fa0n.ca-central-1.rds.amazonaws.com","USERNAME","PASSWORD","mydb");

Both my database and EL instance are run from ca-central. The connection is not failing, it is taking an extreme amount of time.

the page that is failing is http://howardpearce.ca/posts.php


If you have any ideas on what it could be, I would appreciate it very much. Thanks!

NOTE:

I will post certain bits of my code, but creating an MCVE is really not feasible as I would have to give my DB password, and you would need to re-create my AWS environment, so please don't ask for one, I can always give more detail.

  • 写回答

1条回答 默认 最新

  • duansha6410 2018-07-22 22:51
    关注

    After @colde mentioned checking logs, I quickly found an error code which lead me to the right resources.

    My database was only configured to allow connections from my IP, and the firewall was blocking out my Elastic Beanstalk instance, I just had to add a new security rule.

    Thanks!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 在若依框架下实现人脸识别
  • ¥15 网络科学导论,网络控制
  • ¥100 安卓tv程序连接SQLSERVER2008问题
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同