英文:
Golang HTTP server requests async or sync?
问题
我有一个使用Golang编写的RESTful API,我的Angular网站调用它。
Go的http模块默认是按顺序处理请求还是并发处理请求?
另外,如果我的Go中的HandlerFunc调用一个Python脚本,对该HandlerFunc的并发调用会生成多个Python进程,还是会被阻塞直到一个进程完成?
英文:
I have a RESTful API in Golang that my Angular website calls.
Does the Go http module by default handle requests in sequence or concurrently?
Also, if my HandlerFunc in Go calls a python script, would concurrent calls to this HandlerFunc spawn multiple python processes, or would they be blocked till one is complete?
答案1
得分: 4
是的,默认情况下,所有的HTTP请求都可以并发执行。
如果你正在执行一个Python脚本,那么确实会生成一个单独的进程,并且它们会并发执行。
请注意,这可能会带来生成过多进程并耗尽资源的潜在风险。
英文:
Yes, by default all http requests can be executed concurrently.
If you are executing a python script, then indeed a separate process will be spawned and they will execute concurrently.
Please note that this carries the potential risk of spawning too many processes and running out of resources.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论