-
Notifications
You must be signed in to change notification settings - Fork 18
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
Get User Timeout on Tenants with many users. #207
Comments
The diff was not displayed correctly. |
Hi @IronBernd you make a fair point that searching for a user via email takes some time. I would say this isn't the fault of pyZscaler though, let me explain my reasoning:
So what we have here is that both the current implementation and your suggested approach don't really do anything additional; we're still pulling the entire list and using a generator expression to iterate through and stop when we find a match, returning that result. The bottleneck here is the amount of time it takes for ZIA to return the list of users via API. The only way to fix this would be to log a request with Zscaler to either:
I'm going to leave this issue open as the only 'fix' here is to clean up the current implementation to move it from: elif email:
user = (record for record in self.list_users(search=email) if record.email == email)
return next(user, None) to elif email:
user = (record for record in self.list_users() if record.email == email)
return next(user, None) Let me know what you think? I don't think there's anything we can do here. |
Hello @mitchos, Thank you for the excellent response. The Zscaler API is providing the following search criteria for users:
Two example user: The interesting thing is: The API will find the user. In the Zscaler Documentation, you will find this: Maybe this will help. Kind regards, |
Recently i have tshooted, that my app segments were getting no resource found from API server. After opening TAC case they fixed it globally.. But that tshooting took me to interesting workaround - by default pagesize parametr equals to 20. (during that time api call took around 16 seconds with 200 app segments). When i added kwarg pagesize = 499 (that is max according to documentation, but it accepts bigger vaules) it took only 3 second. In zpa parameter is "pagesize", for zia it should be entered as page_size, and it should be automatically translated to "pageSize" key. You may try this workaround... |
@martinkiska that's a great workaround and I didn't even think about the pagesize. @IronBernd would you mind comparing the time for a What I might do is change the API call to max out the page size to get some more efficiencies for the larger userDBs out there if you find that fixes the timeout issue. e.g. elif email:
user = (record for record in self.list_users(page_size=1000) if record.email == email)
return next(user, None) |
Hello, List of Timing: users.list_users(page_size=499, max_pages=500): zia.users.list_users(page_size=1000, max_pages=500) real 6m24.488s And this is not an issue with the internet line. |
Oh wow that's a lot of time blocked waiting for I/O. The only way we could get around this is to write an async method for any API calls that might have a huge number of entries returned... except we have a rate limit of 1 per second which means we can't use an exponential function to increase the amount of threads. We'd have to drip-feed our requests at a rate of 1 per second. Our efficiency over single-threading is capped by the amount of time it takes for an API call to return (I'm getting around 11-13 seconds consistently). So to get 50k users as quick as possible using async, I'm calculating the below:
That's still a performance increase of 10x if you're comparing against the last test with a page size of 1000 @IronBernd. I don't think waiting 5min+ to search for a user by email across 50k users is a very good result. Having said that, I don't think it's the responsibility of pyZscaler to 'fix' this for Zscaler, but we did add a capability that wasn't there natively so it's a two-way street here. I'm happy to investigate this option if we think this might be of value? |
btw, just tried to increase the page_size parameter to 20k, as there is no limitation mentioned on the ZIA API reference guide and it worked. 10k users in 16 seconds, that is much better ;). Without this customization, it took around 2min 50sec. @IronBernd you may try to increase it even to 50k so it will be downloaded in one batch. Then it should be only about TCP delays (for me delay between syn and syn+ack is 100ms, which is quite a lot [zsapi.zscaler.net]). |
Describe the bug
There is an issue with the get_user call.
This issue occurs only if there are many users.
To Reproduce
Steps to reproduce the behavior:
user = zia.users.get_user(user_id='82553113')
print(user)
The API is using zia.users.get_list, as there are more then 50.000 users there will be too many requests.
The Solution may by:
My solution will be:
elif email:
Expected behavior
Get the requested user.
Kind regards
Bernd Wollny
The text was updated successfully, but these errors were encountered: