简体   繁体   English

图像上传和操作API需要更多时间来获取更高分辨率的图像

[英]Image Upload and manipulation API taking more time for higher resolution images

My Current flow that I am following for image upload and its manipulation on the S3 bucket is as follows: 我遵循的用于图像 upload及其在S3存储桶上的manipulation我的当前流程”如下:

  1. Image is uploaded into an S3 Bucket . 图像被上传到S3存储桶中
  2. Retrieving the image buffer of the saved image in the S3 Bucket . 检索S3存储桶中保存的图像的图像缓冲区。
  3. Resizing of the image buffer using gm and imagemagick npm module. 使用gmimagemagick npm模块调整图像缓冲区的大小。
  4. Saving the resized image buffer with the original extension as a new image in the S3 Bucket . 将具有原始扩展名的调整大小后的图像缓冲区另存为S3存储桶中的新图像。

As the image size increases so those the API response time.It takes 3 secs for the API to give a response while following above workflow for a 300 KB image and 30 secs for a 15 MB or more image. 随着image size增加,API的response时间也随之增加。对于300 KB的图像,遵循上述工作流程需要3秒钟的API响应;对于15 MB或更多的图像,则需要30秒。

I don't know if my flow is correct or not. 我不知道我的流程是否正确。 My requirement is that I need to reduce my API response time while uploading a 15 or more MB image. 我的要求是,在上传15或更多MB图像时,我需要减少API响应时间。 Can somebody suggest me how to achieve this? 有人可以建议我如何实现这一目标吗?

EDIT 编辑

To make it clear I am uploading a single 15 MB file which I am sending it from Advanced Rest Client (a chrome plugin) to my API. 为了清楚起见,我上传了一个15 MB的文件,并将其从Advanced Rest Client (chrome插件)发送到我的API。 The image file is currently present in my local system. 该图像文件当前在我的本地系统中。 I am currently working on jpg and png images. 我目前正在处理jpgpng图像。 I want to resize the image to both bigger and smaller sizes by reducing the width to height ratio . 我想通过减小宽高比来将图像调整为更大或更小的尺寸。 The API that I Have written is in Node JS which follows the above workflow. 我编写的API在Node JS中,它遵循上述工作流程。

Seems like upload and download big image from S3 takes a lot of time. 似乎从S3上传和下载大图像需要花费大量时间。

You can do some optimizations: 您可以进行一些优化:

  • Try to use graphicsmagick package, in common cases it's faster that imagemagick (latest versions) 尝试使用graphicsmagick软件包,在通常情况下,它比imagemagick(最新版本)要快
  • Make resize / optimize operations before uploading to S3 and upload at last step 在上载到S3并最后一步上传之前进行调整大小/优化操作

  • If it's not possible - try to use Streams for downloading - resizing - uploading to S3. 如果不可能-尝试使用Streams进行下载-调整大小-上载到S3。 just pipe request stream to gm module and write pipe to AWS S3 只是将请求流通过管道传输到gm模块并将管道写入AWS S3

  • Make image optimizations from Amazon EC2 infastructure, it's having very high network perfomance with S3 通过Amazon EC2基础架构进行图像优化,它与S3的网络性能非常高

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM