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

ref: GOMAXPROCS=1 #288

Merged
merged 2 commits into from
Sep 25, 2024
Merged

Conversation

vorandrew
Copy link
Contributor

@vorandrew vorandrew commented Sep 25, 2024

Due to concurrency nature of Golang you should also set GOMAXPROCS=1 to make results comparable, otherwise Go uses threads = max cores to serve requests but node uses only 1 thread. Also take notice if you were running on instances with more cores Golang results would be even higher with same CPU limits

@antonputra
Copy link
Owner

@vorandrew well, actually, i was thinking of giving each application 1 CPU and instead running 2 replicas. i left another question in #287

@antonputra
Copy link
Owner

@vorandrew @agravelot Last question: I just want to make it as 'fair' as possible. I use m7a.xlarge EC2 instances and deploy each application on its own instance. I set the CPU limit to 2000m and 256Mi of memory. I understand that by setting GOMAXPROCS=1, I potentially reduce the performance of Go. Is that fair to say? What setup would you suggest to make it fair without explicitly limiting Go's performance?

@vorandrew
Copy link
Contributor Author

vorandrew commented Sep 25, 2024

Golang uses concurrency vs single threaded NodeJS. Internal goroutine scheduler makes it even more efficient rather then system threads scheduler

@vorandrew
Copy link
Contributor Author

vorandrew commented Sep 25, 2024

@antonputra IMO. You should set same cpu limit for both apps - it will make both apps even in terms of throttling. On top of this you should neutralise concurrency effect of golang by setting GOMAXPROCS=1

@antonputra
Copy link
Owner

@vorandrew I understand that, but that's the whole point of Go, isn't it? I can make it 'fair' on one side, but then I'll get a lot of criticism from the Go community 😊.

@agravelot
Copy link

agravelot commented Sep 25, 2024

This is a good reference for a very restricted server, which is not very representative of high-demand systems.
For highly scalable systems, you can use multi nodejs replicas against 1-2 replicas for golang. As long as your total limits "match".

In any case, the benchmarking methodology must answer a specific question. Otherwise, there is many answers for a multitude of specific uses.

@vorandrew
Copy link
Contributor Author

IMO. Golang is beating NodeJS in performance because it's concurrency model is better. You can nerf this to make comparison as close as possible, but should we?

@antonputra
Copy link
Owner

I don't think it's a big deal. I'll just run two tests and share the results, one with GOMAXPROCS=1 and one without. Let's see how Node's standard library compares to Go.

@antonputra antonputra merged commit 84ae1a6 into antonputra:main Sep 25, 2024
Comment on lines +40 to +42
env:
- name: GOMAXPROCS
value: 1
Copy link

@DarVoid DarVoid Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you ever want to run it with the limits of the container here:

- name: GOMEMLIMIT
  valueFrom:
    resourceFieldRef:
      resource: limits.memory
- name: GOMAXPROCS
  valueFrom:
    resourceFieldRef:
      resource: limits.cpu

Copy link

@DarVoid DarVoid Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants