I need to create about 8000 sites in a site collection, based on Title and path attributes from a database table with 8000 records. I wrote a simple console based application in C# that utilizes the Server Object Model and the following algorithm:
Connect to this database and retrieve all the rows in this table Connect to the desired SharePoint Site Collection (SPSite) Foreach row in rows Add a web site under SPSite.RootWeb.Webs using Add method
This application is running on one of the web servers, not sure if that matters. Actual code for child site creation:
/*---- * Create the child web in the site collection. *----*/ using (SPSite siteCollection = new SPSite(siteCollectionUrl)) { using (SPWeb rootWeb = siteCollection.RootWeb) { // Create a new child web in the site collection using the input parameters defining the child web. SPWeb newWeb = rootWeb.Webs.Add(webUrl, title, description, 1033, webTemplate, useUniquePermissions, false); newWeb.Dispose(); } }
The setup is a medium SharePoint 2016 farm with two app servers (MinRole: App + Search) and two web servers (MinRole: Web + Distributed Cache).
The application is still running. At first, creation of the child site was taking about 15 seconds. After about 500 sites, that same operation is taking 40 seconds. Now, at about 1500 sites, site creation is taking 70 seconds. If this pattern keeps growing, I am afraid it will take way too long to create all 8000 sites. What may be the reason for this slow down? Is there any way to optimize and increase the speed of site creation, hopefully dramatically? Because I have to provision several more site collections that are similarly large.