Home > Uncategorized > Customizing GlassFish v2 with 23 unpublished properties.

Customizing GlassFish v2 with 23 unpublished properties.

Because Grizzly has replaced the Sun WebServer runtime (starting with 9.0/GlassFish v1) in Sun’s Application Server (SJSAS), and to avoid breaking compatibility with previous release, some configuration mechanisms are not officially exposed in GlassFish‘s domain.xml as attribute or elements. We will fix the problem with our upcoming v3 release, but for now those hidden features are sleeping with the bear! Time to officially expose them. Some are highly NIO related, some not. UPDATE: if you are using GlassFish v3, all properties starts with com.sun.grizzly instead of com.sun.enterprise.web.connector.grizzly

Maintenant 038.jpg

  • -Dcom.sun.enterprise.web.connector.grizzly.selector.timeout==xxx : The time, in milliseconds, a NIO Selector will block waiting for events (users requests). By default it blocks 1000 (1 second). In some environment, increasing the value will reduce the CPU usage, but changes to that value aren’t recommended unless you are seeing high CPU, most probably when your server doesn’t have enough ram.
  • -Dcom.sun.enterprise.web.connector.grizzly.displayConfiguration=true : flush Grizzly’s internal configuration to the server logs (like number of threads created, how many polled objects, etc.)
  • -Dcom.sun.enterprise.web.connector.grizzly.enableCometSupport=true : enable Comet support for all http-listener, including the Admin-gui.
  • -Dcom.sun.enterprise.web.connector.grizzly.useDirectByteBuffer=true : Use direct ByteBuffer instead of heap ByteBuffer. Turning on direct byte buffer may improve performance if your application use a lot of memory or do a lot a write operations.
  • -Dcom.sun.enterprise.web.connector.grizzly.pipelineClass=className : replace the default Grizzly’s Thread pool with a customized one. You can easily change the Thread pool with your own by implementing the simple Pipeline interface.
  • -Dcom.sun.enterprise.web.connector.grizzly.algorithmClassName=className : replace the current http parser with a customized one. This is useful if you want to optimize the parsing based on some application headers, etc., but quite dangerous as it might breaks the http logic so use it carefully.
  • -Dcom.sun.enterprise.web.connector.grizzly.maxSelectors=xx x : The number of temporary NIO Selector used to read more bytes when incomplete read. The default is 20, but can significantly increase performance if you running on slow network.
  • -Dcom.sun.enterprise.web.connector.grizzly.factoryTimeout= 5000 : When Grizzly try to read bytes from a browser’s request, the bytes might not be available when the read occurs. By default, the thread will block for 5 seconds, and then drop the request. In some slow network (or fast), changing that value might significantly improve performance (mostly throughput).
  • -Dcom.sun.enterprise.web.connector.grizzly.asyncHandlerClass=className : change the default Grizzly’s Asynchronous Request Processing (ARP)AsyncHandler implementation. Useful if want to use ARP with your application
  • -Dcom.sun.enterprise.web.connector.grizzly.asyncHandler.ports=8080,4848 : the port supporting the ARP mechanism.
  • -Dcom.sun.enterprise.web.connector.grizzly.enableSnoop=true : dump the requests/response information in server.log. Useful for debugging purpose, but significantly reduce performance as the request/response bytes are translated to String.
  • -Dcom.sun.enterprise.web.connector.grizzly.readTimeout=5000 : the time Grizzly waits on its first read before dropping the connection. Can improve your site performance if you are under denial-of-service attack frequently, by reducing the value.
  • -Dcom.sun.enterprise.web.connector.grizzly.writeTimeout=30000 : the time before Grizzly stop waiting for the browser to read the response bytes. By default, if the browser haven’t read all the response bytes after 30 seconds, Grizzly drops the connection. Useful to improve performance on slow network (or fast).
  • -Dcom.sun.grizzly.comet.notificationHandlerClassName=classname : If you use Comet, you might want to improve the Server push performance by customizing its notification mechanism.
  • -Dcom.sun.grizzly.http.bufferResponse=true : buffer the entire response before flushing it to the client. Might improve performance as you only execute a single write operation instead of several.
  • -Dcom.sun.enterprise.web.connector.grizzly.OOBInline=true : See JDK definition.
  • -Dcom.sun.enterprise.web.connector.grizzly.protocolFinders= xxx : Inject your own Protocol finder. Quite useful if you want to open a single tcp port on a server and serve several protocol on that port (not only http).
  • -Dcom.sun.enterprise.web.connector.grizzly.protocolHandlers=className : when a protocol has been found (see the above property), redirect it to the proper container/server/etc.

All the above properties needs to be added in domain.xml using the jvm-options elements:


Now the following list of property can be added under the http-service in domain.xml:

<property name="xxx" value="xxx"/>

Et hop! Grizzly no longer have an hidden side :-)!


_uacct = “UA-3111670-1”;

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: