0

I'm trying to deploy a sample application to AWS ECS and I'm experimenting something weird.

I have created a task definition with a container definition using the sample image amazon/amazon-ecs-sample. This is just a simple PHP welcome page.

When I start a task in my ECS service, I navigate to the task public IP and it works fine: I can see PHP website. But, eventually, after 2 minutes or so, it stops working and when I reaload I get timeout.

Task is still running and there are no logs. After watching metrics with container insights and CloudWatch metrics, there are no problems with memory or CPU, either.

I'm running my task in Fargate mode and I'm not using load balancer.

This is the task definition:

{
  "ipcMode": null,
  "executionRoleArn": "arn:aws:iam::xxxxxxxxxxxx:role/myEcsExecutionRole",
  "containerDefinitions": [
    {
      "dnsSearchDomains": [],
      "environmentFiles": [],
      "logConfiguration": {
        "logDriver": "awslogs",
        "secretOptions": [],
        "options": {
          "awslogs-group": "myapp",
          "awslogs-region": "eu-central-1",
          "awslogs-stream-prefix": "myapp"
        }
      },
      "entryPoint": [],
      "portMappings": [
        {
          "hostPort": 80,
          "protocol": "tcp",
          "containerPort": 80
        }
      ],
      "command": [],
      "linuxParameters": null,
      "cpu": 512,
      "environment": [],
      "resourceRequirements": null,
      "ulimits": [],
      "dnsServers": [],
      "mountPoints": [],
      "workingDirectory": null,
      "secrets": [],
      "dockerSecurityOptions": [],
      "memory": null,
      "memoryReservation": 1024,
      "volumesFrom": [],
      "stopTimeout": null,
      "image": "amazon/amazon-ecs-sample",
      "startTimeout": null,
      "firelensConfiguration": null,
      "dependsOn": null,
      "disableNetworking": null,
      "interactive": null,
      "healthCheck": null,
      "essential": true,
      "links": [],
      "hostname": null,
      "extraHosts": [],
      "pseudoTerminal": null,
      "user": null,
      "readonlyRootFilesystem": null,
      "dockerLabels": {},
      "systemControls": [],
      "privileged": null,
      "name": "myContainerDefinition"
    }
  ],
  "placementConstraints": [],
  "memory": "4096",
  "taskRoleArn": "arn:aws:iam::xxxxxxxxxxxx:role/myTaskRole",
  "compatibilities": [
    "EC2",
    "FARGATE"
  ],
  "taskDefinitionArn": "arn:aws:ecs:eu-central-1:xxxxxxxxxxxx:task-definition/my-taskdefinition:36",
  "family": "my-taskdefinition",
  "requiresAttributes": [
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "ecs.capability.execution-role-awslogs"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "com.amazonaws.ecs.capability.docker-remote-api.1.17"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "com.amazonaws.ecs.capability.docker-remote-api.1.21"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "com.amazonaws.ecs.capability.task-iam-role"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "ecs.capability.task-eni"
    }
  ],
  "pidMode": null,
  "requiresCompatibilities": [
    "FARGATE"
  ],
  "networkMode": "awsvpc",
  "cpu": "2048",
  "revision": 36,
  "status": "ACTIVE",
  "inferenceAccelerators": null,
  "proxyConfiguration": null,
  "volumes": []
}

EDIT:

This is so weird. I have changed my region from eu-central-1 to eu-west-1 and it's working fine! This problem only happens on eu-central-1.

Héctor
  • 24,444
  • 35
  • 132
  • 243
  • Can you share your task definition? Also you just run the task itself, or create ECS service with load balancers? – Marcin Jan 30 '21 at 00:40
  • @Marcin Edited. I'm running the task with no load balancer. – Héctor Jan 30 '21 at 00:45
  • If you go to your `Service`, there is `Events` tab. Does it have any entries there? – Marcin Jan 30 '21 at 01:03
  • It just shows deployment completed and service reached a steady state events. Everything looks fine. – Héctor Jan 30 '21 at 01:12
  • I made service running `amazon/amazon-ecs-sample`, but its working as expected for now. For now I don't know what could be happening. – Marcin Jan 30 '21 at 01:15
  • What cpu and memory values have you used? I don't know why but... I suspect that could be the problem. – Héctor Jan 30 '21 at 01:17
  • Does this happen only for `amazon/amazon-ecs-sample`? What if you run different example container such as `nginxdemos/hello`? – Marcin Jan 30 '21 at 01:17
  • I used cpu 256 and memory 512. – Marcin Jan 30 '21 at 01:18
  • In fact, it did happen with my app's image as well. That was the reason I tested with amazon/amazon-ecs-sample – Héctor Jan 30 '21 at 01:18
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/228026/discussion-between-hector-and-marcin). – Héctor Jan 30 '21 at 01:35

0 Answers0