Hello everyone,
I am a game server development engineer, and I am considering replacing our existing registration center with Consul. Additionally, I plan to use Consul for traffic control. Here is the initial plan:
- The Consul server is deployed inside Kubernetes.
- Considering the cost of migration, the initial deployment of process instances will still be on traditional virtual hosts, outside of k8s, All service instances register with the local Consul agent via HTTP, and the local Consul agent communicates with the Consul server.
- Service instances use TTL (time-to-live) for heartbeat checks.
- Traffic control is achieved by setting the weight of each instance in the KV store, such as
{ "dbproc-11": { "weight": 10 }, "dbproc-12": { "weight": 0 } }
. The business side retrieves this KV value via an interface and updates the in-memory instance weights, referring to these weights during allocation to control traffic. - When the process starts, it needs to query two things: 1. All healthy instances under the dbproc service; 2. The weight values of each instance in the KV store for dbproc.
Firstly, this is my initial guess. I am not sure if I misunderstood Consul’s best practices. I hope everyone can point out any mistakes.
Secondly, if this plan is feasible, is there a way to combine the two queries in step 5? I looked at the API documentation, and it seems that the existing Transactions do not support my query requirements. Are there any other ways to support my plan?
Lastly, I would appreciate any thoughts and suggestions!