Welcome to the Linux Foundation Forum!

Lowering memory consumption for lab 15.1 on anynines a9s 1G free tier

If you are on the free tier of anynines, you'll find that by using the java_buildpack, you will be unable to run all three roster , web-ui , and rate-limit apps on the 1GB memory limit.

Instead, you can combine custom parameters to the java buildpack along with cf scale, to decrease the memory footprint and therefore stay within quota.

If you don't do this, when you cf push the app, it will complain about memory quota.

  1. memory quota_exceeded
  2. FAILED

If you simply scale down the memory limit, it will crash on launching the instance

  1. name: rate-limit
  2. requested state: started
  3. routes:
  4. last uploaded: Thu 04 Feb 11:26:16 AEDT 2021
  5. stack: cflinuxfs3
  6. buildpacks:
  7. name version detect output buildpack name
  8. java_buildpack v4.35-https://github.com/cloudfoundry/java-buildpack.git#895590c java java
  9.  
  10. type: web
  11. sidecars:
  12. instances: 0/1
  13. memory usage: 128M
  14. state since cpu memory disk details
  15. #0 crashed 2021-02-04T01:53:10Z 0.0% 0 of 128M 0 of 512M
  16.  
  17. type: task
  18. sidecars:
  19. instances: 0/0
  20. memory usage: 256M
  21. There are no running instances of this process.

In the logs will be this similar message

  1. 2021-02-04T13:08:32.79+1100 [APP/PROC/WEB/0] ERR Cannot calculate JVM memory configuration: There is insufficient memory remaining for heap. Memory available for allocation 128M is less than allocated memory 633090K (-XX:ReservedCodeCacheSize=240M, -XX:MaxDirectMemorySize=10M, -XX:MaxMetaspaceSize=121090K, -Xss1M * 250 threads)

Take this corrective action, by lowering the threads used in the memory calculator.
cf set-env roster JBP_CONFIG_OPEN_JDK_JRE '{ memory_calculator: { stack_threads: 10 } }'

Restage and scale the app

  1. cf restage roster
  2. cf scale roster -m 512M

Repeat for rate-limit
cf set-env rate-limit JBP_CONFIG_OPEN_JDK_JRE '{ memory_calculator: { stack_threads: 5 } }'

Restage and scale the app

  1. cf restage rate-limit
  2. cf scale rate-limit -m 425M

If you need to scale down any task memory limits, use the --process task argument, like so:
cf scale rate-limit -m 32M --process task

Source: https://github.com/cloudfoundry/java-buildpack#configuration-and-extension

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training