carropublic/serverless-chunk-payload 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

carropublic/serverless-chunk-payload

最新稳定版本:2.0

Composer 安装命令:

composer require carropublic/serverless-chunk-payload

包简介

README 文档

README

Lambda Invocation Limitation

https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html

  • AWS Gateway only allow HTTP API Payload Size of 10MB.
  • AWS Lambda only allow Function Invocation payload size of 6MB. -> So Using AWS Gateway and AWS Lambda Integration, max payload size is 6MB

Simple Chunk Upload Protocol

To be able to send larger payload, need to chunk the payload into smaller pieces.

  • Let's say we have JSON payload of 10MB
  • Decode the JSON into string, and split it into 10 chunks of 1MB string
  • Call the API 10 times with different chunk payload
    • chunk_data: current chunk
    • chunk_index: current chunk's index
    • total_chunks: total chunks (in this example = 10)
    • payload_hashed: the md5 value of original JSON
  • BE will collect 10 chunks
  • After the last chunk is collected, the actual payload will be concatenated and pass through Laravel pipeline
    • The previous chunks will be collected and saved in Redis Cache
    • Those request will be returned immediately after saving to Redis Cache

UniqueId

Since payload_hashed will be used as Tag Name of Cache, so attempting to upload the same content multiple times may cause conflict between those upload

To avoid this unexpected behavior, always add extra data to original payload called uniqueId

  • This could be any random string or current timestamp, which can be considered as unique between multiple uploads.
  • This uniqueId data will be deducted after restoring the original data.

How to use

composer require carropublic/serverless-chunk-payload

The middleware will be auto registered via ServiceProvider, which is also auto registered by Laravel Auto Discovery

统计信息

  • 总下载量: 9.68k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-11-29