Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dtirer@gmail.com's avatar

Inconsistently slow response times - SQS, RDS, Elasticache

I have a Laravel application (5.2) which sends data to SQS on nearly every request. However, every so often, one of these requests takes several seconds to execute. Attached is a stack trace from New Relic. It seems that the tick() method (within CURL) gets called many times and the seconds just pile up. It also seems to be making several attempts to connect to the same endpoint, though they are AWS services so I can't imagine they'd be unresponsive this often.

Any idea why this might occur?

My code is hosted on AWS, on two m4.large instances behind an ELB. In general, the application is operating at a fairly low throughput -- roughly 50 - 100 requests per minute.

stack trace 1: https://ibb.co/f05gLk stack trace 2: https://ibb.co/bDBLfk

What makes this stranger is that this sometimes seems to occur when connecting to RDS and / or Elasticache. And in some cases, just plain ol' PHP processes are slow -- I find things like loading from the Composer Autoloader, or hydating a model can take seconds. However, SQS & CURL seem to be the biggest culprits

0 likes
7 replies
bashy's avatar

So very often, DNS causes issues like this. Does hardcoding an IP for the hostname (/etc/hosts) for SQS make it better? (Not something you want to do on prod btw)

bashy's avatar

@dtirer If you have no staging server, I guess you'll have to test on prod. Ping the domain ping sqs.us-east1.aws.com or ping6 sqs.us-east1.aws.com if it's IPv6 only. Then add that IP to the hosts with the IP. 123.123.123.123 sqs.us-east1.aws.com

dtirer@gmail.com's avatar

@bashy sorry, a bit of confusion there. I do have a staging server. I thought you were saying I shouldn't even implement this solution on production :)

I'll try this out and see what happens. Is this documented anywhere? I would imagine that other would experience this exact same problem with SQS if that were the case

bashy's avatar

@dtirer Ah, my bad. I just meant do this to test if this is the issue. You can resolve it better ways if that is the case.

I have no clue but it's the only thing I could think of.

dtirer@gmail.com's avatar

@bashy not sure thats something I can actually do. When i ping the sqs address, the IP address is always different.

bashy's avatar

@dtirer That's just because they have load balancing but yeah, maybe you won't be able to.

You may be able to try a cURL request manually on the server. That way you can see if it's timing out or just some other error.

Please or to participate in this conversation.