This article suggests a solution for the timeout issue you might have, when performing operations with large categories (1k+ plus products).
Prerequisites: The Stores > Configuration > CATALOG > Catalog > Use Categories Path for Product URLs option is set to Yes for your store view.
Steps to reproduce
Expected result:
Category is saved successfully.
Actual result:
After five minutes of saving process, the 504 gateway timeout error page appears.
The process takes longer than the server’s configured timeout.
Disabling the Generate “category/product” URL Rewrites option will remove all category/product URL rewrites from the database, and significantly decrease the time required for the operations with big categories.
Turning this option off will result in permanent removal of category/product URL rewrites without an ability to restore them.
To disable the Generate “category/product” URL Rewrites option:
bash bin/magento cache:clean
or in the Commerce Admin under System > Tools > Cache Management.Now you can proceed to adding products to categories, or moving categories with a large number of products, and these operations will take much less time and should not cause timeout.
Automatic Product Redirects in our user guide.