apache / apisix

The Cloud-Native API Gateway
https://apisix.apache.org/blog/
Apache License 2.0
14.54k stars 2.52k forks source link

help request: memory leakage problem in Apisix GW #11680

Open sdd-el opened 1 month ago

sdd-el commented 1 month ago

Description

Current behavior: After running stress tests, memory usage increases and doesn’t decrease after the tests are finished (unlike CPU usage, which decreases as expected). The configured resources are: resources: limits: cpu: 2000m memory: 5Gi requests: cpu: 1500m memory: 4Gi The minimum replicas are set to 1, and the maximum replicas are set to 3. The plugins in use are proxy-rewrite, serverless-pre-function, loki-logger, and prometheus. Any idea what could be causing this? Why isn’t memory being “cleaned” after the traffic load is gone?

image

Expected behavior: Memory usage should decrease after the traffic load is gone, similar to how CPU usage decreases.

Environment

wklken commented 1 month ago

did you set the prometheus.expire in config.yaml? https://github.com/apache/apisix/blob/release/3.9/conf/config-default.yaml#L605

and also you can change the default_buckets

try and do the test again.

sdd-el commented 1 week ago

@wklken thx for your comment. I tried what you have proposed, i.e.,
prometheus:

export_addr:

  ip: 0.0.0.0

  port: 9091

export_uri: /apisix/prometheus/metrics

metric_prefix: apisix_

expire: 600

default_buckets:

  - 10

  - 50

but I still get memory increase which is constant, i.e., memory is not released after running load test(s). Do you have any other possible solution in mind?

wklken commented 1 week ago
curl http://0.0.0.0:9091/apisix/prometheus/metrics > a

get the metrics


you can see some more tips here: https://github.com/apache/apisix/issues/10618

and https://github.com/apache/apisix/issues/10618#issuecomment-1870936375

sdd-el commented 1 week ago

@wklken thanks for your feedback.

Here are my findings:

image