Hi guys I am relatively new to GO and I already love it. As my first project I want to build a simple web API. And I use the chi router for it.
In the past I used Python for my webserver and I had NGINX as reverse proxy and then GUNICORN prefork workers, I think something like number of CPU cores plus one, in the RAM that had my DJANGO backend ready.
For my GO project I want to keep NGINX for SSL and caching and point from there to my GO backend API. (I plan on using DOCKER to learn it)
The question is now how are the multiple cores of my server used? Do I have to start multiple DOCKER containers of the GO backend? One for each Core? Or is the multiple core support handled within the chi router already build in? Or do I have to include my own implementation of go functions goroutines? in my single instance?
something like:
v1Router := chi.NewRouter()
// option from a tutorial I followed:
v1Router.Get("/healthz",handlerReadiness)
// option with goroutine do I have to use it like this to use all cores well?
v1Router.Get("/healtz", func(w http.ResponseWriter, r *http.Request) {
go handlerReadiness(w, r) // handle each request in a new goroutine
})
// the handler FYI:
package goback
import "net/http"
func handlerReadiness(w http.ResponseWriter, r *http.Request) {
respondWithJSON(w, 200, struct{}{})
}
I hope my question is clear. If not I am happy to clarify what I want.
Thank you for your help.