Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monitor JVM in AWS Fargate

I have been currently trying to connect VisualVM (A program which monitors the JVM, heap and memory usage etc) to a Spring Boot Application (Java App) running on AWS Fargate in Docker containers.

I have been exposing the JMX ports accordingly and I am able to connect through the JMX ports when running the Docker container locally. However, when running the Java App on Fargate, I have not found a way to connect to the Container through JMX. I have tried setting the VM argument -Djava.rmi.server.hostname to the IP Address of the container, but when I try to connect through JMX it still fails to do so. Has anyone had any experience with this?

JMX commands for reference:

-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.local.only=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-Djava.rmi.server.hostname=172.17.0.2 \
-Dcom.sun.management.jmxremote.port=9090\
-Dcom.sun.management.jmxremote.rmi.port=9090\
-jar java-api.jar server```

like image 837
John Avatar asked Feb 19 '20 11:02

John


People also ask

What is vCPU in AWS fargate?

This means that a vCPU is essentially the same as an EC2 instance vCPU. From the docs: Amazon EC2 instances support Intel Hyper-Threading Technology, which enables multiple threads to run concurrently on a single Intel Xeon CPU core. Each vCPU is a hyperthread of an Intel Xeon CPU core, except for T2 instances.

Which is better EC2 or fargate?

Fargate is the better option for ease of use as it takes infrastructure management out of the equation allowing you to focus on just the tasks to be run. It works great for most workloads and enables a faster pace of operations.

What is the difference between fargate and ECS?

Fargate removes the need to provision and manage servers. Instead, you simply specify the resources per task, which also improves security through application isolation by design. ECS then communicates with Fargate to launch, run, and manage the containers on your behalf.

How can I monitor my AWS Fargate usage?

In the Service Quotas console, you can visualize your usage on a graph and configure alarms that alert you when your usage approaches a service quota. For more information, see AWS Fargate usage metrics .

What is the difference between Amazon ECS and AWS Fargate?

Amazon ECS is a highly scalable, high-performance container orchestration service that supports Docker containers and allows you to easily run and scale containerized applications on AWS. AWS Fargate is a compute engine for Amazon ECS that allows you to run containers without having to manage servers or clusters.

What is the on-demand usage for AWS Fargate?

Fargate On-Demand usage combines Amazon EKS pods using Fargate, Amazon ECS tasks using the Fargate launch type and Amazon ECS tasks using the FARGATE capacity provider. The class of resource being tracked. Currently, AWS Fargate does not use the class dimension.

How does the applications manager monitor JVM?

The Applications Manager briefing documents stress that the JVM monitoring tool focuses on how JVM manages the memory allocation and release processes. There is a lot more to JVM memory usage and the Applications Manager covers all of those issues. The Applications Manager isn’t just a JVM monitoring tool.


1 Answers

Following changes worked for me in connecting Visual VM to Spring Boot Application deployed in AWS Fargate (private VPC)

  • jvm parameters
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=1099 \
-Dcom.sun.management.jmxremote.rmi.port=1099 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.local.only=false \
-Djava.rmi.server.hostname=127.0.0.1
  • export port 1099 (both in dockerfile and cloudformation template - PortMappings->ContainerPort)

  • Container security group to accept incoming traffic on 1099 (tcp and udp) from one of the existing EC2 in vpc (jump server)

  • ssh port forwarding by using EC2 (jump server) to task running in fargate (use private ip of task running in fargate)

run following command on local

ssh -l <user> -L 127.0.0.1:1099:<task-private-ip-in-fargate>:1099 <ec2-ip(jump server)>
  • Connect VisualVM using JMX Connection on 127.0.0.1:1099
like image 168
Snehal Patel Avatar answered Sep 29 '22 13:09

Snehal Patel