the code you show should take milliseconds, but it depends if your site has queue workers to run the jobs or if they are running sync.
Even then, what on earth are you doing in HandleWebhookJob that could take 30 seconds?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm implementing Shopify webhooks, my current setup works, but it is too slow. Resulting in the deletion of the webhook on Shopify's end. Shopify states
Shopify waits five seconds for a response to each request to a webhook. If there's no response, or an error is returned, then Shopify retries the connection 19 times over the next 48 hours. If there are 19 consecutive failures, then the webhook subscription is automatically deleted. A warning that the subscription will be deleted is sent to the app's emergency developer email address.
My controller takes roughly 30 seconds to respond to the webhook which causes Shopify to delete the webhook after 48 hours since it takes us longer than 5 seconds to respond, I'm looking for a way to speed this up but I am unable to come up with a solution, because the controller does not do anything resource intensive.
My controller looks as follows:
public function handleWebhook($shopname, $hash)
{
$shopDomainHeader = $_SERVER['HTTP_X_SHOPIFY_SHOP_DOMAIN'];
$data = file_get_contents('php://input');
$topic = WebhookTopic::from($_SERVER['HTTP_X_SHOPIFY_TOPIC']);
$verified = $this->verifyWebhook($shopDomainHeader, $hash);
if (!$verified) {
return Response::HTTP_UNAUTHORIZED;
}
$decodedData = json_decode($data, true);
HandleWebhookJob::dispatch($decodedData, $shopName, $topic)->onQueue('webhook');
return Response::HTTP_OK;
}
I know that $verified is true and the job is dispatched, but I feel that above code should not take 30 seconds. How could I speed this up?
Additional information;
10.12.0
API middleware.Please or to participate in this conversation.