Monday, March 28, 2016

Running Node.JS Apps and "Fat-JAR" Apps on Application Container Cloud Service

With the trend of container technologies going on it is great to see Oracle is providing the so called Application Container Cloud Service. Its current architecture is based on Docker and allows to run Java SE and Node.js applications in its current version. See the the following diagram

The Load Balancing, dockerizing and scaling is fully transparent. From developer perspective you are deploying a ZIP containing a manifest.json with a command property that states what should be executed once the deployment has been installed on the specific container.

In the following figure you see the overview screen of Application Container Cloud service (ACC).

Next lets create an app and deploy it to ACC. For Java SE lets see how that manifest.json looks like

Java SE App

The important properties are runtime / majorVersion and command. It states that the deployment needs Java 8. The application is started with the given "java -jar ..." command. Currently two working samples are provided, one works with embedded Tomcat the other works with Grizzly Http Server. Here is how a typical class would look like

The PORT and HOSTNAME are given from the environment. So it is in control of the application container cloud service.

Node.js App
For a Node.js app that manifest.json looks like

It expects a file server.js as the main entry point. There is an official Node.js sample application (together with a Tutorial). In my example I am going to create a connection to Oracle Database Cloud Service (via oracle nodedb driver) and expose DEPARTMENTS as a read online REST Resource.

The most interesting part here is how to retrieve the CONNECT String to the Database.

For testing on local machine defaults are used. Once deployed the CONNECT String is given as an environment property (beyond PORT, USER, etc).

Hint: All the JavaScript modules except native add-ons like node-oracledb should be included in the ZIP bundle.

The deployment is quite straightforward from the ACC UI using the "upload application archive" option. Further you can provide initial values for number of "Instances" and Memory.

After about 5 min. the application is available through the Load balancer. For automated deployment a REST API exists.

To connect to other cloud services a service binding needs to be created first. The service binding creates environment variables that are available to every application instance.

Custom environment variables can be created. For example the schema user / password you want to connect with. Unfortunately just clear text values are accepted at the moment. Would be great to have a "secret type" for passwords. Further  # characters are not allowed (although my schema name is c##hr  ;) ).  Anyway it is no major show stopper.

See the sample service running in Postman

Logging / Diagnostics
Logs are stored on the Oracle Storage Cloud Service as a zip file. To look into the log files you have to download those ZIP files on your local disc first

For Java SE Apps a Flight Recording is possible.


The first public release of ACC looks quite promising. For the next versions my wishlist would contain
- Online Log Viewer
- Monitoring RAM / CPU Usage / Requests online
- Automatic Scaling
- Service discovery
- Security ?
- Adding environment variables of type "secret". (Currently you can only provide variables in clear text)
- Packaging improvements, maybe some mvn acc:install or CLI Tooling

Looking forward to new features in the future versions. There is potential for a modern microservice platform.

Samples Code
Explore the Node.JS sample code on
The Java SE jersey based code is available from Oracle.

Further Information

No comments:

Post a Comment