Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xExchOABVirtualDirectory: Large numbers of Offline Address Books cause scaling issue #447

Open
jrdbarnes opened this issue Mar 31, 2020 · 1 comment
Labels
enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community.

Comments

@jrdbarnes
Copy link

When using xExchOABVirtualDirectory with large numbers of offline address books, this resource takes a very long time to test.

For example we have approximately 65 thousand OABs and in testing with Invoke-DscResource, this resource took 2321 seconds to complete.

This was using a relatively simple configuration:

$invokeParams = @{
    Name       = 'xExchOabVirtualDirectory'
    ModuleName = @{
        modulename    = 'xExchange'
        moduleversion = '1.27.0.0'
    }
    Method     = 'test'
    Property   = @{
        'identity' = 'servername\OAB (Default Web Site)';
        'allowServiceRestart' = $true;
        'internalURL' = 'https://domainname.tld/OAB';
        'externalURL' = 'https://domainname.tld/OAB';
        'credential' = $cred
    }
}
Invoke-DscResource @InvokeParams

I think the issue exists here:
https://github.com/dsccommunity/xExchange/blob/078fd0883cf2f5560513bd3a4ee0187aee32182a/source/DSCResources/MSFT_xExchOabVirtualDirectory/MSFT_xExchOabVirtualDirectory.psm1#L87-L97

I think there are two fixes which could be applied:

  1. Using += to generate an array inside a foreach is costly in PS5, it could be replaced with a select-object?
$oabs = Get-OfflineAddressBook @PSBoundParameters | Where-Object {$_.VirtualDirectories -like "*$($Identity)*"} | Select-Object -ExpandProperty Name
  1. Wrap these lines inside If($PSBoundParameters.ContainsKey('OABsToDistribute')) as Test and Set both do.
@mhendric
Copy link
Contributor

Hi @jrdbarnes , thanks for the submission. I agree, the += on the array could definitely cause perf issues if a large number of OAB's are returned by Get-OfflineAddressBook. That said, are you sure that's actually where the delay is? Might be worthwhile adding some custom Write-Verbose logging with time stamps throughout that code section to confirm where the delay is. Given your sample config, I would expect:

Get-OfflineAddressBook @PSBoundParameters | Where-Object {$_.VirtualDirectories -like "*$($Identity)*"}

to translate to:

Get-OfflineAddressBook @PSBoundParameters | Where-Object {$_.VirtualDirectories -like "*servername\OAB (Default Web Site)*"}

I wouldn't expect that to return more than one OAB, unless that server has multiple OAB's, and all start with 'OAB (Default Web Site)'. My thinking is that if anywhere, this is actually getting delayed by the Get-OfflineAddressBook call, before the Where-Object filter is even applied. If that is the case, the correct fix may be to update the Get-OfflineAddressBook call to use the -Identity parameter (and possibly fall back to the existing method if it fails).

@johlju johlju added enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community. labels Oct 3, 2021
@johlju johlju changed the title xExchOABVirtualDirectory Large numbers of Offline Address Books cause scaling issue xExchOABVirtualDirectory: Large numbers of Offline Address Books cause scaling issue Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community.
Projects
None yet
Development

No branches or pull requests

3 participants