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

Provide compute resource guidance for OPA deployments #1601

Closed
tsandall opened this issue Jul 31, 2019 · 9 comments · Fixed by #2310
Closed

Provide compute resource guidance for OPA deployments #1601

tsandall opened this issue Jul 31, 2019 · 9 comments · Fixed by #2310
Assignees
Labels

Comments

@tsandall
Copy link
Member

It's common for people to ask how many CPU and memory resources to give to OPA for specific use cases (e.g., admission control, microservice API authorization, etc.) The answer will depend on what the target latency should be (e.g., 1ms for microservice API authorization) and what kind of platform OPA is running on. It would be great if we could provide recommendations for typical platforms (e.g., Kubernetes on AWS) for common use cases.

@omerlh
Copy link
Contributor

omerlh commented Nov 26, 2019

Hey, any update about this? I'm also experiencing high CPU usage and I wonder if it's normal. Such documentation could help me understand it better.

@tsandall
Copy link
Member Author

@omerlh if you can provide some more detail? Like the original comment says, it's going to depend on a bunch of variables. There is no single correct answer.

@omerlh
Copy link
Contributor

omerlh commented Nov 26, 2019

Yep, I was reading all the issues and we're actually considering to move to use GRPC instead of http to see if it will improve the performance.
We noticed that OPA takes up to 300 milicore per pod - which is a lot. I need to find more details about the impact on timing. Attached is the ppref output.
profile001

@omerlh
Copy link
Contributor

omerlh commented Nov 27, 2019

I just took another CPU profile today, see it attached. During this time we had ~500 requests per second to the container. Hope this helps :)
profile002

@jin09
Copy link

jin09 commented Jan 10, 2020

Is OPA capable of leveraging multiple CPUs? Looks like opa run -s runs the server in single concurrency mode. How shall we leverage multiple cores with OPA server?

@tsandall
Copy link
Member Author

@jin09 by default, the OPA server (opa run -s) uses all available cores. You can limit this with GOMAXPROCS. What makes you think the server is only capable of using a single core?

@jin09
Copy link

jin09 commented Jan 10, 2020

@tsandall pardon me for gaps in my understanding. I come from python background and have never worked on go. So when I spin the server (opa run -s) I see only a single process running (ps -elf | grep opa) which is why I thought maybe opa is single threaded. Do we use some prefork model, or is it something specific to golang? Probably you can redirect me to some resources where I could learn about it and get my concepts cleared.

Thanks

@tsandall
Copy link
Member Author

tsandall commented Jan 10, 2020 via email

@patrick-east
Copy link
Contributor

Just to chime in on the python concurrency model vs golang. Python is limited to a single core by the interpreter and its global lock. It doesn't actually run >1 thread in parallel, execution of threads can be interleaved but always on the same single CPU. That is why for Python applications to use >1 CPU you need to fork into multiple python processes (or put the python scripts behind something that does it for you like gunicorn or whatever). Essentially in python multi-threaded != multi-core, but multi-process can be multi-core. Hence why you are used to seeing >1 process if you check on the server.

Golang, like c/c++/java/etc, uses real system threads which the OS schedules over any of the CPUs on the host. This means that multi-threaded in these languages does imply it can/will be distributed over multiple CPU's.

There is a good post here https://stackoverflow.com/a/4496918/4789546 which gives more details

@tsandall tsandall self-assigned this Apr 16, 2020
tsandall added a commit to tsandall/opa that referenced this issue Apr 17, 2020
There are many ways this question can be answered so this is not a
final answer but instead a starting point. In the future we can expand
on this section to include more use-case specific resource utilization
guidance however for the time being this is a good start.

Fixes open-policy-agent#1601

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
tsandall added a commit that referenced this issue Apr 17, 2020
There are many ways this question can be answered so this is not a
final answer but instead a starting point. In the future we can expand
on this section to include more use-case specific resource utilization
guidance however for the time being this is a good start.

Fixes #1601

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants