0

我正在尝试将我使用 RMagick 创建的一堆图像即时上传到 S3。

在本地,我可以创建大约 50 张图片并在 30 秒内上传所有图片。

代码非常简单:

#outside the loop
s3 = AWS::S3.new
bucket = s3.buckets["bucket_name"]

#inside the loop
s3_object = bucket.objects[image_name]
s3_object.write(image.to_blob) # image from rmagick

它在一个工人测功机上运行在 Sidekiq 工作中。

不幸的是,在 Heroku 上上传相同的图像需要大约 300-400 秒。长10倍!

查看日志,我看到很多对相当小的图像进行重试。

2013-10-11T04:35:22.145747+00:00 app[worker.1]: [AWS S3 200 0.197307 0 retries] put_object(:bucket_name=>"bucket_name",:content_length=>109459,:data=>#<StringIO:0x007f2365b64240>,:key=>"key")
2013-10-11T04:35:25.874405+00:00 app[worker.1]: [AWS S3 200 0.361312 0 retries] put_object(:bucket_name=>"bucket_name",:content_length=>95877,:data=>#<StringIO:0x007f2365b804e0>,:key=>"key")
2013-10-11T04:35:29.132112+00:00 app[worker.1]: [AWS S3 200 0.234044 0 retries] put_object(:bucket_name=>"bucket_name",:content_length=>139513,:data=>#<StringIO:0x007f2365bb2468>,:key=>"key")
2013-10-11T04:35:32.344850+00:00 app[worker.1]: [AWS S3 200 0.2355 0 retries] put_object(:bucket_name=>"bucket_name",:content_length=>170072,:data=>#<StringIO:0x007f2365bf7090>,:key=>"key")
2013-10-11T04:35:36.945883+00:00 app[worker.1]: [AWS S3 200 1.333778 0 retries] put_object(:bucket_name=>"bucket_name",:content_length=>99901,:data=>#<StringIO:0x007f2365facdc0>,:key=>"key")
2013-10-11T04:35:40.425480+00:00 app[worker.1]: [AWS S3 200 27.044513 1 retries] put_object(:bucket_name=>"bucket_name",:content_length=>41198,:data=>#<StringIO:0x007f236586b430>,:key=>"key")
2013-10-11T04:35:43.188034+00:00 app[worker.1]: [AWS S3 200 0.619067 0 retries] put_object(:bucket_name=>"bucket_name",:content_length=>105656,:data=>#<StringIO:0x007f2377d37e98>,:key=>"key")
2013-10-11T04:36:01.464658+00:00 app[worker.1]: [AWS S3 200 23.727376 1 retries] put_object(:bucket_name=>"bucket_name",:content_length=>41198,:data=>#<StringIO:0x007f23668d57a8>,:key=>"key")
2013-10-11T04:36:05.773317+00:00 app[worker.1]: [AWS S3 200 20.765285 1 retries] put_object(:bucket_name=>"bucket_name",:content_length=>77195,:data=>#<StringIO:0x007f2378bc2350>,:key=>"key")
2013-10-11T04:36:24.315209+00:00 app[worker.1]: [AWS S3 200 20.947173 1 retries] put_object(:bucket_name=>"bucket_name",:content_length=>105656,:data=>#<StringIO:0x007f23757d1f00>,:key=>"key")
2013-10-11T04:36:28.069586+00:00 app[worker.1]: [AWS S3 200 20.963508 1 retries] put_object(:bucket_name=>"bucket_name",:content_length=>126600,:data=>#<StringIO:0x007f2366aa5fd8>,:key=>"key")

有任何想法吗?

4

1 回答 1

0

解决方法:升级到 2x worker dyno 减少了超时。

于 2013-10-17T18:58:13.967 回答