{"action":"created","issue":{"url":"https://api.github.com/repos/disqus/disqus-wordpress/issues/113","repository_url":"https://api.github.com/repos/disqus/disqus-wordpress","labels_url":"https://api.github.com/repos/disqus/disqus-wordpress/issues/113/labels{/name}","comments_url":"https://api.github.com/repos/disqus/disqus-wordpress/issues/113/comments","events_url":"https://api.github.com/repos/disqus/disqus-wordpress/issues/113/events","html_url":"https://github.com/disqus/disqus-wordpress/issues/113","id":165909688,"number":113,"title":"dsq_sync_forum floods cron every second and destroys entire sites/servers","user":{"login":"archon810","id":469543,"avatar_url":"https://avatars.githubusercontent.com/u/469543?v=3","gravatar_id":"","url":"https://api.github.com/users/archon810","html_url":"https://github.com/archon810","followers_url":"https://api.github.com/users/archon810/followers","following_url":"https://api.github.com/users/archon810/following{/other_user}","gists_url":"https://api.github.com/users/archon810/gists{/gist_id}","starred_url":"https://api.github.com/users/archon810/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/archon810/subscriptions","organizations_url":"https://api.github.com/users/archon810/orgs","repos_url":"https://api.github.com/users/archon810/repos","events_url":"https://api.github.com/users/archon810/events{/privacy}","received_events_url":"https://api.github.com/users/archon810/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2016-07-16T05:32:19Z","updated_at":"2016-08-02T04:53:16Z","closed_at":"2016-07-21T22:13:35Z","body":"I'm going to open a proper ticket for this issue because none of the existing tickets and pull requests are descriptive enough, and what ends up happening is because of Disqus' cron jobs, entire servers go down and catch fire.\r\n\r\nHere are some relevant urls for starters:\r\n\r\n- https://wordpress.org/support/topic/high-server-load-and-dsq_sync_forum-problem - a topic about this on WP.org.\r\n\r\n- The reason for why what Disqus does, which is create a cron entry every second on busy sites, is so bad (this is WP's fault): https://core.trac.wordpress.org/ticket/15148#comment:9\r\n\r\n- https://gist.github.com/502d43fadb2afc085bd8d8ab0866a8db - a Crontrol dump of all cron jobs I took earlier today, showing that dsq_sync_forum was created over 7500 times up to that point, once every second.\r\n\r\n- https://github.com/disqus/disqus-wordpress/blob/0f5b52af38f690342f9fd794f8af0403898547fb/disqus/disqus.php#L513 - the relevant scheduler location which basically schedules an event 5 min into the future every time cf_action = sync_comments, which seems to be every second for us (tens of thousands of people on the site at the same time).\r\n\r\nEven if WP's flawed single db entry cron were to be fixed, the fault is still with the code above because it over-schedules so aggressively that no amount of cron-running stands any chances of catching up. \r\n\r\nThe immediate resolution would be instead of blindly scheduling a dsq_sync_forum job, to check if one exists first.\r\n\r\nA much better solution, though, is to schedule a 5-minutely recurring job once and forget all this sync_comments nonsense that only ends up adding millions of requests to server logs. This can easily be done using this technique: https://codex.wordpress.org/Plugin_API/Filter_Reference/cron_schedules.\r\n\r\nThank you in advance for quick fixes. Our and I'm sure your own servers will thank you."},"comment":{"url":"https://api.github.com/repos/disqus/disqus-wordpress/issues/comments/236797311","html_url":"https://github.com/disqus/disqus-wordpress/issues/113#issuecomment-236797311","issue_url":"https://api.github.com/repos/disqus/disqus-wordpress/issues/113","id":236797311,"user":{"login":"Crunchify","id":8164601,"avatar_url":"https://avatars.githubusercontent.com/u/8164601?v=3","gravatar_id":"","url":"https://api.github.com/users/Crunchify","html_url":"https://github.com/Crunchify","followers_url":"https://api.github.com/users/Crunchify/followers","following_url":"https://api.github.com/users/Crunchify/following{/other_user}","gists_url":"https://api.github.com/users/Crunchify/gists{/gist_id}","starred_url":"https://api.github.com/users/Crunchify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Crunchify/subscriptions","organizations_url":"https://api.github.com/users/Crunchify/orgs","repos_url":"https://api.github.com/users/Crunchify/repos","events_url":"https://api.github.com/users/Crunchify/events{/privacy}","received_events_url":"https://api.github.com/users/Crunchify/received_events","type":"User","site_admin":false},"created_at":"2016-08-02T04:53:16Z","updated_at":"2016-08-02T04:53:16Z","body":"Tried fix https://github.com/disqus/disqus-wordpress/commit/ba0a89ef21e74849c7138052696b4c02c857b72c on site and it worked. Also, I would suggest to increase 5 min time to 1 hr. \r\n\r\nThere is no advantage syncing comment every 5 min than 1 hour or 6 hrs. Comments will be added to WP DB every 1 hr instead of 5 min :)"}}
{"actor":{"display_login":"Crunchify"}}