1 year ago

#357593

test-img

Anuj Panchal

API throwing 503 service unavailable error occasionally and not continuously

I am getting error with status code 503 - Service Unavailable in my OPTIONS request to API Gateway in AWS (Screenshot attached below)

As you can see the OPTIONS request is failing

Our Tech Stack:

  1. API Gateway to route requests to proper docker container(s) residing inside EC2 instance running on docker-compose.
  2. Have enabled VPC peering to connect our application hosted inside the EC2 instance with MongoDB Atlas.

I had a word with the solutions architect at AWS and he said that I've configured the CORS correctly for the API Gateway and it's not a CORS issue. He said that it is an issue on my application hosted on EC2 instance.

My application is hosted in a microservices fashion on docker-compose and consists of 3 microservices. And I am facing this status 503 - Service Unavailable error only on 1 of my microservices out of the 3. The other two microservices are working perfectly fine without any issues.

I am able to see only those requests that had status 200 - OK inside my docker container logs and not those logs which encountered a status 503 - Service Unavailable error.

My API Gateway CORS configuration is as follows:

API Gateway CORS Config

Also, attaching the log generated by the API gateway in Cloudwatch:

{
    "requestId": "P1Zp3iC0BcwEJBA=",
    "ip": "<SOME IP>",
    "requestTime": "31/Mar/2022:05:31:17 +0000",
    "httpMethod": "OPTIONS",
    "routeKey": "ANY /master/{proxy+}",
    "status": "503",
    "protocol": "HTTP/1.1",
    "responseLength": "33",
    "Request_ID": "-",
    "resourcePath": "-"
}

I am not able to figure out the root cause as to why this error is popping up occasionally and not continuously as I have mentioned in the title of this question.

amazon-web-services

docker

amazon-ec2

aws-api-gateway

http-status-code-503

0 Answers

Your Answer

Accepted video resources