Lets say I have an App on App Platform with a single component which has many containers running.
If I expose say a /metrics endpoint it could be served by any of the containers.
Is there a way for me to route requests to a specific container? I have noticed that there is an environment variable called HOSTNAME that is unique for each container such as “component-7f844c67c-7c4bx” which looks like it could work but it doesn’t appear to resolve DNS.
// The address of my app https://app-kssfa.ondigitalocean.app
// Some of the formats I have tried https://app-kssfa.component-56447c7b7d-jv862.ondigitalocean.app https://component-56447c7b7d-jv862.ondigitalocean.app
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hey David! 👋
In the DigitalOcean App Platform, requests are routed through a load balancer by default, which distributes traffic evenly across all running containers for scalability and reliability. Unfortunately, directly routing requests to a specific container isn’t supported because containers are designed to be stateless and interchangeable.
However, if specific behavior is needed for certain routes, you could split your app into multiple components and use path-based routing to direct traffic to the right component.
Example:
/api/v1
→ Component A/api/v2
→ Component B📖 More on URL Path Routing
If container-specific routing is critical, using Droplets with Nginx/HAProxy or a managed DigitalOcean Kubernetes cluster might give you the fine-grained control you need.
Let me know if any of these work for you!
- Bobby