Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

http - Process Management for the Go Webserver

I'm a new Go programmer, coming from the world of web application and service development. Apologies is this is a herp de-derp question, but my googling around for an answer hasn't found anything. Also, this is borderline Server Fault territory, but since I'm more interested in the APIs/programmatic interfaces I'm asking here.

I've written a small go program using the net/http package's built-in web server. I'm getting ready to deploy to production, but I'm a little unclear on the process of model go Go's web-server and how I should deploy.

Specifically -- in the environments I'm used to (PHP, Ruby, Python) we have a web server (Apache, Nginx, etc.) sitting in front of our application, and we configure these web servers to use a certain number of worker processes/threads, and configure how many individual HTTP(S) connections each thread should process.

I haven't been able to find information on how Go's web-server handles this, or practical information on how to scale/plan-for-scale for a Go web server.

i.e. -- if I have a simple program running, ready to handle an HTTP request

func main() {
   http.HandleFunc("/", processRequest)
   http.ListenAndServe(":8000", nil)    
}

how many connections will HandleFunc try to handle at once? Or will it start blocking when a connection opens, and only serve the next connection once the connection closes?

Or should I just not worry about this and jam everything into a go routine? But if I do that how do I prevent the system from becoming bogged down by too many threads of execution?

I'm basically trying to

  1. Understand the process mode of the go web server
  2. Find the built-in features of go for tweaking this, and/or whatever standard package folks are using

Like I said, I'm very new to go, so if I'm completely missing the plot on this please let me know!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...