When connecting to AWS SQS using AWS SDK, there seems to be a noticeable delay.
It is not so important when starting up a service to consume messages since after a 3-7 second delay on the first connection, the messages start flowing at a good speed -
BUT, when publishing messages it is a big problem. For example a user web request takes a few extra seconds to complete because of the connection to AWS is waiting to publish the message. This defeats the purpose of sending a message out in order to defer the wait time to a background job.
Is this a problem fixed with DNS? Networking? Or is it an AWS SQS setting? My web app is not in AWS network not sure if thats an issue.
Simple publishing a message code:
$aws = \Aws\Common\Aws::factory(/* array with connection settings */);
$client = $aws->get('Sqs');
$queue = $client->getQueueUrl(['QueueName' => $queue]);
// This takes 3 - 5 seconds every time its called.
$res = $this->client->sendMessage([
'QueueUrl' => $queue['QueueUrl'],
'MessageBody' => json_encode($request)
]);