If I understand the problem, you said it takes about 30 minutes to put 4000-ish tasks into MS Project. I'm not sure what you meant by 8000 relationships; do you mean predecessors/successors? Perhaps you could clarify? So, what you have is a system made up of 3 components: a data source, a transfer mechanism, and MS Project itself; correct?
This performance surprises me. I whipped up some VBA code (see bottom of post) to test the performance of adding 4000 tasks with various outline levels + predecessors and on my system (Proj 2016, Intel i7, Win 10) it took at most 100 seconds to add the tasks. This tells me that there isn't a bottleneck in Project. I would suspect the bottleneck is in either your data source or the transfer mechanism.
To confirm this, perhaps you could try just adding all of your task (you called them an activity) data to one task's notes property and see what your performance is. A If it is quick, then perhaps try adding the 4000 tasks but with no properties (other than name) and then incrementally add more properties until you find which properties(s) add the slow-down. From my test below, using the task.predecessors property added a 6x performance reduction, the rest had a negligible impact; you may encounter another performance degrading attribute. B But if adding your task data to just one task's notes is still slow, then you have a problem with the data source or transfer mechanism. Maybe you are sending one task (i.e. activity) at a time and instead could build a batch? Whatever the case, isolate the problem and eliminate it.
Good Luck!
Sub add4000tasks()
On Error Resume Next
Dim myTask As task
Dim myProject As Project
resPool = Split("Allice,Bob,Claire,Dave", ",")
For testRun = 0 To &HF '00001111
testPreds = testRun And &H1 '00000001
testOutlines = testRun And &H2 '00000010
testDurations = testRun And &H4 '00000100
testAssignments = testRun And &H8 '00001000
If testPreds Then Debug.Print "Testing Predcessors"
If testOutlines Then Debug.Print "Testing Outlines"
If testDurations Then Debug.Print "Testing Durations"
If testAssignments Then Debug.Print "Testing Resource Assignments"
Application.Projects.Add
Set myProject = ActiveProject
Application.Calculation = pjManual
starttime = Now
Set myTask = myProject.Tasks.Add("Task 0")
For a = 1 To 4000
Set myTask = myProject.Tasks.Add("Task " & a)
If testPreds Then
myTask.Predecessors = Rnd * 10000000 Mod a + 1 'may fail if predecessor is also a parent
End If
If testOutlines Then
If Rnd * 10000000 Mod 10 = 0 And myTask.OutlineLevel < 10 Then
myTask.OutlineIndent
ElseIf Rnd * 10000000 Mod 10 = 1 And myTask.OutlineLevel > 1 Then
myTask.OutlineOutdent
End If
End If
If testDurations Then
myTask.Duration = Rnd * 10000000 Mod 50 & "d"
End If
If testAssignments Then
myTask.ResourceNames = resPool(Rnd * 10000000 Mod UBound(resPool) + 1)
End If
Next
Application.Calculation = pjAutomatic
Debug.Print (Now - starttime) * 86400 & vbCrLf
Application.FileCloseEx (pjDoNotSave)
Next
End Sub