如何批量上传到 s3?
我最近重构了一些代码,使用“加载数据”将行填充到数据库中,效果很好——但是对于我拥有的每条记录,我必须将 2 个文件上传到 s3——这完全破坏了我所获得的巨大速度升级。 虽然我每秒能够处理 600 多个这些文档,但由于 s3,它们现在只能每秒处理 1 份。
您对此有何解决方法? 查看 API,我发现它主要是 RESTful,所以我不确定该怎么做——也许我应该将所有这些都放入数据库中。 文本文件通常不超过1.5k。 (我们放入其中的另一个文件是文本的 xml 表示形式)
我已经将这些文件缓存在对我的 Web 服务器的 HTTP 请求中,因为它们被大量使用。
顺便说一句:我们当前的实现使用 java; 我还没有尝试过线程,但这可能是一个选项
建议?
I recently refactored some of my code to stuff rows into a db using 'load data' and it works great -- however for each record I have I must upload 2 files to s3 -- this totally destroys the magnificent speed upgrade that I was obtaining. Whereas I was able to process 600+ of these documents/second they are now trickling in at 1/second because of s3.
What are your workarounds for this? Looking at the API I see that it is mostly RESTful so I'm not sure what to do -- maybe I should just stick all this into the database. The text files are usually no more than 1.5k. (the other file we stuff in there is an xml representation of the text)
I already cache these files in HTTP requests to my web server as they are used quite a lot.
btw: our current implementation uses java; I have not yet tried threads but that might be an option
Recommendations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用JetS3t的[
putObjects
][1]函数上传一次多个文件。或者,您可以使用后台线程从队列上传到 S3,并从将数据加载到数据库的代码中将文件添加到队列。
[1]: http://jets3t.s3.amazonaws.com/api/org/jets3t/service/multithread/S3ServiceMulti.html#putObjects(org.jets3t.service.model.S3Bucket, org.jets3t.service .model.S3Object[])
You can use the [
putObjects
][1] function of JetS3t to upload multiple files at once.Alternatively you could use a background thread to upload to S3 from a queue, and add files to the queue from your code that loads the data into the database.
[1]: http://jets3t.s3.amazonaws.com/api/org/jets3t/service/multithread/S3ServiceMulti.html#putObjects(org.jets3t.service.model.S3Bucket, org.jets3t.service.model.S3Object[])
我刚刚找到了一个很好的解决方案,可以使用 php 上传整个目录:
I just found a nice solution to upload an entire directory with php: