What Node am I Connected to?

A YugabyteDB universe is a group of nodes (VMs, physical machines, or containers) that collectively function as a resilient and scalable distributed database.

The Yugabyte JDBC driver supports uniform load balancing where the driver makes the best effort to uniformly distribute the connections to each YugabyteDB server.

If your connection gets load balanced to another node, the inet_server_addr() function provides a simple way to figure which node that is.

Example:

				
					
yugabyte=# SELECT * FROM yb_servers() ORDER BY host;
      host      | port | num_connections | node_type | cloud  |   region    | zone  | public_ip
----------------+------+-----------------+-----------+--------+-------------+-------+-----------
 192.168.56.110 | 5433 |               0 | primary   | cloud1 | datacenter1 | rack1 |
 192.168.56.111 | 5433 |               0 | primary   | cloud1 | datacenter1 | rack1 |
 192.168.56.112 | 5433 |               0 | primary   | cloud1 | datacenter1 | rack1 |
(3 rows)
yugabyte=# SELECT inet_server_addr() connected_to_host;
 connected_to_host
-------------------
 192.168.56.110
(1 row)
				
			

Have Fun!