A Processing Unit is deployed to the GigaSpaces runtime environment, which is called the service grid. The service grid is responsible for materializing the Processing Unit's configuration, provisioning its instances to the runtime infrastructure and making sure they continue to run properly over time.

The gs-agent script is deprecated as of version 14.0, as noted in the Release Notes. Use the gs host run-agent command in the new CLI instead.


To start a service grid on a machine, launch the gs-agent utility located in the $GS_HOME/bin folder. This will start the Grid Service Agent, which is responsible for starting and managing the other service grid components (GSC, GSM, etc.). Command line arguments are used to specify which service grid components should be started and managed. In general, --process_type=n will start n instances of the specified process_type. Use the global keyword (e.g. --global.process_type=n) to specify that the agent should coordinate the hosting and management of that service with other running agents.


Run the --help or -h command to see all available options:

./ --help
gs-agent --help

Starting the Data Grid with a Manager

Use the following command to start a single Manager on your local machine (useful for development and testing):

# Starts a local manager:
./ --manager-local
# Starts a local manager and 2 GSCs:
./ --manager-local --gsc=2
REM Starts a local manager:
gs-agent --manager-local
REM Starts a local manager and 2 GSCs:
gs-agent --manager-local --gsc=2

To start a highly available cluster of Managers on several hosts, run the following command on each designated host:

# Starts a manager:
./ --manager
# Starts a manager and 2 GSCs:
./ --manager --gsc=2
REM Starts a manager:
gs-agent --manager
REM Starts a manager and 2 GSCs:
gs-agent --manager --gsc=2

You also need to configure the GS_MANAGER_SERVERS environment variable in the list of designated Manager servers.

Starting a Data Grid Without a Manager

If you can't start the Manager for some reason, but you still want high availability, you can select specific host machines as management servers, and start a LUS and GSM on each one:

# Starts a LUS and GSM:
./ --lus --gsm
# Starts a LUS, GSM and 2 GSCs:
./ --lus --gsm --gsc=2
REM Starts a LUS and GSM:
gs-agent --lus --gsm
REM Starts a LUS, GSM and 2 GSCs:
gs-agent --lus --gsm --gsc=2

Alternatively, if your environment supports multicast and you prefer a more dynamic approach, you can use the global prefix to indicate that GSMs and LUSs will be automatically started and managed by the collective of gs-agents, instead of explicitly on a specific hosts. For example, to start two global GSM and LUS components across a set of hosts, as well as 2 GSCs on each host, you can use the following command:

# Starts a LUS, GSM and 2 GSCs:
./ --global.lus=2 --global.gsm=2 --gsc=2
REM Starts a LUS, GSM and 2 GSCs:
gs-agent --global.lus=2 --global.gsm=2 --gsc=2

This configuration is convenient for new users, so it is also the default - running gs-agent without any arguments creates the same environment. If you want to disable the default configuration and start a data grid without any components, run the gs-agent with --zero-defaults or -z. This can be useful if you're planning to use the REST Manager API from another host to add or remove containers.

./ -z
gs-agent -z

Configuring the Service Grid

Service grid configuration is often comprised of two layers, namely the system-wide configuration and component-specific configuration.

The system-wide configuration specifies the settings that all components share, such as discovery (unicast/multicast), security, zones, etc. These are set using the GS_OPTIONS_EXT environment variable.

The component-specific configuration specifies settings per component type, for example that the GSC memory limit should be greater than the GSM and LUS limits. These are set using one or more of the following environment variables: GS_GSA_OPTIONS, GS_GSC_OPTIONS, GS_GSM_OPTIONS, GS_LUS_OPTIONS.

The component-specific configuration overrides the system-wide configuration where there is overlap.

For example:

export GS_GSA_OPTIONS=-Xmx256m
export GS_GSC_OPTIONS=-Xms2g -Xmx2g
export GS_GSM_OPTIONS=-Xmx1g
export GS_LUS_OPTIONS=-Xmx1g

set GS_GSA_OPTIONS=-Xmx256m
set GS_GSC_OPTIONS=-Xms2g -Xmx2g

call gs-agent.bat

Customizing the GSA Components

The GSA manages different process types. Each process type is defined within the $GS_HOME/config/gsa directory in an XML file that identifies the process type by name.

You can change the default location of the GSA configuration files using the com.gigaspaces.grid.gsa.config-directory system property.

The following process types have default configurations:

Process Type Description File Name
gsc Defines a Grid Service Container .gsc.xml
gsm Defines a Grid Service Manager gsm.xml
lus Defines a Lookup Service lus.xml
gsm_lus Defines a Grid Service Manager and Lookup Service within the same JVM gsm_lus.xml

Here is an example of the gsc.xml configuration file:

<process initial-instances="script" shutdown-class="com.gigaspaces.grid.gsa.GigaSpacesShutdownProcessHandler" restart-on-exit="pid-handshake">
    <script enable="true" work-dir="${}/bin"
            windows="${}/bin/gs.bat" unix="${}/bin/">
    <vm enable="true" work-dir="${}/bin" main-class="com.gigaspaces.start.SystemBoot">

The GSA can spawn either a script-based process, or a pure JVM (with its arguments) process. The GSC, for example, allows both types of process spawning.

  • The initial-instances parameter controls what type of spawning will be performed when the GSA spawns processes by itself (and not on demand by the Admin API).
  • The shutdown-class, followed by the restart-on-exit flag, controls whether the process will be restarted upon termination. The restart-on-exit flag has these types of values:
    • Default and recommended value pid-handshake - Restart the process on any exit value if the process started successfully, as indicated by a successful PID handshake.
    • always - Always restart the process if it exits.
    • !0 - Restart the process only if the exit code is different than 0.

    • never - Never restart the process if it exits.
  • The shutdown-class is an implementation of com.gigaspaces.grid.gsa.ShutdownProcessHandler interface and provides the default shutdown hooks before and after shutdown of a process, to make sure it is shut down properly. The shutdown-class can be omitted.
  • The restart-regex (there can be more than one element) is applied to each console output line of the managed process, and if there is a match, the GSA will automatically restart the process. By default, the GSC will be restarted if there is an OutOfMemoryError.

In addition, within the script tag, you can add the following tags:

  • argument - adds a command ling argument which will be passed to the script. In the gsc.xml example above, there are two command line arguments.
  • environment -adds an environment variable. For example, <environment name="GS_GSC_OPTIONS">-Xmx1024m</environment> can be used to override the memory for the GSC.

Advanced Configuration

In some scenarios you may need several "flavors' of components (e.g. multiple zones, or different sizes of GSCs, etc.). You can create a custom gs-agent script to manage each of those, or you can do this all within a single agent.

For example, you may want your GS agent to load 2 "small' GSCs (512MB each) in a zone called Small, and 1 "large' GSC (1024MB) in a zone called Large. To achieve this, duplicate the default gsc.xml (which resides in $GS_HOME/config/gsa) into gsc_small.xml and gsc_large.xml, and modify them to include an environment tag that defines the GS_GSC_OPTIONSenvironment variable with the required settings:

<process initial-instances="script" shutdown-class="com.gigaspaces.grid.gsa.GigaSpacesShutdownProcessHandler" restart-on-exit="pid-handshake">
    <script enable="true" work-dir="${}/bin"
            windows="${}\bin\gs.bat" unix="${}/bin/">
        <environment name="GS_COMPONENT_OPTIONS">-Xms512m -Xmx512m</environment>
    <vm enable="true" work-dir="${}/bin" main-class="com.gigaspaces.start.SystemBoot">
<process initial-instances="script" shutdown-class="com.gigaspaces.grid.gsa.GigaSpacesShutdownProcessHandler" restart-on-exit="pid-handshake">
    <script enable="true" work-dir="${}/bin"
            windows="${}\bin\gs.bat" unix="${}/bin/">
        <environment name="GS_COMPONENT_OPTIONS">-Xms1024m -Xmx1024m</environment>
    <vm enable="true" work-dir="${}/bin" main-class="com.gigaspaces.start.SystemBoot">

Now to start the GS agent, use the following command:

gs-agent --gsc_small=2 --gsc_large