grahamr975 / EWS-Office365-Contact-Sync

Uses Exchange Web Services to synchronize a Global Address List in Office 365 to a user's mailbox
MIT License
99 stars 21 forks source link

Performance / Speed Issue #1

Closed Floyz closed 4 years ago

Floyz commented 5 years ago

Hello ! I'm not sure if this is an issue or expected / standard behavior but each contact take ~4 minutes to create . The script is currently running for 24hours and I have only 417 contacts created on my exchange specified folder. I think the GAL is about 1200 users so it would take a very long time to run this script on DIRECTORY option (or I should take a loop on a csv file with all users adresses and run this script at the same time on all my accounts ) .

I read you run this on DIRECTORY once a week so i'd like to know if you just have few users on your directory or my contact creation speed is abnormal ?

No expected time is written in the readme so I think writting an issue about this is ok ?

Except this, this script is wonderfull and I want to thank you a lot about this, this is so usefull when you need to manage a lot of company mobile devices on Android or iPhones. (native exchange offline gal sync is an option missed from a lot of years now) .

Regards !

grahamr975 commented 5 years ago

The script I currently run weekly is much faster because it deletes the entire folder and re-adds the contacts back in. That version is more of a "nuke it and rebuild" than sync. I'm trying to move away from that version due to the random issues that repeatedly deleting and recreating the entire folder has been causing for my users. You can find that version here

That being said, this new script is under heavily development. It's certainly not optimized yet. Once I'm able to get it working reliably, I'll start working on reducing the runtime.

Thanks for the feedback, Ryan

Floyz commented 5 years ago

Ok I understand better, this script on github is the new version and you are trying to check contact presence in the folder before creating it, instead of wipe/reimport all ?

I'm not sure i can launch this script concurrently if there is an exchange concurrent connection limit on O365, i'll try after my first test and see. If there is no restriction i'd be able to cover my 45 most important users that needs the GAL to get internal caller identification, with I think 72H runtime ~.

grahamr975 commented 5 years ago

Yes, this new version checks contact presence and only removes a contact if the contact has been removed from the GAL. In theory, this means you could run the script on a 24/7 loop and your users wouldn't even notice, as opposed to having the contacts all temporarily vanish when the folder is first deleted.

Unfortunately, for Office 365 Exchange Online PowerShell, you're limited to 3 sessions at a time. Source

Luckily, I only use the Office 365 Exchange Online PowerShell to fetch the list of GAL contacts. This part only takes about 5 minutes. The rest of the script uses the Exchange Web Services API, which does not have this limit. Eventually, I'll multithread this script using Powershell Jobs similar to how my current script is set up.

grahamr975 commented 4 years ago

The script is now significantly faster thanks to the latest update.

You'll notice the largest speed increase for mailboxes that the script has already been used on because it can now skip contacts that don't need any changes.