Server Engine Java NIO

Server Engine Java NIO

[[Client Engine connectionCacheMax|Back]]

The Java NIO technology has been around since JDK 1.4. But by default, the VBJ Server utilizes standard Java IO for socket communications with the Clients. You can configure the VBJ Server to use Java NIO technology by setting the property "vbroker.se.<se_name>.scm.<scm_name>.manager.type=Socket_nio".

Note that this property is only applicable to VBJ Server, not VBC++ Server.

The "echo_service_java" [[Explanation of Example|example]] is used in this demonstration.

Scenario

  • Start 10 Clients which create 1 threads each to call 1 VBJ Server concurrently.
  • Each client thread calls the Server once.
  • Each invocation blocks for 10 seconds at the Server side.
  • Monitor the VBJ Server's resource consumption with the default configuration.
  • Observe the effect of enabling Java Nio at the Server Engine.

How many threads are created at the VBJ Server side to service all the invocations from the 10 Clients?

Preparation

Configure the Client by modifying c.sh:

  • Set the following properties:
    • server_sleep_time 10
    • vbroker.agent.enableLocator=false
  • Disable all the other properties.

Configure the Server by modifying s.sh:

  • Set the following properties:
    • vbroker.agent.enableLocator=false
  • Disable all the other properties.

Execution

Make sure you have set up the necessary VisiBroker environment and build the example before running this demonstration.

  • Start the VBJ Server Monitor script:
    • mon_s.sh
  • Start the Server:
    • s.sh 1
  • Start the Client:
    • c.sh 10 1 1
  • Monitor the Server's resource consumption (printed by Server Monitor). E.g.:

MEMORY(KB) THREADS SOCKETS
74968      32     10

  • Stop the Client and Server.
  • Set the following property at the Server side by modifying s.sh:

vbroker.se.iiop_tp.scm.iiop_tp.manager.type=Socket_nio

  • Re-start the Server:
    • s.sh 1
  • Re-start the Client:
    • c.sh 10 1 1
  • Monitor the Server's resource consumption (printed by Server Monitor). E.g.:

MEMORY(KB) THREADS SOCKETS
74912      23      10

Observations

Compare the resource consumption measurement of the VBJ Server before and after  tuning “vbroker.se.iiop_tp.scm.iiop_tp.manager.type=Socket_nio” property at the VBJ Server side.

Server Memory (KB)  Server Threads Server Sockets
Before Tuning 74968 32 10
After Tuning 74912 23 10

Key observations after tuning:

  • The number of threads created by the Server is lesser.
  • The memory usage by the Server is lesser.

Explanation

A VBJ Server can be configured to use the Java NIO feature by setting the property "vbroker.se.<se_name>.scm.<scm_name>.manager.type=Socket_nio".  The default value is "Socket", which configures the VBJ Server to use the standard Java IO.

Using Java NIO technology enables the VBJ Server to handle a larger number of concurrent client connections with fewer threads compare to using standard Java IO. This translates to higher scalability as lesser thread resources are required to handle more clients.

The standard Java IO implementation requires a Worker Thread per established connection to wait for (and read) any new request message that may arrive. This implies that the number of Worker Threads needed to just listen at the connections varies directly with the number of connections. Including those Worker Threads which are doing the actual work (i.e. executing the application method implementation), the total thread and memory resource consumption can become a concern for large number of connections.

The Java NIO implementation does not have this thread per connection overhead. Only one listener thread is needed to listen to all the established connections. The Worker Threads are dispatched to service the requests only when new requests arrive at the connections. That is why Java NIO feature may scale better when the number of concurrent client connections is very large.

Whether Java NIO feature can bring about better performance to your VBJ Server depends on the nature of your application. For example, a Server receiving requests from a few clients will benefit less from Java NIO feature compare to a Server receiving requests from a huge number of clients. So you must perform benchmark tests to find out the appropriate setting that is suitable to your application.

[[Client Engine connectionCacheMax|Back]]  |  [[Other Connection Tuning|Next]]

Labels (1)

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
2 of 2
Last update:
‎2020-03-13 21:06
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.