when do you use selenium grid code example

Example 1: selenium grid configuration

java -jar selenium-server-standalone-2.53.1.jar -role hub -hubConfig hubconfig.json

Example 2: when do you use selenium grid

When do you use Selenium Grid?
Selenium Grid can be used to execute 
same or different test scripts on
multiple platforms and browsers
concurrently so as to achieve distributed test execution.

Example 3: nodes and hubs in selenium grid

-we run this jar from 2 roles: hub and node
-hub receives commands Webdriver object of the client
-then hub is looking for available nodes 
 for execution.
-nodes are executing tests

Example 4: how to configure selenium grid to driver

I configure my driver class to run remote test.
DesiredCapabilities.desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("browser","chrome");
URL gridUrl = new URL("http://ipAdress.4444/wd/hub");
driverPool.set(new RemoteWebDriver(gridUrl, desiredCapabilities));

Example 5: how selenium grid looks like

-it's a java program looks like jar file
-we run this jar from 2 roles: hub and node
-hub receives commands Webdriver object of the client
-then hub is looking for available nodes 
 for execution.
-nodes are executing tests