We have an old Java application running in Jboss As 7.1.1. Currently, this application is running on AWS EC2 instance type t3.medium, which is 2 CPU cores and 4GB memory.
We are trying to modernize our applications with CI/CD and AWS Fargate. We succeed to achieve modernization but not with performance.
The task definition of the Fargate has the same CPU and memory as the EC2 instance(2048 CPU and 4096 Memory). The Fargate is in the same subnet and linked to the same security group as the EC2 instance. We couldn't understand the reason for the slow performance.
The application normally searches for music works detail (creators, publishers, artists, and so on). If we take a music work with a large list of interested parties, in the EC2 instance it takes less than 20 seconds but in the Fargate it takes around 30 minutes.
I created the docker image from the same Jboss running on the EC2 instance and the same Java version.
One more piece of information, the database is in a different(non-AWS) data center.
Could you please guide me on how to achieve the same performance as the older setup by using AWS Fargate? What Am I missing in the Fargate?
Task definition
{
"containerDefinitions": [
{
"name": "CONTAINER_NAME",
"image": "<IMAGE1_NAME>",
"memory": 4096,
"essential": true,
"logConfiguration": {
"logDriver": "awslogs",
"secretOptions": null,
"options": {
"awslogs-group": "/ecs/TaskDefinitionName",
"awslogs-region": "eu-central-1",
"awslogs-stream-prefix": "ecs"
}
},
"portMappings": [
{
"hostPort": 8080,
"containerPort": 8080,
"protocol": "tcp"
}
]
}
],
"compatibilities": [
"EC2",
"FARGATE"
],
"requiresCompatibilities": [
"FARGATE"
],
"networkMode": "awsvpc",
"cpu": "2048",
"memory": "4096",
"family": "TaskDefinitionName",
"taskRoleArn": "arn:aws:iam::accountId:role/ecsTaskExecutionRole",
"executionRoleArn": "arn:aws:iam::accountId:role/ecsTaskExecutionRole"
}