Go Webservice in production

I am writing a webserver in Go. I want to run it in production. How I can set up the server? Should I just run the executable and open the ports (be it VM, Docker or K8). Or is there specific way?

Also, like in Python, we have Gunicorn which is used in production which also gives the option of workers to handle concurrent requests. Is there something similar for Go? I know Go can handle concurrent requests but still workers can balance the load.

1 Like

Generally, put the executable in a container. There are many tools to manage and orchestrate containers. There’s probably already an orchestrator where you plan deploy your code.

Okay. So it means directly running the executable. But is there anytool like Gunicorn or something to start the process in production.

It’s common to launch the application/binary into a container with kubernetes, in front of this you can put some services like nginx, traefik to route yours services and a Load Balancer to route into yours servers from AWS/GCP/Azure
but, there are some tools can help you here https://awesome-go.com

1 Like

Depends on the service but if you use net/http each handler will be executed in a goroutine. gunicorn takes care of handling requests in different process/thread.

In Go you don’t need it

1 Like

Just run the executable. That’s it!

You don’t need gunicorn, workers, uwsgi or nginx.

The Go standard library contains a production grade http server, and does everything needed.
If you want to serve https, then check out GitHub - caddyserver/certmagic: Automatic HTTPS for any Go program: fully-managed TLS certificate issuance and renewal

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.