disqus / disqus-wordpress-plugin

WordPress plugin for Disqus (Latest version)
https://disqus.com/
34 stars 25 forks source link

Throttle manual comment-sync requests to prevent ERR_INSUFFICIENT_RESOURCES #96

Closed tterb closed 3 years ago

tterb commented 3 years ago

Description

We received a report from AndroidPolice that their manual syncing was failing with an ERR_INSUFFICIENT_RESOURCES error. This is likely due to the fact that each comment that is synced makes a separate request, so manually syncing large sites could result in >1000 parallel requests. In response, these changes limit the number of parallel comment-sync requests to 100, which should increase stability but we also expect it to slightly increase the time it takes to manually sync a large number of comments. Because of this, I've also added additional progress logging to the manual-sync process.

Unfortunately, I wasn't able to actually reproduce the ERR_INSUFFICIENT_RESOURCES error prior to limiting the requests so I'm assuming that this could have to do with available resources and hardware capabilities, though I did get some comments failing to sync and Danny mentioned that he saw sync requests that were returning 200's but weren't actually getting synced in the WP database.

The reasoning for setting the parallel request limit to 100 was influenced by the initial report citing that they got the ERR_INSUFFICIENT_RESOURCES error after a couple of hundred requests were sent, though I'm still open to adjusting this threshold.

There was also a version that was incorrect in the last disqus/README.txt changelog update, so I threw that fix in there too.

Motivation and Context

Received a report from AndroidPolice that their manual syncing was failing with an ERR_INSUFFICIENT_RESOURCES error.

How Has This Been Tested?

Tested on a production WordPress site with the following workflow:

  1. Change the "Plugin Name" in disqus/disqus.php to differentiate from the production plugin
  2. Run make js && zip -r disqus.zip disqus
  3. Go to the WP admin and go to Plugins > Add new
  4. Click the "Upload Plugin" button at the top of the page
  5. Upload the zip created in step 2
  6. Deactivate the existing Disqus plugin and activate the newly uploaded version
  7. Go to the Disqus page in the WP admin and click the "Syncing" tab
  8. Click "Manually Sync Comments" and enter a date range containing a >1000 comments
  9. Click "Run Manual Sync"

Types of changes

Checklist:


This change is Reviewable

archon810 commented 3 years ago

Cheers for the upcoming fix.