The deployment of go program asks whether it is necessary to add nginx as a reverse proxy.

problem description

recently developed an API micro-service interface with go gin, and now want to deploy it online to provide services to app

the original plan was to let app visit http://ip:9000

directly.

but colleagues say that nginx should be used as a reverse proxy, so that the performance will be higher.

in this case, the deployment mode becomes app to access http://a.com/api. After receiving this request, nginx reverse proxies to the local
http://127.0.0.1:9000

.

questions

1. If the number of visits is very high, will the performance of directly accessing the go service port be high, or will it be high after being proxied by nginx?
2. If nginx proxies go services with higher performance, why is it better with one more layer? is it similar to the relationship between nginx and php-fpm?

finally, thank you for your answer!

Jul.15,2022

is wrong. The reason why we add nginx reverse proxy
1: it is very convenient to achieve load balancing
2: it is convenient to restrict requests, and there is request control
3: although adding nginx has lost a little bit of performance, it is negligible!


there is another reason:

in general, only a few common ports (80,443, 22 and 23, etc.) are available on CVM, so if you want to access ip:port directly from the public network, you have to manually configure the rules for entering and exiting the network. If more services are deployed, open port management and security are both a problem ~

Menu