Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pefromance issue with AWS fargate

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"
}
like image 303
Bini Avatar asked Jan 25 '23 08:01

Bini


1 Answers

The answer I get from AWS support is as follows.

"ECS Fargate tasks may be placed on any underlying host that is available, and meets the CPU and Memory specified in the task definition and as such may have varying performance. EC2 instances are better suited in situations where control of the application performance is required."

My recommendation for developers, if network throughput and IO performance are important for your application better to use EC2.

like image 179
Bini Avatar answered Feb 05 '23 01:02

Bini