Kong: the default load-balancing algorithm is round-robin by weight

Weights make it proportional, so a target with weight 200 gets twice the traffic of one with 100. Consistent hashing is the alternative when a client must keep hitting the same node.

Code
# weighted round-robin (default)
curl -X POST http://localhost:8001/upstreams --data name=u1

# sticky by client IP
curl -X POST http://localhost:8001/upstreams \
  --data name=u2 \
  --data algorithm=consistent-hashing \
  --data hash_on=ip

# sticky by a header or by consumer
  --data hash_on=header --data hash_on_header=X-Session-Id
  --data hash_on=consumer

# least-connections
  --data algorithm=least-connections
Output
# consistent-hashing keeps a given key on one target even when the target
# list changes - only the keys that mapped to a removed node move.
#
# hash_fallback decides what happens when the hash input is missing:
#   --data hash_fallback=ip
#
# Sticky routing is usually a workaround for session state in the upstream.
# It is worth asking whether the state can move instead.
Advertisement

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-08-25