How to avoid timeouts on real long page loads
The Drupal Batch API is a great solution for something like this. You can specify or count the number of actions that need to be done, display a progress bar, and prevent timeouts on long processes. Also there are many examples like this one you can utilize to create a good solution for your use-case.