Skip to content

fix close_wait and tomcat connection keeps growing - #726

Open
taobaorun wants to merge 8 commits into
modelcontextprotocol:mainfrom
taobaorun:fix/fix_close_wait
Open

fix close_wait and tomcat connection keeps growing#726
taobaorun wants to merge 8 commits into
modelcontextprotocol:mainfrom
taobaorun:fix/fix_close_wait

Conversation

@taobaorun

Copy link
Copy Markdown

Motivation and Context

Reproduction Scenario:

Perform stress testing at 120 TPS.
MCP client/server environment: 4 cores, 8 GB memory.
Create an MCP client, invoke methods, then close the client.
Issue:

A large number of CLOSE_WAIT connections appear on the Tomcat side. Meanwhile, the number of Tomcat connections keeps increasing. After observation, neither the CLOSE_WAIT states nor the connections are being released.

CLOSE_WAIT
tcp 1 0 127.0.0.1:8080 127.0.0.1:41480 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:37302 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:38498 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:56912 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:43558 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:59106 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:56932 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:51550 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:51164 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:43560 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:34260 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:41716 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:35992 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:44786 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:55236 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:59386 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:53424 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:56114 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:58248 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:52838 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:48726 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:36736 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:45538 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:59914 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:40062 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:52192 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:33146 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:47786 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:58276 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:49948 CLOSE_WAIT - tcp 1 0 127.0.0.1:8080 127.0.0.1:49464 CLOSE_WAIT - 
Tomcat Connection
lrwx------ 1 admin admin 64 12月 14 13:53 960 -> socket:[23255743]
lrwx------ 1 admin admin 64 12月 14 13:53 961 -> socket:[23420857]
lrwx------ 1 admin admin 64 12月 14 13:53 962 -> socket:[23662408]
lrwx------ 1 admin admin 64 12月 14 13:53 963 -> socket:[23520462]
lrwx------ 1 admin admin 64 12月 14 13:53 964 -> socket:[23220526]
lrwx------ 1 admin admin 64 12月 14 13:53 965 -> socket:[23403999]
lrwx------ 1 admin admin 64 12月 14 13:53 966 -> socket:[23260212]
lrwx------ 1 admin admin 64 12月 14 13:53 967 -> socket:[23793138]
lrwx------ 1 admin admin 64 12月 14 13:53 968 -> socket:[23713542]
lrwx------ 1 admin admin 64 12月 14 13:53 969 -> socket:[23426193]
lrwx------ 1 admin admin 64 12月 14 13:53 970 -> socket:[23570999]
lrwx------ 1 admin admin 64 12月 14 13:53 971 -> socket:[23222233]
lrwx------ 1 admin admin 64 12月 14 13:53 972 -> socket:[23387440]
lrwx------ 1 admin admin 64 12月 14 13:53 973 -> socket:[23288628]
lrwx------ 1 admin admin 64 12月 14 13:53 974 -> socket:[23293539]
lrwx------ 1 admin admin 64 12月 14 13:53 975 -> socket:[23404582]
lrwx------ 1 admin admin 64 12月 14 13:53 976 -> socket:[23366146]
lrwx------ 1 admin admin 64 12月 14 13:53 977 -> socket:[23741741]
lrwx------ 1 admin admin 64 12月 14 13:53 978 -> socket:[23598858]
lrwx------ 1 admin admin 64 12月 14 13:53 979 -> socket:[23232809]
lrwx------ 1 admin admin 64 12月 14 13:53 980 -> socket:[23401313]
lrwx------ 1 admin admin 64 12月 14 13:53 981 -> socket:[23232813]
lrwx------ 1 admin admin 64 12月 14 13:53 982 -> socket:[24086253]
lrwx------ 1 admin admin 64 12月 14 13:53 983 -> socket:[23409146]
lrwx------ 1 admin admin 64 12月 14 13:53 984 -> socket:[23426197]
lrwx------ 1 admin admin 64 12月 14 13:53 985 -> socket:[23858842]
lrwx------ 1 admin admin 64 12月 14 13:53 986 -> socket:[23385364]
lrwx------ 1 admin admin 64 12月 14 13:53 987 -> socket:[23694127]
lrwx------ 1 admin admin 64 12月 14 13:53 988 -> socket:[23692908]
lrwx------ 1 admin admin 64 12月 14 13:53 989 -> socket:[23628026]
lrwx------ 1 admin admin 64 12月 14 13:53 990 -> socket:[23313794]
lrwx------ 1 admin admin 64 12月 14 13:53 991 -> socket:[23236207]
lrwx------ 1 admin admin 64 12月 14 13:53 992 -> socket:[23790058]
lrwx------ 1 admin admin 64 12月 14 13:53 993 -> socket:[23426205]
lrwx------ 1 admin admin 64 12月 14 13:53 994 -> socket:[23700721]
lrwx------ 1 admin admin 64 12月 14 13:53 995 -> socket:[23617975]

How Has This Been Tested?

Breaking Changes

benchmark test

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@taobaorun

Copy link
Copy Markdown
Author

Hey @Kehrlann , mind taking a look at this PR when you get a sec? We ran into a potential stability issue during stress testing, and I’d feel way better if you could give it a quick review. Thanks!

@He-Pin

Copy link
Copy Markdown
Contributor

你在哪个公司呀?

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@taobaorun@He-Pin