Skip to content
Advertisement

What happens if php://input receives simultaneous webhooks?

I wrote an API that takes a WooCommerce webhook and inputs the data into our CRM. I’m using:

file_get_contents("php://input");

The whole script is in one file because it’s so simple.

My question is what happens if php://input receives two or more webhooks at the same time. Would it operate like a queue or could one be potentially dropped?

Reason I ask is we have multiple WC stores and I’m not sure if I need to clone the script for each store or if they could all feed into the same script.

Thanks for the help!

Advertisement

Answer

Just the same as when it receives any other set of http requests…each one is processed separately, usually in the order they arrive. If they should all be processed with the same code, then you only need one script. You don’t make 20 copies of your website homepage just because you might have 20 users, do you? This is no different.

You only need multiple scripts if the scripts must do something different because it’s a different store (and if it’s not possible to know from the request input data which store it should be working with, and vary the behaviour that way). And of course then the scripts would all have different URLs so you’d have to configure the senders to send to different URLs. But that has nothing to do with receiving concurrent requests.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement