Article From:https://segmentfault.com/q/1010000010763840
Question:

scene
Comparison of pressure data: tomcat/beego, in the case of 1000 concurrent, data comparison.

beegoThe consumption of CPU has been 93.3% (the server is a CPU, 2 core), consuming much more than Tomcat.

problem
Excuse me, why does golang consume CPU so much? Is it appropriate to do API interface service?

Answer 0:

If you want better performance, recommend a web framework gin https://github.com/gin-gonic/gin

Answer 1:

beegoIt’s a development framework that encapsulates too much. You also compare the HTTP services developed by this framework with Tomcat. Beego is really CPU.

But the problem: golang is so CPU? Is it suitable for writing the API interface?

I suggest not to confuse beego with golang. Beego is a framework that is built on the basis of various packages that are suitable for new and fast development libraries, and golang is a language. Golang has a native HTTP library, if you think the HTTP native library is written.If you can’t get it right, you can rewrite it yourself, which is in line with the HTTP agreement.

golangIt’s a static language, at least because it handles high concurrency speed and is used in cloud computing.

It’s all right to write API. Docker/k8s/etcd is all written by go, not suitable for writing, ALI / Tencent / Baidu / / Green / HUAWEI / Google / Amazon cloud services.

Answer 2:

There are no problems at all. There are too many beego packages for easy use.

Answer 3:

beego The performance is never the best

Answer 4:

I recommend not using frameworks for writing only apis, because go’s http. handleFunc (pattern, func (writer Response Writer, req * Request) {}) is already comprehensive!
If you want to write some pages and systems, the gin framework is almost the same as Nodejs’s express.

Leave a Reply

Your email address will not be published. Required fields are marked *