Junior — Middle
How does one microservice determine how to communicate with another in the Direct Call approach?
sobes.tech AI
Answer from AI
In the Direct Call approach, a microservice directly calls another microservice at a known address. Usually, one of the following methods is used:
- Hardcoded URL or IP address — the service stores the address of the other service in configuration.
- Service Discovery — the service uses a service discovery system (e.g., Consul, Eureka) that returns the current address of the required microservice.
- DNS or Load Balancer — the call is made via a domain name that resolves to the service's address.
Thus, the microservice determines how to connect to another, using either static configuration or dynamic discovery through service discovery, allowing for scaling and address changes.