【问题标题】:AWS RDS Slow InsertAWS RDS 慢速插入
【发布时间】:2014-10-30 19:43:43
【问题描述】:

我有一个关于在 RDS 中插入行的问题。 在该示例中,我在 1 个表中插入了 301119 条记录。

这是我对这些插入批次的日志:

Amazon : 

2014-09-05 12:12:47,245 - Processing 30119 users 
2014-09-05 12:15:01,508 - 5000 users updated in transaction 
2014-09-05 12:17:29,672 - 10000 users updated in transaction 
2014-09-05 12:19:30,499 - 15000 users updated in transaction 
2014-09-05 12:21:38,866 - 20000 users updated in transaction 
2014-09-05 12:23:26,659 - 25000 users updated in transaction 
2014-09-05 12:25:16,727 - 30000 users updated in transaction 
2014-09-05 12:25:19,376 - 30119 users updated in transaction - DONE 
2014-09-05 12:25:19,379 - Process completed in **752134** ms 


Local : 

2014-09-05 12:33:20,767 - Processing 30119 users 
2014-09-05 12:33:39,692 - 5000 users updated in transaction 
2014-09-05 12:33:50,949 - 10000 users updated in transaction 
2014-09-05 12:33:59,476 - 15000 users updated in transaction 
2014-09-05 12:34:06,962 - 20000 users updated in transaction 
2014-09-05 12:34:14,874 - 25000 users updated in transaction 
2014-09-05 12:34:22,945 - 30000 users updated in transaction 
2014-09-05 12:34:23,111 - 30119 users updated in transaction - DONE 
2014-09-05 12:34:23,112 - Process completed in **62345** ms 

查询是直接批量插入 1 个表。

我的本​​地速度不是很快,而且这些结果很奇怪......在 AWS 中运行相同的插入需要 12 倍以上......所以,有什么问题......是配置问题还是其他问题?

一些指针将非常受欢迎:) :)

谢谢!

【问题讨论】:

  • 你有什么实例类型?如果你有一个微型实例,那就不足为奇了。
  • 实际上我们升级到具有 5000 IOPS 的 X-LARGE,而且速度很慢,现在不是比我的本地慢 12 倍,而是慢 10 倍......非常令人不安:-/
  • 插入数据的进程是什么?该进程是否与 RDS 实例在同一可用区中运行?
  • 感谢您的帮助,大卫,两人都在 west-2b。插入数据的过程由 Spring 框架完成(batchUpdate() 查询)

标签: mysql amazon-web-services bulkinsert


【解决方案1】:

所以,我想通了!在搜索和调整配置之后,我们大约每秒插入 300 次,我们禁用了 innodb_flush_log_at_trx_commit (1 -> 0) 和 sync_binlog (1 -> 0),我们达到了每秒 1500-2000 次插入!! 由于如果数据库崩溃,我们可以丢失最后一个事务/提交,所以我们继续使用它,现在速度非常快!!

希望它能帮助遇到同样问题的其他人!

【讨论】:

  • 你能指导一下你是怎么做到的
  • 您必须前往 AWS 控制台。您可以在其中找到您的实例并修改这些设置。
  • @julien 将 sync_binlog 更改为 0 是否安全?更改后我需要重新启动实例吗?我问是因为我不太了解,我也有同样的问题。我所有的插入和更新都很慢。
  • 是的,我们已经使用该设置运行了一段时间,并且做得很好。我相信这是一个热门值,因此不需要重新启动 - 虽然不是 100% 确定 :)
  • 哇,我们看到的正是。昂贵的 RDS 性能超慢。我们看到每秒只有大约 80 个基本/小型插入到一个非常小的表中。我们正在使用 PHP laravel。我尝试通过事务开始/提交一次强制执行 1000 行,但没有帮助。这个 innodb log flush 和 binlog 可能就是我们需要的!
【解决方案2】:
猜你喜欢
  • 2018-12-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-25
相关资源
最近更新 更多