<@ULVA73B9P> I'm working on deploying Prefect Serv...
# ask-marvin
e
@Marvin I'm working on deploying Prefect Server on ECS, v0.15.13 (need to host this version for now) and going through some issues. I'm hosting it on a ECS cluster (all containers on the same task) using awsvpc (you can't reach containers by name, only using
localhost
). My load balancer is configure to redirect traffic from port 8080 to 8080 (UI port), and my ECS service is exposing port 8080 as well, to receive this traffic. On the URL, I can see the UI interface (it opens up getting-started endpoint). The problem I'm having is basically that I can't connect to the backend. And the question I have is, is it correct to use the port 8080 or should I use the Apollo's 4200 port? The log I get from apollo is:
FetchError: request to http://<my-url>:4201/graphql/ failed, reason: connect ETIMEDOUT 52.7.152.112:4201
My PREFECT_API_URL env var is:
http://<my-url>:4201/graphql/
Any help would be much appreciated!
m
It seems like your issue revolves around the configuration of Prefect Server on ECS, particularly with the ports and the
PREFECT_API_URL
setting. Based on the information gathered: 1. Ports: The Prefect Server UI typically runs on port 8080, which you've correctly configured for your load balancer and ECS service. However, the backend Apollo service (GraphQL API) uses port 4200 by default. Your
PREFECT_API_URL
should indeed point to this port, but it should be
http://<my-url>:4200/graphql/
instead of 4201. 2. Configuration: Ensure that your
PREFECT_API_URL
environment variable is correctly set to
http://<my-url>:4200/graphql/
. This is crucial for the Prefect Server components to communicate properly. 3. ECS Networking: Since you're using
awsvpc
mode, make sure all containers can communicate internally using
localhost
or their respective IP addresses. You may need to adjust security groups or network ACLs to allow this communication. 4. Documentation and Issues: According to the Prefect ECS Guide, it's important to correctly set the
PREFECT_API_URL
for the containers. Additionally, there are no direct GitHub issues matching your exact problem, but similar issues have been resolved by ensuring correct network configurations and environment variable settings. In summary, double-check your
PREFECT_API_URL
and ensure it's set to use port 4200. Adjust any networking configurations to ensure containers can communicate internally. If issues persist, consider consulting the ECS guide linked above for detailed configurations.
e
@Marvin and should my prefect_api_url be http/localhost4200/graphql/ or should it be the url on my LB, like https://my-url.com:4200/graphql/? Because my URL is open on port 8080, and redirecting to the same port on my ECS cluster. So, since im redifecting to my UI container (the one running on port 8080), it'd make sense if I ran localhost, since it would try to redirect traffic internally instead of outside the ecs cluster. Or does the API URL must be pointing at my external URL and I should open port 4200 on my LB?
m
In your setup, since you're using
awsvpc
and all containers are on the same ECS task, the
PREFECT_API_URL
should indeed use
localhost
. This allows internal communication between the containers without needing to expose additional ports externally. Here's the recommended approach: 1. Internal Communication: Set
PREFECT_API_URL
to
<http://localhost:4200/graphql/>
. This ensures that the Prefect components communicate internally within the ECS task, leveraging the local network. 2. Load Balancer Configuration: Your load balancer should only need to manage external traffic to the UI on port 8080. There's no need to expose port 4200 externally unless you have specific requirements to do so. 3. Network Mode: Ensure that your ECS task definition and security groups allow communication between containers using
localhost
. This setup keeps your backend API traffic internal to the ECS cluster, reducing exposure and potential security risks from opening additional ports on your load balancer.