这个configuration文件图片上传器的逻辑是可扩展的吗?

用于实现configuration文件上载function的以下通用逻辑是否可以在生产中进行扩展?

1. Inside a web app user selects an image to upload 2. Image gets sent to the server where it gets stored in memory and validated using nodejs package called: multer 3. If the image file is valid, a unique name is generated for the file 4. The image is resized to 150 x 150 using nodejs package called: sharp 5. Image is streamed to google cloud storage 6. Once image is saved a public URL of the image is saved under the user's profile inside of the database 7. The image ULR is sent back to the client and the image gets displayed 

用来实现上述的语言

这将实施使用:

  • 在Nodej上运行的Firebase云function作为后端
  • 用于保存图像的Google云端存储
  • firebase数据库,用于保存用户上传图片的图片url

我目前关心的是:

  • 在内存中保存一个图像,经过validation和处理后,可能会导致服务器在重负载时堵塞
  • 如何为图像比例生成唯一名称?uuidV4 +当前date(以毫秒为单位)+图像原始文件名的最后5个字符

Muller和Sharp都能满足您的需求:

上传的2MB图片缩小到150×150分辨率。

假设您将拥有100,000个用户。 每个用户上传一张缩小到20kb图像的图片。 这是1.907GB〜2GB的存储空间。

Google云端存储:

  • 在法兰克福一个例子
  • 2GB区域存储

= 一年 $ 0.55

Google云端函数:

为了简单起见,我们假设它将被均匀分配,因此每月用户上传图片的次数为8334 。 让我们非常悲观,并说一个调整function将需要3秒

  • 8334每月调整操作
  • 每个function3s
  • networking吞吐量每个function2MB

= 一年 $ 16.24

所以你很好走。 快乐的编码!


这个答案最终过时,所以我包括谷歌价格计算器的截图:

在这里输入图像说明