An application development team is designing a microservice that will convert large images to smaller, compressed images. When a user uploads an image through the web interface, the microservice should store the image in an Amazon S3 bucket, process and compress the image with an AWS Lambda function, and store the image in its compressed form in a different S3 bucket.
A solutions architect needs to design a solution that uses durable, stateless components to process the images automatically. Which combination of actions will meet these requirements? (Choose two.)
A. Create an Amazon Simple Queue Service (Amazon SQS) queue. Configure the S3 bucket to send a notification to the SQS queue when an image is uploaded to the S3 bucket.
B. Configure the Lambda function to use the Amazon Simple Queue Service (Amazon SQS) queue as the invocation source. When the SQS message is successfully processed, delete the message in the queue.
C. Configure the Lambda function to monitor the S3 bucket for new uploads. When an uploaded image is detected, write the file name to a text file in memory and use the text file to keep track of the images that were processed.
D. Launch an Amazon EC2 instance to monitor an Amazon Simple Queue Service (Amazon SQS) queue. When items are added to the queue, log the file name in a text file on the EC2 instance and invoke the Lambda function.
E. Configure an Amazon EventBridge (Amazon CloudWatch Events) event to monitor the S3 bucket. When an image is uploaded, send an alert to an Amazon ample Notification Service (Amazon SNS) topic with the application owner's email address for further processing.
AB
技巧:排除明顯錯誤選項,在沒有明顯錯誤的選項中選擇最合理的選項。
一個應用開發團隊正在設計一個微服務,該服務將大型圖像轉換為較小、壓縮后的圖像。當用戶通過網頁界面上傳圖像時,微服務應將圖像存儲在 Amazon S3 存儲桶中,使用 AWS Lambda 函數處理和壓縮圖像,并將壓縮后的圖像存儲在另一個 S3 存儲桶中。解決方案架構師需要設計一個使用持久、無狀態組件的解決方案,以自動處理圖像。
推薦方案,通過SQS隊列實現事件的異步和持久處理,然后配置Lambda函數從SQS隊列中讀取和處理消息,實現無狀態的處理流程。
A. 正確。創建一個 Amazon Simple Queue Service(Amazon SQS)隊列。配置 S3 存儲桶,當圖像上傳到 S3 存儲桶時,向 SQS 隊列發送通知。通過配置 S3 存儲桶在圖像上傳時發送通知到 SQS 隊列,可以實現事件的異步處理。SQS 隊列作為一個持久、可靠的消息傳遞服務,可以確保事件不會丟失,并且可以被 Lambda 函數按需處理。
B. 正確。配置 Lambda 函數使用 Amazon Simple Queue Service(Amazon SQS)隊列作為調用源。當 SQS 消息成功處理后,刪除隊列中的消息。Lambda 函數可以配置為從 SQS 隊列中讀取消息,并處理這些消息。處理成功后,Lambda 函數會自動刪除隊列中的消息,確保消息不會被重復處理。這種配置實現了無狀態的處理,因為 Lambda 函數不需要維護任何關于已處理消息的狀態。
C. 不正確。配置 Lambda 函數監控 S3 存儲桶的新上傳。當檢測到上傳的圖像時,將文件名寫入內存中的文本文件,并使用該文本文件跟蹤已處理的圖像。Lambda 函數是無狀態的,且其執行環境在每次調用后都可能被回收,因此不能依賴內存中的文本文件來跟蹤已處理的圖像。此外,這種方法也不具備持久性,因為內存中的數據在 Lambda 函數執行結束后可能會丟失。
D. 不正確。啟動一個 Amazon EC2 實例來監控 Amazon Simple Queue Service(Amazon SQS)隊列。當項目被添加到隊列中時,在 EC2 實例上的文本文件中記錄文件名,并調用 Lambda 函數。引入 EC2 實例增加了系統的復雜性和運維成本,而且 EC2 實例是有狀態的,需要維護和管理。此外,使用 EC2 實例來監控 SQS 隊列并調用 Lambda 函數是一種不必要的冗余,因為 Lambda 函數本身就可以直接從 SQS 隊列中讀取和處理消息。
E. 不正確。配置一個 Amazon EventBridge(Amazon CloudWatch Events)事件來監控 S3 存儲桶。當圖像上傳時,向包含應用程序所有者電子郵件地址的 Amazon Simple Notification Service(Amazon SNS)主題發送警報,以進行進一步處理。EventBridge(CloudWatch Events)可以用于監控 S3 存儲桶的事件,但發送 SNS 警報并不是自動處理圖像的有效方法。SNS 主要用于通知和警報,而不是作為事件處理流程的一部分。