79253211

Date: 2024-12-05 02:11:31
Score: 1
Natty:
Report link

I ran into a memory leak and tcp port number occupancy caused by not reusing the client, which bothered me for a week. The official recommendation is to reuse clients, and it is said that Transport is in the keep-alives state by default(you can set Transport, DisableKeepAlives = True to solve, but this will cause a lot of time - wait state socket), which causes goroutine to block if http requests are sent in goroutine.

pprof of my http server

socket status

This is the data that my server exported with pprof, and you can see that there were 9101 Goroutines at the time, and then I did a special test and found that it was indeed the result of not reusing the client.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: SkyHyko