AWS ECS 503 Temporarily Unavailable During Deployment

I am using Amazon Web Services EC2 container service with application load balancer for my application. When I deploy the new version, I get 503 Service Temporarily Unavailable for about 2 minutes. This is slightly longer than the launch time of my application. This means that I cannot perform a deployment with zero downtime.

Is there a parameter to not use new tasks during their launch? Or what am I missing here?

UPDATE:

The health check numbers for the target ALB are as follows:

Healthy threshold:     5
Unhealthy threshold:   2
Timeout:               5 seconds
Interval:              30 seconds
Success codes:         200 OK

Healthy threshold: “Number of successful health checks needed before considering a healthy healthy goal.”
Unhealthy threshold: “Number of successive health checks needed before considering a goal that is unhealthy.”
Timeout: "The amount of time, in seconds, during which no response indicates a failed health check."
Interval is the "approximate amount of time between health checks for a particular target

2: , EC2, . 2. , . (jenkins aws cli script) 4. AWS ( ). - .

+6
5

, . , 80 8080 . , , - . 0, ECS 32768-61000, , , . , , ALB .
, ECS , 50/200 / , . .

, !

+2

AWS ECS, , " " " "

, " " 200 " " 50, .

, :

, .

, .

50 " " , , .. "2", "1" , . , .

, 200 " " ecs-, .

, - .

+2

30 , 2 ( , ). 2 3 , ( , - , ).

, , , . , .

, AWS , ( , ).

+2

, , ALB , . , script , node, OutOfService.

, . node . node LB, , Inservice node , node, .

script

# Remove Health Check target
echo -e "\nDisabling the ELB Health Check target and waiting for OutOfService\n"
rm -f /home/$USER/$MYAPP/server/public/alive.html

# Loop until the Instance is Out Of Service
while true
do
        RESULT=$(aws elb describe-instance-health --load-balancer-name $ELB --region $REGION --instances $AMAZONID)
        if echo $RESULT | grep -qi OutOfService ; then
                echo "Instance is Deattached"
                break
        fi
        echo -n ". "
        sleep $INTERVAL
done
+2

, Jenkins, ( ECS, Jenkins , ).

503

503 , , , healthchecks ( ). , 0.

HTTP, 200 ( ) , . , .

, 503 , , ( ), ECS . .

, ( , ):

  • -, 200 ( Jenkins , , /robots.txt).
  • TCP-, HTTP-. , .

node

, node , ( ECS). ECS , . HTTP (, Jenkins 80, 50000 ).

, , , :

myloadbalancer.mydomain.com:80 ( 80 ) → : 8081 ( ) → : 80 ( ).

, , .

Jenkins, , Jenkins Metrics, URL- .

, URL-, : http://myjenkins.domain.com/metrics/mytoken12b3ad1/ping

URL- HTTP- 200 , , , , .

, , , , , AWS Cloudwatch.

( conf):

: awslogs
awslogs-group: mycompany ( Cloudwatch, )
awslogs-region: us-east-1 ( )
awslogs-stream-prefix: myservice ( )

This will give you more information about what happens during initialization of the container if it is too long or if it does not work.

Hope this helps !!!

+1
source

All Articles