Symptom
A busy instance, such as a reverse proxy, NAT instance, DNS server, Network Load Balancer backend or API front end, starts failing new connections at peak:
- Clients see SYN timeouts or
connect()timeouts. Connections that already exist keep working. - CPU, memory and NIC throughput on the instance are well under their limits.
ss -son the host shows nothing unusual, and the Linuxnf_conntracktable is not full.- The failures stop when traffic drops, and resizing the shape seems to help for a while.
This is often the VCN's own connection tracking, not the guest OS. Every stateful security rule (security list or NSG) makes the virtual network track each flow per VNIC. That table has a fixed size per shape. When it is full, new flows are dropped before they reach the guest.
How OCI connection tracking works
- Stateful is the default for new rules. A tracked flow is keyed on protocol, source and destination IPs, and (for TCP/UDP) ports.
- Tracked entries live until they go idle. Oracle's documented defaults are below. Check the current security rules page, because these can change.
| Protocol / state | Idle timeout |
|---|---|
| TCP established | 1 day |
| TCP setup | 1 minute |
| TCP closure | 2 minutes |
| UDP, traffic seen in both directions | 3 minutes |
| UDP, one direction only | 30 seconds |
| ICMP | 15 seconds |
| Other protocols | 5 minutes |
- The table size depends on the shape. Flex shapes scale it per OCPU, and bare metal shapes are sized per physical VNIC. The numbers are listed in the "Connection Tracking" section of the OCI service limits page. Look up your shape there and don't assume a figure.
- If traffic matches both a stateful and a stateless rule in the same direction, the stateless rule wins and the flow isn't tracked. The fix below depends on this.
The 1-day timeout for established TCP is the trap. Clients that open connections and leave without a clean FIN/RST (mobile clients, crashed load generators, aggressive scanners) leave entries behind for hours. UDP-heavy services such as DNS and syslog churn through entries quickly, and that can fill the table too.
Checks
1. Read the VNIC conntrack metrics
The oci_vcn namespace publishes these per VNIC (dimension resourceId = VNIC OCID). They are emitted automatically and you don't need to install an agent. They live in the subnet's compartment, not the instance's.
| Metric | Meaning |
|---|---|
VnicConntrackUtilPercent | Table utilisation 0–100% |
VnicConntrackIsFull | 1 when the table is full |
VnicIngressDropsConntrackFull | Inbound packets dropped because the table is full |
VnicEgressDropsConntrackFull | Outbound packets dropped because the table is full |
VnicIngressDropsSecurityList | Inbound drops from rule mismatch (a different problem) |
Find the VNIC and query the last six hours:
INSTANCE=ocid1.instance.oc1..xxxx
COMP=ocid1.compartment.oc1..subnetcompartment # subnet's compartment
VNIC=$(oci compute vnic-attachment list -c "$COMP" --instance-id "$INSTANCE" \
--query 'data[0]."vnic-id"' --raw-output)
oci monitoring metric-data summarize-metrics-data -c "$COMP" \
--namespace oci_vcn \
--query-text "VnicConntrackUtilPercent[1m]{resourceId = \"$VNIC\"}.max()" \
--start-time "$(date -u -d '-6 hours' +%Y-%m-%dT%H:%M:%SZ)" \
--end-time "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--query 'data[0]."aggregated-datapoints"[-10:]'
Run the same query with VnicIngressDropsConntrackFull[1m]{...}.sum(). Any value above zero confirms the diagnosis.
2. Rule out the other drop counters
| Metric high | Cause | Fix |
|---|---|---|
Vnic*DropsConntrackFull | Tracking table full | Stateless rules or bigger shape (below) |
Vnic*DropsSecurityList | No rule allows the flow | Fix rules, see VCN flow logs |
Vnic*DropsThrottle | Shape bandwidth/PPS limit | Larger shape, more VNICs, spread load |
None, but Linux shows nf_conntrack: table full | Guest conntrack | Tune nf_conntrack_max or bypass with NOTRACK |
3. Check the guest table too
On a Linux proxy you can hit both tables. Check the guest one so you don't fix the wrong layer:
sudo sysctl net.netfilter.nf_conntrack_count net.netfilter.nf_conntrack_max
sudo dmesg -T | grep -i 'nf_conntrack: table full'
ss -tan state time-wait | wc -l
4. Identify which rules are stateful for the hot port
oci network nsg rules list --nsg-id "$NSG" --all \
--query 'data[?direction==`INGRESS`].{port:"tcp-options"."destination-port-range".min, src:source, stateless:"is-stateless"}' \
--output table
oci network security-list get --security-list-id "$SL" \
--query 'data."ingress-security-rules"[].{src:source, proto:protocol, stateless:"is-stateless", port:"tcp-options"."destination-port-range".min}' \
--output table
Fix
Option A: make the high-volume flows stateless (preferred)
Stateless rules aren't tracked, so they don't use the table. You have to allow both directions yourself.
For an HTTPS front end on 443 behind 0.0.0.0/0, the NSG needs a stateless ingress rule for the service port and a stateless egress rule for the replies:
cat > rules.json <<'EOF'
[
{"direction":"INGRESS","protocol":"6","source":"0.0.0.0/0","sourceType":"CIDR_BLOCK",
"isStateless":true,"description":"HTTPS in, untracked",
"tcpOptions":{"destinationPortRange":{"min":443,"max":443}}},
{"direction":"EGRESS","protocol":"6","destination":"0.0.0.0/0","destinationType":"CIDR_BLOCK",
"isStateless":true,"description":"HTTPS replies, untracked",
"tcpOptions":{"sourcePortRange":{"min":443,"max":443}}},
{"direction":"INGRESS","protocol":"1","source":"0.0.0.0/0","sourceType":"CIDR_BLOCK",
"isStateless":true,"description":"PMTUD",
"icmpOptions":{"type":3,"code":4}}
]
EOF
oci network nsg rules add --nsg-id "$NSG" --security-rules file://rules.json
Warning
Add the stateless egress rule at the same time as the ingress rule. A stateless ingress rule takes precedence over your existing stateful one, so the reply traffic is no longer allowed automatically. If the egress rule is missing, every connection on that port fails immediately.
Tip
Oracle documents the ICMP type 3 code 4 ingress rule as critical whenever stateless rules allow traffic to or from outside the VCN. Without it, Path MTU Discovery breaks and large responses hang. That looks like a new problem, but you caused it with this change.
Keep the stateful rules for admin ports (SSH, monitoring) and for outbound calls the instance starts itself. Only the high-churn service port needs to be untracked.
Option B: a larger shape or more OCPUs
On Flex shapes, more OCPUs give a bigger table. This buys headroom fast, using an in-place resize with a reboot, but it doesn't remove the ceiling. Oracle says a larger shape may not be enough when the stateful rules stay in place.
Option C: reduce how many entries each client leaves behind
- Enable HTTP keep-alive and connection reuse on clients and the proxy, so you get fewer flows per request.
- Close idle client connections at the application with an explicit FIN rather than abandoning them.
- Put a load balancer in front. The OCI Load Balancer terminates client TCP, so the backends see a small, reused set of flows.
Verify
After the change, VnicConntrackUtilPercent should fall as old tracked entries age out. Established TCP entries only expire after their idle timeout, so this is gradual. VnicIngressDropsConntrackFull should stay at zero at the next peak. Test with a burst of new connections:
# From a client: 2000 new TLS connections, 100 in parallel
seq 2000 | xargs -P100 -I{} curl -s -o /dev/null -w '%{http_code} %{time_connect}\n' https://app.example.com/health \
| awk '{c[$1]++; if ($2>1) slow++} END {for (k in c) print k, c[k]; print "connect>1s:", slow+0}'
Prevent it next time
- Alarm on the table before it is full:
VnicConntrackUtilPercent[5m]{resourceId = "<vnic-ocid>"}.max() > 80
Add a second alarm on VnicIngressDropsConntrackFull[1m].sum() > 0 at critical severity.
- Treat stateless rules as the default for internet-facing high-rate ports in your NSG modules, and review them in code. Don't hand-edit them in the console.
- Include conntrack capacity when you size shapes for proxies, NAT instances, DNS and NLB backends with client IP preservation. Size from concurrent flows as well as CPU.
- Load test with realistic client behaviour, including abandoned connections. Synthetic tests with clean closes hide this problem.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get