Multitenancy support with IBM SDK,7R1


The multitenant JVM recently became available as part of the IBM SDK Java™ Technology Edition, Version 7 Release 1 as a tech preview. This is a mechanism for sharing run-time resources across Java virtual machine instances.

Cloud system fasten application processing and reduces memory usage by running multiple applications together within a single multitenant JVM. According to cloud providers, there are two popular multitenant architectures – shared or no shared multitenant architectures. For the shared architecture, underlying hardware and software will be same. In case of no shared multitenant architecture, the complete set of hardware and software is fully dedicated to single customer only. Obviously, in shared architecture the overall cost involved is a lot lesser.

  • Besides reducing processing time, better isolation is achieved between tenants and applications being shared on JVM.
  • Reduces applications’ start times as subsequent applications take less time to start when JVM is running already.
  • Reduces overall cost as single set of hardware and software is shared by multiple tenants.

Multitenant JVM Vs  Multiple standard JVMs.

Instead of using multitenant JVM, developer can use multiple JVMs. This associate with with memory consumption issues.

  • The Java heap consumes hundreds of megabytes of memory. Heap objects cannot be shared between JVMs, even when the objects are identical. Furthermore, JVMs tend to use all of the heap that’s allocated to them even if they need the peak amount for only a short time.
  • The Just-in-time (JIT) compiler consumes tens of megabytes of memory, because generated code is private and consumes memory. Generated code also takes significant processor cycles to produce, which steals time from applications.
  • Internal artifacts for classes (many of which, such as String and Hashtable, exist for all applications) consume memory. One instance of each of these artifacts exists for each JVM.
  • Each JVM has a garbage-collector helper thread per core by default and also has multiple compilation threads. Compilation or garbage-collection activity can occur simultaneously in one or more of the JVMs, which can be suboptimal as the JVMs will compete for limited processor time.

With this cons, maximum number of concurrent applications that can be run on multitenat JVM is improve nearly 5X.

Application Description Improvement with multitenant JVM
Hello World Print “HelloWorld” and then sleep 4.2X to 4.9X
Jetty Start Jetty and wait for requests 1.9X
Tomcat Start Tomcat and wait for requests 2.1X
JRuby Start JRuby and wait for requests 1.2X to 2.1X

Using the multitenant JVM

import java.io.*;

public class HelloFile {
  public static void main(String[] args) throws IOException {
    try(PrintStream out = new PrintStream("hello.txt")) {
      out.println("Hello, Tenant!");
    }
  }
}

Compiling and invoking the above program:

$ javac HelloFile.java
$ java -Xmt HelloFile

Resource constraints
The multitenant JVM provides controls that can be configured to limit a tenant’s ability to misbehave and use resources in a way that affects other tenants. Values that can be controlled include:

  • Processor time
  • Heap size
  • Thread count
  • File I/O: read bandwidth, write bandwidth
  • Socket I/O: read bandwidth, write bandwidth

These controls can be specified in the -Xmt command line. For example:

  • -Xlimit:cpu=10-30 (10 percent minimum CPU, 30 percent maximum)
  • -Xlimit:cpu=30 (30 percent maximum CPU)
  • -Xlimit:netIO=20M (maximum bandwidth of 20 Mbps)
  • -Xms8m-Xmx64m (initial 8 MB heap, 64 MB maximum)

 

Documented limitations

Multitenancy cannot be applied arbitrarily to Java applications. There are documented limitations.

  • Native libraries (including GUIs like SWT)
  • Debuggers and profilers

 

 

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s