By David
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!
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 BIf 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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.