title: Making the JVM lightweight using Docker and Azure Kubernetes Service
body: <p>I'm having a bit of an issue.  I'm building a Java Spring application, but when I try to run it on Azure Kubernetes Service (AKS) using Docker, it appears to be using a lot of system resources (RAM, CPU are the main considerations).  Aside from Spring itself, the code is fairly lightweight, so I don't understand why it is using so much system resources.  Is there any best practices I should be aware of to reduce the system resource footprint of my Java Spring application?</p>
  
  <p>The purpose of the application is as a lightweight CRUD service on top of a MongoDB database.  The DB interaction layer uses Spring Data or Morphia for direct DB operations (older applications are using Morphia, newer development uses Spring Data, with QueryDSL in some places as appropriate).</p>
  
  <p>In particular, the metric I am comparing to is NodeJS, so I would like to make my Java application run at a level comparable to a Node application of similar size/scope.</p>
  
  <p>Thanks!</p>
  
  <p>Dockerfile (some params redacted):</p>
  
  <pre><code>FROM openjdk:8-jre-alpine
  
  RUN mkdir /[redacted]
  ADD *.jar /[redacted]
  
  ENV JVM_OPTS="-Xmx256M"
  ENV JVM_ARGS="-Dspring.profiles.active=[redacted]"
  
  EXPOSE 8080
  
  ENTRYPOINT [ "sh", "-c", "java $JVM_ARGS $JVM_OPTS -jar /[redacted]" ]
  </code></pre>
  
  <p>The only thing the Spring profile parameter does is set a bunch of configuration which is needed for the business logic of the application.  It doesn't set anything JVM-wise.</p>