Consul difference between agent and catalog
Asked Answered
I

1

7

I don’t understand the difference between consul’s agent api and catalog api

Although the consul document has always emphasized that agent and catalog should not be confused,But there are indeed many methods that look similar, such as:

When should I use catalog or agent(Just like the above http url)?

Which one is suitable for high frequency calls?

Inconsumable answered 6/1, 2021 at 6:24 Comment(0)
C
8

Consul is designed for services to be registered against a Consul client agent which is running on the same host where a service is deployed. The /v1/agent/service/ endpoints provide a way for you to interact with services which are registered with the specific Consul agent to which you are communicating, and register new services against that agent.

Each Consul agent in the data center submits its registered service information to the Consul servers. The servers aggregate this information to form the service catalog (https://www.consul.io/docs/architecture/anti-entropy#catalog). The /v1/catalog/ endpoints return that aggregated information.

I want to call out this sentence from the anti-entropy doc.

Consul treats the state of the agent as authoritative; if there are any differences between the agent and catalog view, the agent-local view will always be used.

The catalog APIs can be used to register or remove services/nodes from the catalog, but normally these operations should be performed against the client agents (using the /v1/agent/ APIs) since they are authoritative for data in Consul.

The /v1/agent/ APIs should be used for high frequency calls, and should be issued against the local Consul client agent running on the same node as the app, as opposed to communicating directly with the servers.

Cheder answered 14/1, 2021 at 19:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.