Building Scalable Internet Applications with Oracle8i JServer


Julie Basu

Goal of the Demonstration

In this session at VLDB 2000, we demonstrated the salient architectural features of Oracle8i JServer that enable the development of powerful and scalable Java applications for the Internet.

What is Oracle8i JServer?

Java is emerging as the primary language for writing Internet applications. Reasons for its popularity include its rich object-oriented framework, memory safety, and platform independence. The Oracle8i database embeds a Java Virtual Machine (JVM) that is designed for high performance and scalability in the web environment. This JVM serves as the basis for the JServer platform, which provides a comprehensive set of Java-based programming tools such as Java stored programs for procedural computations, Enterprise JavaBeans for writing modular business logic components, Java servlets and JavaServer Pages for web-based access, and JDBC / SQLJ for SQL data manipulation. The powerful APIs in Java 2 Enterprise Edition (J2EE) are completely supported by JServer.

Scalability of Java Web Applications

The Internet imposes stringent requirements on the performance and scalability of web applications. These applications must provide response times that are acceptable for "online" human interaction, and they must be capable of handling concurrent requests from possibly hundreds or even thousands of simultaneous users. Any performance degradation, which is inevitable in practice for such large numbers of users due to system limitations, should be graceful and not erratic.

In order for a Java application to be highly scalable, the Java server platform must support efficient execution of code from concurrent clients. The storage management strategy of the server is of great importance, because the Java language mandates automatic memory allocation and garbage collection. Furthermore, the Java application developer should not be unduly burdened with writing highly complex multi-threaded code, which is error prone, in order to be scalable.

Why Oracle8i JServer Scales Well

Below we list the architectural features of Oracle8i JServer that are behind its superior scalability:

Demonstrated Examples

The examples demonstrated at the VLDB session showed the difference between executing a program on the JDK and on the session-oriented JServer. Specifically, the intent was to show, through some simple code samples, the difference in the handling of static variables and in the programming style for the two Java platforms. Here is how this was done.

There is a basic class called SessionTest. The class is public and defines a static variable called staticVar. This class also defines a method incrementStaticVar that adds the input value (i.e., the parameter to this method) to the static variable. There is another method getStaticVar which returns the current value of the static variable.

The code for the SessionTest class appears in the file SessionTest.java. This code was deployed on the JDK as a compiled Java class, and on the Oracle8i JServer as a stored Java program (refer to the Oracle documentation on the steps involved in this process). On JServer, the incrementStaticVar method was deployed as a stored procedure (since it does not return any value), and the getStaticVar() method was deployed as a stored function (since it returns an integer value).

Next, we define a set of platform-specific classes to demonstrate the difference in programming paradigms between the JDK and JServer.

Code for JDK

The relevant classes for the JDK platform are:

Code for JServer

The relevant classes for the JServer platform are:

Executing on JDK

The relevant Java code appears in the files User.java and SessionDemo.java.

The output of after compiling these files and executing the main method in the SessionDemo class is provided in the JDK_output.txt file. As shown in this file, the value of the static variable is 10 after construction of the first User instance, and is 30 after construction of the second User instance.

Executing on JServer

The relevant Java code appears in the files Oracle8iUser.java and SessionDemo8i.java.

The output of the SessionDemo8i provided in the JServer_output.txt file. As shown in this file, the value of the static variable is 10 after construction of the first User instance, and is 20 after construction of the second User instance. In contrast to the JDK, the value of the static variable did not get incremented to 30. This is because each user (database) session is effectively executing in its own virtual JVM, insulating it from the effects of static variable manipulation in other sessions.

Summary

Most Java platforms that claim to be scalable require application developers to employ complex threading techniques. This approach is inherently problematic, since applications that are heavily multi-threaded are generally difficult to design, code, and debug. Other problems include contention from memory sharing, and a single garbage collector that deals with common garbage from all users of a JVM.

Oracle8i JServer is a comprehensive enterprise-level highly scalable Java server platform that is tightly integrated with the Oracle8i database. Both have a common notion of a user session that is effectively isolated from other concurrent user sessions, thus providing a simpler programming model. JServer presents the appearance of a dedicated virtual JVM for each user. This behavior was demonstrated through Java code executed on the JDK and on the Oracle8i JServer, and specifically for initialization of static variables.

In conclusion, JServer does not require complex multi-threaded coding for applications to be scalable. Memory management is highly optimized in this session-oriented server architecture, with independent allocation and garbage collection for each user session. Applications can be natively compiled during deployment, and once deployed, high scalability is achieved through the underlying sophisticated and efficient architecture of JServer.