Child pages
  • Tuning the Server
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 21 Next »

Servoy Application Server JVM Tuning

Java version
Servoy supports both Java 5 and Java 6 (for the server, the clients and developer). Java 6 has numerous performance improvements, so it is preferred over Java 5.

When the hardware of the Servoy is 64bit, make sure to also run a 64 bit Java Virtual Machine. When in doubt which version is used, check the Servoy Admin page, under "Servoy Server Home" > "Servoy Server Status" > "JVM Information":

  • 64 bit: java.vm.name=Java HotSpot(TM) 64-Bit Server VM
  • 32 bit: java.vm.name=Java HotSpot(TM) Client VM

An 32 bit JVM will allow a max memory of 2 Gb in total, In order to run with larger heap sizes (over 2 Gb) you have to use 64 bit JVM on 64 bit OS!

Java Virtual Machine Server mode
Java has 2 distinct operating modes: client mode and server mode. When running in server mode, the startup of the Java process will take longer and initial execution of code will be slower, but after a while the application will perform faster. The server mode is best suited for the Servoy Application Server.

Whether or not a Java Virtual Machine supports client and/or server mode depends on the hardware, see http://download.oracle.com/javase/6/docs/technotes/guides/vm/server-class.html.

If the JVM supports servermode, it will automatically detect if the machine it is running on is a "capable" machine and automatically run in server or client mode depending. The definition of "capable" may differ from Java version to Java version. For Java 5/6 this means a 2CPU, 2Gb memory machine.

Checking whether or not a Servoy Application Server runs in client or server mode can be seen on the Servoy Admin page, under "Servoy Server Home" > "Servoy Server Status" > "JVM Information":

  • Server mode: java.vm.name=Java HotSpot(TM) 64-Bit Server VM
  • Client mode: java.vm.name=Java HotSpot(TM) Client VM

It is possible to enforce the Servoy Application Server to run in server mode (assuming the JVM is capable to operate in server mode), an extra startup argument can be added to the startup of the Servoy Application Server.

In servoy_server.sh/bat:

java -server -Djava.awt.headless=true .....

When using the Service wrapper:

# Java Additional Parameters
wrapper.java.additional.1=-Djava.awt.headless=true
wrapper.java.additional.2=-Duser.dir="C:\Users\pbakker\Desktop\tmp servoy\application_server"
wrapper.java.additional.3=-XX:MaxPermSize=128m
wrapper.java.additional.4=-server

On Windows 32 bit environments , the Java Runtime Environment does not include support for server mode. In order to take advantage of server mode optimizations on 32 bit windows systems, it is required to install Java Development Kit (JDK)

Memory

Processes in Java, like the Servoy Application Server, need to be told explicitly the maximum of memory they are allowed to use. This setting, the maximum heap size, is important to adjust to the load the Servoy Application Server is to handle.

The maximum heap size setting is set in {servoy_install}/application_server/servoy_server.sh/.bat, through the "Xmx" setting.

When the Application Server is started as a Service through the setting can be found in {servoy_install}/application_server/service/wrapper.conf, by the name of "wrapper.java.maxmemory".

By default the maximum heap size is set to 256MB. This setting should be changed when:

  • The actual used memory is >= 70% of the specified maximum. The actually used memory can be found on the main page of the Admin page, under System Information, like: Heap memory: allocated=549184K, used=371473K, max=699072K
  • When there is plenty of free real memory available on the OS level, Servers in general just run faster when not memory constraint. (When 2Gb free real memory availeble just asign 2Gb, it will stays unused otherwise. The JVM will not take more memory then assigned ever)
  • When the expected client load will exceed the maximum: As a rule of thumb:
    • Smart Client: assume a memory usage of about 600kb for each Smart Client. NOTE: When the Servoy HTTP Tunnel is used, assume 900kb per Client.
    • All other type of Clients (Web, Headless, Batch): the required memory for each client depends on the size and design of the solution, but should be in the order of magnitude of a couple of Mb per Client.

Servoy Application Server settings for Database Tuning

Databases have a max connection poolsize to prevent memory problems, but the default 10 can be too low when using many clients on 1 server.
As rule of thumb, if the active connection is > 70% of the max then set the max higher, its however not advised to have more then 30 connection max. (since databases them self have limits on how much they can handle, postgress for example default 40 max)
The idle connection parameter is just for efficient memory usage, when allow many idle more memory is occupied when idle, low idle means more connections have to be created (which is expensive time wise)

When noticing performance problems also watch the "performance data" section. At all times the normal Servoy SQL should be below 0.5 seconds not including reporting or search queries. If this is not the case contact an database administrator for index creation.

Servoy Application Server log

At all times try to keep the Server log free from javascript application errors/excpetions, all application exceptions point to possible problems inside the application!

Out of memory errors means the heap size is configured to small.
Nullpointer errors indicate Servoy codebase problems, incase these are noticed file a support case containing the log entry.
Network error are only listed as non critical (orange) which may point to (possible) networks (config) problems, when many errors are continuous listed these should definitely be investigated.

Servoy Application Server settings for Web Client Tuning

servoy.webclient.templates.use_local_ids

For the Web Client, Servoy generates HTML markup. In order for Servoy to dynamically update only parts of the UI through Ajax, each object in the HTML Markup receives a unique ID. This ID is also placed in the editable Web Client templates.

Servoy has 2 modes for generating the ID's:

  • Using unique identifiers that are part of the internal design of the Solution created with Servoy. These ID's, as they are part of the solution design, are the same on any Servoy Application Server where the solution is imported. 
  • Using local identifiers. These identifiers are generated at runtime and thus differ per installation and session.

The advantage of the local identifiers are that they are shorter in length, thus bring down the weight of the generated HTML markup. The advantage of the unique identifiers is that they are the same on any server where the solution is running.

If templates are used to modify the generated HTML markup for Web Clients, then the unique identifiers are to be used, in order to maintain the link between the identifiers in the edited templates and the identifiers used at runtime. Otherwise the local identifiers can be used.

By default a Servoy Application Server uses the unique identifiers. Enabling the use of local identifiers can be done by setting the servoy.webclient.templates.use_local_ids option on the Servoy Admin page to true (located under Servoy Settings > Web Client settings) 

Content compression

In order to minimize the size of the content that the browser has to download for the Web Client, it's possible to turn on compression. The Servoy Application Server is currently not configured to automatically compress the content. 

Compression can be done by the Apache Tomcat instance that is part of the Servoy Application Server, or can be done by an HTTP server that is in front of the Servoy application Server, like an Apache HTTPD Server. 

In order to enable compression in the Tomcat instance that is part of the Servoy Application Server, open the file "server.xml" located in {servoy_install}application_server\server\conf\. and locate the Connector:

<Connector port="8080"
  protocol="HTTP/1.1"
  maxThreads="500" connectionTimeout="60000"
  redirectPort="8443" useBodyEncodingForURI="true" />

and add the following atttributes:

  • compressableMimeType="text/html,text/xml,text/css,text/javascript,text/plain" 
  • compression="on"
  • compressionMinSize="2048" 

so the connector is configured like this:

<Connector port="8080"
  protocol="HTTP/1.1"
  maxThreads="500" connectionTimeout="60000"
  redirectPort="8443" useBodyEncodingForURI="true"
  compressableMimeType="text/html,text/xml,text/css,text/javascript,text/plain" compression="on"
  compressionMinSize="2048"/>

Save the edits and restart the Servoy Application Server to let the configuration changes take effect.

As of Servoy 6.0, the Tomcat compression configuration will be enabled by default

It is also possible to handle the compression outside of the Servoy Application Server, for example in an Apache HTTPD Server placed between the Servoy Application Server and the outside world. The advantage of this is that Tomcat's compression options are limited, so an external HTTP server offers more options.

When it comes to Apache HTTPD server, there are two options:

  1. Compression using mod_deflate
  2. Compression using gzip

When it comes to compression, there are two factors that come into play, the time it takes to do the actual compression and the rate of compression achieved, resulting in quicker downloads to the browser due to smaller size. This is primary difference between mod_deflate and gzip in Apache HTTPD: while gzip gets a better compression rate than mod_deflate, it takes more time and CPU to perform the compression. In the case of Servoy Web Clients, that, due to it's Ajax driven design, performs a lot (albeit small) requests to the server, the overall performance will be better using mod_deflate.

Details on setting up mod_deflate on an Apache HTTPD server can be found here: http://httpd.apache.org/docs/2.0/mod/mod_deflate.html

  • No labels