ฉันต้องการรับการซิปไฟล์ที่มีประสิทธิภาพโดยใช้ amazon lambda กับ s3 buckets ไฟล์ที่ฉันต้องการซิปอยู่ในที่เก็บข้อมูล แลมบ์ดาที่ฉันกำลังทดสอบควรจะรับเส้นทางของไฟล์และสร้าง zip
จากพวกมันในที่เก็บข้อมูลเดียวกัน
ฉันใช้ไลบรารีนี้ https://github.com/orangewise/s3-zip และฉัน ฉันกำลังทดสอบทุกประการเหมือนกับตัวอย่างนี้: https://github.com/orangewise/s3-zip/blob/master/aws_lambda.md
ฉันเพิ่งทำการทดสอบที่ให้เส้นทางของสองไฟล์เป็นอินพุต หนึ่งในนั้นมี 2 MB และอันที่สอง 58 KB และเป็นประเภท docx
และ doc
เหตุการณ์การทดสอบมีลักษณะดังนี้:
{
"region": "eu-west-1",
"bucket": "bucket_name",
"folder": "folder_name/",
"files": [
"file1.doc",
"file2.docx"
],
"zipFileName": "test.zip"
}
ฉันได้รับรายงานการทดสอบนี้
START RequestId: xxx Version: $LATEST
2016-07-26T20:40:02.084Z xxx event {
region: 'eu-west-1',
bucket: 'bucket_name',
folder: 'folder_name/',
files: [ 'file1.doc', 'file2.docx' ],
zipFileName: 'test.zip' }
2016-07-26T20:40:02.765Z xxx append to zip file1.doc
2016-07-26T20:40:04.364Z xxx append to zip file2.docx
2016-07-26T20:40:04.364Z xxx end -> finalize
2016-07-26T20:40:07.066Z xxx { loaded: 3011247,
total: 3011247,
part: 1,
key: 'folder_name/test.zip' }
2016-07-26T20:40:08.232Z xxx { ETag: '"xyz"',
Location: 'https://bucket_name.s3.amazonaws.com/folder_name/test.zip',
key: 'folder_name/test.zip',
Key: 'folder_name/test.zip',
Bucket: 'bucket_name' }
END RequestId: xxx
REPORT RequestId: xxx Duration: 6149.09 ms Billed Duration: 6200 ms Memory Size: 128 MB Max Memory Used: 75 MB
ซึ่งหมายความว่า Amazon lambda ต้องใช้เวลามากกว่า 6 วินาทีในการทำงาน ดูเหมือนว่าจะช้า ฉันจะทำให้เร็วขึ้นได้ไหม? ฉันได้ลองเพิ่มหน่วยความจำให้กับแลมบ์ดาแล้วโดยไม่มีผลลัพธ์ใด ๆ
สิ่งสำคัญที่ฉันอัปโหลดแลมบ์ดาเป็น zip เนื่องจากฉันต้องการการพึ่งพา node_modules สำหรับไลบรารีนี้ที่ฉันใช้