A company has an application that ingests incoming messages. Dozens of other applications and microservices then quickly consume these messages. The number of messages varies drastically and sometimes increases suddenly to 100,000 each second. The company wants to decouple the solution and increase scalability.
Which solution meets these requirements?
A. Persist the messages to Amazon Kinesis Data Analytics. Configure the consumer applications to read and process the messages.
B. Deploy the ingestion application on Amazon EC2 instances in an Auto Scaling group to scale the number of EC2 instances based on CPU metrics.
C. Write the messages to Amazon Kinesis Data Streams with a single shard. Use an AWS Lambda function to preprocess messages and store them in Amazon DynamoDB. Configure the consumer applications to read from DynamoDB to process the messages.
D. Publish the messages to an Amazon Simple Notification Service (Amazon SNS) topic with multiple Amazon Simple Queue Service (Amazon SOS) subscriptions. Configure the consumer applications to process the messages from the queues.
D
技巧:排除明顯錯誤選項,在沒有明顯錯誤的選項中選擇最合理的選項。
某公司有一個應用程序負責接收消息,有數十個其他應用程序和微服務應用都需要迅速消費這些消息。消息的數量變化很大,有時會突然增加到每秒10萬條。公司希望解耦解決方案并提高可擴展性。
A. 不正確。使用 Amazon Kinesis Data Analytics。Amazon Kinesis Data Analytics 主要用于實時分析數據流,而不是作為消息隊列或消息中間件。它不適合直接用于消息的持久化和消費。
B. 不正確。在Auto Scaling組中的Amazon EC2實例上部署應用程序。Auto Scaling 可以根據CPU 指標自動調整 EC2 實例的數量,但這主要解決的是計算資源的彈性伸縮問題,而不是消息傳遞和消費的問題。此外,這種方法并沒有實現消息系統的解耦。
C. 不正確。使用 Amazon Kinesis Data Streams 和單個分片。使用Amazon Kinesis Data Streams 是一個消息流服務,但使用單個分片是不合適的。因為 Kinesis Data Streams 的每個分片有一個每秒1 MB的輸入限制和每秒2 MB的輸出限制(對于增強型分片,這些限制更高,但單個分片仍然不足以處理每秒10萬條消息的高負載)。此外,雖然Lambda函數可以用于預處理消息并將其存儲在DynamoDB中,但這種方法增加了系統的復雜性和延遲。
D. 正確。使用 Amazon SNS和多個 Amazon SQS 訂閱。Amazon SNS(簡單通知服務)是一個高度可擴展的、靈活的發布/訂閱消息傳遞服務。它允許將消息發送到多個訂閱者,這些訂閱者可以是SQS隊列、HTTP/HTTPS端點、Lambda函數等。在這個場景中,使用SNS發布消息,并讓多個SQS隊列訂閱這些消息是合適的。每個消費者應用程序可以從其專用的SQS隊列中讀取消息進行處理,這樣實現了消息的解耦和可擴展性。此外,SQS隊列可以自動擴展以處理任意數量的消息,無需人工干預。