Skip to main content

Version: 3.10.x

Shared Memory Sizing

API7 Gateway data plane nodes keep several kinds of cross-worker state in NGINX shared memory zones (lua_shared_dict). Most of these behave like caches: when they fill up, the least recently used entries are evicted and the node keeps working. A few, however, hold data that grows with the size of your deployment and is not evicted — when they fill up, new writes are silently dropped. This page explains which zones to size, how much they hold, and how to change them for your scenario.

Zones That Need Sizing

The API7 Dashboard monitors the following zones because their contents are not self-healing: an overflow causes a persistent, hard-to-diagnose loss rather than a transient cache miss.

ZoneDefaultHoldsSymptom when full
prometheus-metrics-advanced256 MBone entry per Prometheus time seriesmetrics stop updating; gaps in dashboards and alerts
kubernetes / nacos / consul64 MB eachone entry per discovered service (its node list)new or changed upstream nodes do not resolve
api-calls-for-portal64 MBone counter per Developer Portal API-call dimensionportal analytics under-count
tracing_buffer32 MBSkyWalking trace segments awaiting reporttrace spans are dropped

All other shared memory zones (rate-limiting counters, EWMA balancer state, caches, and so on) evict or reset on their own and do not need tuning.

note

The defaults above are chosen to cover the majority of deployments. Change them only if your scale exceeds the capacity described below, or if you want to reclaim memory on a small deployment. An explicit value always overrides the default.

Capacity Reference

The figures below come from measuring how many entries fit per megabyte on the API7 Gateway runtime. Shared memory is allocated in fixed slab classes, so the cost per entry rounds up to the next power-of-two boundary. Crossing a boundary — a longer key or a larger value — roughly doubles the per-entry cost, which is why the numbers below step in halves.

Prometheus Metrics

Each unique metric-and-label combination (a time series) is one entry of about 256 bytes.

Zone sizeApproximate time series
64 MB260,000
256 MB (default)1,000,000
512 MB2,000,000

The series count grows with the number of routes and services that have the prometheus plugin enabled, multiplied by label cardinality and histogram buckets. Histogram metrics dominate: the request-latency histogram alone adds about 15 buckets per label combination, whereas counters such as bandwidth add only a couple of series each. High-cardinality labels, such as a per-upstream-node label, multiply the count quickly; use the prometheus plugin's disabled_labels metadata to drop specific labels if you need to cap it.

Service Discovery

Each discovered service is one entry whose value is the JSON list of its backend nodes, so the per-entry cost grows with the number of nodes per service.

Nodes per serviceServices per 64 MB (default)
1260,000
5130,000
2032,000
1008,000

Size the kubernetes, nacos, or consul zone to the number of services in your registry, leaving headroom for the services with the largest node lists.

Developer Portal API Calls

Each entry is a counter keyed by a combination of subscription, developer, application, credential, API product, and response status — about 512 bytes.

Zone sizeApproximate counter combinations
64 MB (default)130,000
128 MB260,000

The number of live combinations grows with portal consumers × applications × products × distinct response codes. Counters are flushed periodically, so size for peak concurrent cardinality rather than cumulative traffic.

Tracing Buffer

The buffer holds SkyWalking trace segments queued for reporting. It absorbs spikes when the collector is slow or briefly unreachable; segments drain as they are reported.

Segment sizeSegments per 32 MB (default)
~1 KB16,000
~2 KB8,000
~4 KB4,000

Size this for how long you need to keep buffering during a collector slowdown, not for steady-state throughput. If you see dropped segments while the collector is healthy, raise it.

Change the Defaults

Override any of these zones on the data plane. The value is a size string such as 128m or 1g. For Helm deployments, apply the change with helm upgrade; for a directly managed data plane, edit config.yaml and restart the node. Shared memory zones are sized once at startup, so the new size takes effect only after a full restart — a reload does not resize them.

Set the zone under nginx_config in the data plane config.yaml, which overrides config-default.yaml:

nginx_config:
meta:
lua_shared_dict:
prometheus-metrics: 512m # backs the prometheus-metrics-advanced zone
http:
lua_shared_dict:
tracing_buffer: 64m
api-calls-for-portal: 128m
custom_lua_shared_dict:
kubernetes: 128m
nacos: 128m
consul: 128m

The Prometheus zone is configured under the meta context with the key prometheus-metrics, which sizes the prometheus-metrics-advanced zone shown on the Dashboard.

Monitor Usage

The API7 Dashboard reports the used and total capacity of each monitored zone per data plane node and raises an alert as a zone approaches its limit. Use it to confirm your sizing under real traffic and to catch a zone trending toward full before it starts dropping data.

API7.ai Logo

The digital world is connected by APIs,
API7.ai exists to make APIs more efficient, reliable, and secure.

Sign up for API7 newsletter

Product

API7 Gateway

SOC2 Type IIISO 27001HIPAAGDPRRed Herring

Copyright © APISEVEN PTE. LTD 2019 – 2026. Apache, Apache APISIX, APISIX, and associated open source project names are trademarks of the Apache Software Foundation