Skip to content

I am trying to launch a microservice for wordpress and using service connect to connect three services Nginx, db, php. But my services are not able to connect to each other.

0

I used used 3 task definition to launch 3 different services of nginx, db(mysql), php(php-fpm). and I created a namespace called wp-micro. In the Nginx configuration i gave the endpoint of phpfpm service as php.wp-micro:9000. And for connection with database service I gave the mysql endpoints as db.wp-micro:3306. My services are up and running but I am getting error 502, while accessing the wordpress. I had done the same thing perfectly fine using the service discovery on the Old Classic Console of ECS.

service and client service connect configuration getting these error in nginx logs

1 Answer
0

Hi Saurabh, your confirmation looks correct, I think that the problem you are facing is related to the strict ordering deployment required of ECS Service Connect. If you application has the following architecture:

nginx --> php(php-fpm) --> db(mysql)

You should deploy the service with ECS Service Connect enabled in the following order:

  1. db(mysql)
  2. php(php-fpm)
  3. nginx.

As expressed in the documentation here: "The services need to be created in this order to prevent an time period when the frontend client service is running and available the public, but a backend isn't. This eliminates error messages from being sent to the public during that time period. In AWS CloudFormation, you must use the dependsOn to indicate to AWS CloudFormation that multiple Amazon ECS services can't be made in parallel or simultaneously. You should add the dependsOn to the frontend client service for each backend client-server service that the client tasks connect to." https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-connect-concepts-deploy.html

AWS
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.