Fix performace issues for over 30k users
NickGreen opened this issue · 2 comments
When Safety Net is activated on a site with a large number of users, it takes a while to run its auto-deletion, sometimes resulting in timeouts or 504s.
- 30k users on Pressable, it finishes after about 4.5 minutes, just under what I'm assuming is the 5 minute PHP limit
- 50k users, it 504s
You can test this by spinning up a test site on Pressable, and using wp user generate --count=10000
a few times to generate fake users with meta.
If you want to test more than once on the same site, you'll also need to delete the safety_net_data_deleted
option that gets set after the deletion function completes.
This came up here: #46
I think the solution to this is going to be to remove the foreach
loop here:
safety-net/includes/delete.php
Lines 42 to 53 in 0c42f1c
And replace it with 2 DB calls to delete the usermeta and users that are NOT IN an array of admin user IDs.