expertstatsplugin icon indicating copy to clipboard operation
expertstatsplugin copied to clipboard

AJAX Post Unending Loop causing API hammering

Open duplaja opened this issue 5 years ago • 7 comments

Last night, ajax posts to wp-admin/admin.php?page=codeable_transcactions_stats appeared to be stuck in a loop.

I checked my site access logs, and it tried calling it about 50,000 times last night, resulting in a temporary IP ban from the Codeable API.

It looks like at some point the API timed out (possibly after my IP ban from the API), but the plugin kept attempting indefinitely.

duplaja avatar Feb 04 '20 14:02 duplaja

I saw General posted this in expert lobby... related?

Matjaz Muhic 5:24 AM @here just a quick update: We've deployed a patch to our API that restricts per_page parameter to max 50 items per page. We've had bunch of incidents over last few months when people turn on some scripts or the WP expert stats plugin and it starts bashing our API causing response times to skyrocket and making usage of the App and API for other experts and client quite unpleasant. If anyone relies on some of the endpoints returning more than that, let's create a thread and discuss it there. I know Marius relies on listing more comments to determine if client answered his own comment. But querying 999 comments per page is not the best solution. :slightly_smiling_face: If you give us some examples we can maybe make some quick modifications or additions where possible. Thank you for your understanding! :handshake:

raleighleslie avatar Feb 04 '20 14:02 raleighleslie

Definitely related. It also pushed my CPU usage to 130% of the threshold on my VPS ($20 Linode droplet).

Your Linode has exceeded the notification threshold (90) for CPU Usage by averaging 130.9% for the last 2 hours.

duplaja avatar Feb 04 '20 14:02 duplaja

I just tried locally and I don't have any issues

What are your settings here wp-admin/admin.php?page=codeable_settings for Stop pulling tasks after page ?

I've set it on 2 so it doesnt go ALL the way back

On Tue, 4 Feb 2020 at 16:37, Dan D. [email protected] wrote:

Definitely related. It also pushed my CPU usage to 130% of the threshold on my VPS ($20 Linode droplet).

Your Linode has exceeded the notification threshold (90) for CPU Usage by averaging 130.9% for the last 2 hours.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/codeablehq/expertstatsplugin/issues/54?email_source=notifications&email_token=AAS6RJRMLMIIFQ424KWVWIDRBF4R5A5CNFSM4KPX2QW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKX3BBQ#issuecomment-581939334, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAS6RJTTHVYPKFEJTCPTPIDRBF4R5ANCNFSM4KPX2QWQ .

PanosSynetos avatar Feb 04 '20 15:02 PanosSynetos

I've just used the default settings. I used it a day or two ago with no issues. The only thing I can think of is that I might have closed out the browser while it was still pulling / updating.

duplaja avatar Feb 04 '20 15:02 duplaja

Can you give it a try with 2 days and let me know how it behaves?

PanosSynetos avatar Feb 04 '20 15:02 PanosSynetos

Everything seems to be working fine with 2 days. I ran it with 0, and it worked as well. This has been a one-off occurrence, and haven't been able to recreate. Unfortunately, with the message from Matjaz in the workroom, even a once-off occasionally from any of the users can cause huge issues.

Is there a maximum number of API endpoint retries that the plugin attempts before aborting? The only other thing I can think is that if there isn't, there were some other (non expert stats plugin related) script API issues with another expert's scripts going on at the same time, that might have caused time-outs. I'm wondering if he and I set up a sort of feedback loop, where due to things timing out, both of our scripts kept retrying and hitting the endpoints.

duplaja avatar Feb 04 '20 16:02 duplaja

Is there a maximum number of API endpoint retries that the plugin attempts before aborting

I don't know, maybe @stracker-phil can help us out here?

The "thing" is, that the plugin will pull data ONLY when we have the page open, so one way or another we'll see if it failed or takes too long to complete. It doesn't run in the background (unless you leave the tab open)

PanosSynetos avatar Feb 05 '20 05:02 PanosSynetos