0

I have never used AWS before and have created a php application hosted on an EC2 instance.

The application inserts records into a RDS after processing them. On the free tier it is inserting them at a rate of around 10 records per second.

How would I go about improving the speed at which this process takes place? I have added 100GB provisioned IOPS storage with a limit of 1000 iops.

However when I run my application I get the same speeds as before.

What specs on the Ec2 instance and the RDS instances will determine how quickly it will write to the database?

4

2 回答 2

1

如果 EC2 和 RDS 实例位于同一区域,您可能会通过提高 RDS 规范获得更多性能,但通常 MySQL 在写入时不会那么快,尤其是当您向表中添加更多索引时。

您可以通过在查询中批量插入而不是单独执行它们来获得更好的性能,例如

INSERT INTO users (name, gender) VALUES
  ('bob', 'm'),
  ('jane', 'f')

如果您使用某种排队系统(如 SQS 或 elasticache)写入内存并异步批量插入它们,这可能会更容易。

于 2017-04-19T13:53:29.317 回答
1

请注意

  1. AWS 免费套餐实例仅适用于临时使用。t2.micro 正在“CPU 信用”突发模式下运行。一旦你用完这些 CPU 积分,服务器将限制到超过 25% 的 CPU,因此你的性能将受到影响。

  2. 您应该在 cloudwatch 上投入一点,以发送 RDS IOPS 信息以了解真正的问题,例如找出是 CPU、RAM 还是 IO 问题。

  3. AWS 推出 SSD gp2 存储已经有一段时间了。因此,您应该利用 AWS 每 GB x 3 IOPS 机制,而不是直接跳入预置 IOPS。本文告诉您为什么应该过度配置 gp2 存储而不是使用配置 IOPS。您还可以通过突发 IO 的 gp2 获得额外的物有所值。

于 2017-04-19T17:00:56.983 回答