- Newest
- Most votes
- Most comments
Based on your symptoms, this is very likely related to EC2 security group connection tracking limits rather than application or kernel configuration issues.
The Core Issue: Connection Tracking Allowance
EC2 instances have a maximum connection tracking allowance that varies by instance type. When your instance exceeds this allowance, you'll experience exactly what you're describing: packet drops and inability to establish new connections around a specific threshold. The ~8,300 connection limit you're hitting strongly suggests you've reached your instance's connection tracking capacity.
Security groups are stateful and automatically track connections to manage traffic flow. Each tracked connection consumes memory and compute resources on the instance. For c7a.2xlarge instances, you're likely hitting the connection tracking limit for that instance size.
How to Diagnose This
Monitor these Amazon Elastic Network Adapter (ENA) metrics:
- conntrack_allowance_available: Shows how many tracked connections you can establish before exceeding your allowance
- conntrack_allowance_exceeded: Indicates if your instance is exceeding its connection tracking capacity
If you see conntrack_allowance_exceeded incrementing or conntrack_allowance_available approaching zero around 8,300 connections, this confirms the issue.
Solutions to Consider
-
Scale to a larger instance type: Larger instances have higher connection tracking allowances and can support more concurrent connections.
-
Configure security group rules to avoid tracking: You can create security group rules that allow all traffic (0.0.0.0/0) in both directions for specific ports. These become "untracked connections" and don't consume connection tracking resources. However, this reduces security granularity.
-
Adjust TCP established timeout values: If you have stale connections, reducing the TCP established idle timeout on your Elastic Network Interface can help free up tracking resources faster. You can configure this when creating/modifying network interfaces or in launch templates.
-
Use Network ACLs instead of security groups where possible, as they don't perform connection tracking.
The fact that this works fine on your local machine but fails consistently at the same threshold on EC2 strongly points to an AWS infrastructure limit rather than an application issue. Your kernel tuning and file descriptor limits appear properly configured, but those don't override the EC2 connection tracking limits imposed at the hypervisor level on Nitro instances.
Sources
Amazon EC2 security group connection tracking - Amazon Elastic Compute Cloud
Troubleshoot security group connection tracking | AWS re:Post
Relevant content
- AWS OFFICIALUpdated 2 years ago

I'm create wide rule in security group in and out any ports from 0.0.0.0/0 and check ENI (see below), but problem not solved.