In one of my plugins, I need to insert about 1000 terms into a custom taxonomy while installing a plugin. I see it's sometimes causing
500 internal server error. How can I split that work or prevent it from giving an error?
Are your database tables using the InnoDB engine? If so, and the plugin is just for your website, start a transaction, run the inserts, commit the transaction (or rollback on error).