I’ve never done 5000 extensions before, but we ran into it when attempting large reloads on embedded boxes with slower CPUs. You can try adjusting the reload timeout setting to see if that helps.
It may have changed around, but if you look in [your Web Directory]/admin/views/freepbx_reload.php
Look for the line that starts with “$.ajax({”, and in the properties listed there should be one that says “dataType: ‘json’,”. You can add the timeout as another property by adding “timeout: 7600000,” or whatever time value is appropriate for you. So the final code would end up something like: