SoFunction
Updated on 2025-03-07

How to randomly select an IP for a machine

String ipArr[]={"127.0.0.1","127.0.0.2"};
int iRandom = new Random().nextInt()%(); // Random number of 0 and 1
        String ip =ipArr[iRandom];
        (ip);
This method can be used when load balancing is required, i.e., multiple machines are selected to handle program execution. Randomly select a machine to handle it.

The IP address can be configured in the database.

This is the practice both activation and business testing.