A developer is building a high-throughput backend microservice that processes sensor telemetry events from an Amazon SQS queue. The microservice is written in Java and runs on Amazon ECS. During performance testing under high load, the developer notices high network latency, CPU spikes on the ECS container, and elevated AWS billing charges due to a large number of empty SQS `ReceiveMessage` API calls. Additionally, the application's polling loop exhausts local ephemeral port resources.
Which two actions should the developer take to optimize the SDK client and reduce cost and resource utilization? (Choose two.)
- Configure the SQS client as a static or singleton instance within the application to enable HTTP connection pooling and reuse TCP connections.Cevap
- Set the `WaitTimeSeconds` parameter to seconds during the `ReceiveMessage` API call to enable long polling.Cevap
- CHardcode the AWS IAM access keys in the SQS client builder configuration to bypass the default credential provider chain lookup latency.
- DSet the SQS queue's visibility timeout to seconds to ensure that messages are immediately available for other ECS tasks to process if a task fails.
- EEnable AWS X-Ray active tracing on the ECS task definition, but do not instrument the SQS client within the Java application code.
Cevap
The developer should configure the SQS client as a static or singleton instance to enable connection pooling and reuse TCP connections, and set the WaitTimeSeconds parameter to seconds during ReceiveMessage calls to enable long polling.
Configuring the SQS client as a static or singleton instance ensures that the underlying HTTP client reuses TCP connections via keep-alive, resolving ephemeral port exhaustion. Setting the WaitTimeSeconds parameter to seconds enables SQS Long Polling, which instructs Amazon SQS to wait until messages are available in the queue before responding, thereby eliminating empty responses, lowering API costs, and reducing container CPU usage.
Adım Adım Çözüm
Anahtar Kavram
Optimizing SQS polling and AWS SDK client lifecycles for high-throughput and cost efficiency.