vmware-archive / powernsx

PowerShell module that abstracts the VMware NSX-v API to a set of easily used PowerShell functions
173 stars 89 forks source link

Get-NsxService slow / cache to speedup the lookup process #522

Open ghost opened 6 years ago

ghost commented 6 years ago

Hello,

I'm working on microsegementation implementation. I noticed that the Get-NsxService commandlet was slow (could take up to 1 minute to complete). After running the debug I noticed it will get all services via the rest API. The NSX manager currently has ~30000 service objects so that will course the delay.

Is there a way that Get-NsxService can cache the outcome of the REST API call so there is no extra stress on the NSX manager and we only have to fetch the applications once?

nmbradford commented 6 years ago

At this stage, no, there is no caching mechanism in PowerNSX. We are aware of the issue (services is not the only affected area of the API) but the overhead of building a flexible caching mechanism isn't something we've had the bandwidth to tackle unfortunately. Generally speaking, if you know you need to do something costly like that more than once, it's best to build your own simple cache by just populating a local collection or hashtable to reference.

ghost commented 6 years ago

@nmbradford thank you for the quick response. I'm going to look into it, first time powershell users so wish me luck.