NodeJS vs J2EE Stack - A Performance Comparison Study

This report is based on our research and findings about performance of a popular and extensively used multithreaded synchronous model based web application technology using Spring/Hibernate, compared against the power of an event based, single process, asynchronous model based web application technology using NodeJS. We tested the NodeJS capabilities about being blazing fast and being highly concurrent with its event based asynchronous model, and produced variety of performance charts and suggestions on when to use NodeJS and when to use Spring/Hibernate.



NodeJS Next Steps

Are you considering NodeJS for scalability?

We have scaled our NodeJS cluster to 1 Million transactions in less than a second. It is like 1 Billion transactions in just 15 minutes.

Talk to TechFerry to explore if NodeJS is the right choice for you.



Table of Contents

NodeJS vs J2EE Stack - A Performance Comparison Study

Case Study at a glance NodeJS vs Java EE - Performance Comparison Summary
  • When to use NodeJS
  • When to use JEE (Spring/Hibernate) Stack
Results Comparison Snapshot with Brief Analysis
  • Understanding the data headings
  • Use case 1 : Write a Record
  • Use case 2 : Read a Record
  • Use case 3 : Slow Independent Reporting Queries
  • Use case 4 : Slow Simulated Queries using DB Sleep
Detailed Graphical Results
  • Use case 1 : Write a Record | User/Loops (100/1000)
  • Aggregate Report
  • Active Threads Over Time
  • CPU & Memory
  • Hits Per Second
  • Response Latencies Over Time
  • Response Times vs Threads
  • Transaction Throughput vs Threads (Scales may differ)
  • Transactions per Second
  • Database Threads
  • Use case 2 : Read a Record | User/Loops (100/1000)
  • Aggregate Report
  • Active Threads Over Time
  • CPU & Memory
  • Hits Per Second
  • Response Latencies Over Time
  • Response Times vs Threads (Scales may differ)
  • Transaction Throughput vs Threads (Scales may differ)
  • Transactions per Second
  • Database Threads
  • Use Case 3 : Slow Independent Reporting Queries (10/100)
  • Aggregate Report
  • Active Threads Over Time
  • CPU & Memory
  • Hits Per Second
  • Response Latencies Over Time
  • Response Times vs Threads
  • Transaction Throughput vs Threads
  • Transactions per Second
  • Database Threads
  • Use Case 4 : Slow Independent Queries Simulated using DB Sleep (10/100)
  • Aggregate Report
  • Active Threads Over Time
  • CPU & Memory
  • Hits Per Second
  • Response Latencies Over Time
  • Response Times vs Threads
  • Transaction Throughput vs Threads
  • Transactions per Second
  • Database Threads




Sample Chapter

Case Study at a glance

This report is based on our research and findings about performance of a popular and extensively used multithreaded synchronous model based web application technology using Spring/Hibernate, compared against the power of an event based, single process, asynchronous model based web application technology using NodeJS. We tested the NodeJS capabilities about being blazing fast and being highly concurrent with its event based asynchronous model, and produced variety of performance charts and suggestions on when to use NodeJS and when to use Spring/Hibernate.

The Playfield

Two small applications simulating following use cases were written. One using Spring/Hibernate running on Tomcat with MySQL database at backend and another application using NodeJS with MySQL database at backend. Jmeter has been used to fire similar test load with varying load patterns to both the applications.

  1. Use Case - Write a record : A module to insert a record into one single DB table and the backend returns a success/decline json response.

  2. Use Case - Read a record : A module to read the same record by passing a query parameter and the backend returns the record as json string.

  3. Use Case - Slow Independent Reporting Queries : A module in which multiple slow DB queries are fired in same request and the queries are independent of each other (a case of blocking I/O that can be done asynchronously by NodeJS but Spring/Hibernate will perform this sequentially for same thread/request). Here DB CPU can become bottleneck so outcome may not correctly reveal the power of NodeJS asynchronous model. So we created use case (4) below.

  4. Use Case - Simulated Independent Slow Queries using DB Sleep : A module simulating (3) again but with “select sleep(n)” queries which will not cause any DB CPU bottleneck, still simulating slow response times. True demo of async capabilities of NodeJS.

Ensuring a Fair Game

In our performance lab tests, we ensured both Tomcat (with Spring/Hibernate app deployed) and NodeJS application had same connection pool size and big enough thread pool size to avoid “connection refused” type errors under heavy load on system. Both of the applications used most popular MYSQL Database Connection Driver for their platforms and both of the application had ample heap memory size allocated to fulfil their memory requirement for heavy test loads. And above all both the applications responded with a simple JSON message string, so no templating engines or JSON parsers to contaminate the results. Just pure frameworks/deployments put to benchmarking test.
Both the applications were tested one by one on same hardware and a closed loop private network to provide consistent test environment. A warm up load was given to each application before firing actual load tests or recording results.

Load Testing Setup

Apache Jmeter has been used to fire variety of test load pattern simulating near production like environment scenarios, and study the behaviour of applications under different user load conditions. This tool provides extensive behavioural data for analysis. We plugged in a APC plugin extension to Jmeter to produce huge variety of charts and statistics on various parameters. On top of this variety of supplementary tools were used like JvisualVM, Process Explorer and Perfmon Jmeter plugin to monitor system resource usage such as heap size, thread pool, CPU/Memory/Disk-I/O usage etc. for each load test pattern fired. NodeJS and Spring/Hibernate application (on Tomcat) were setup on one machine. MySQL DB was setup on a different machine connected over a private and closed loop network to avoid any external interference.

NodeJS vs Java EE - Performance Comparison Summary

To continue reading, Download the FREE report.

When to use NodeJS

To continue reading, Download the FREE report.

When to use JEE (Spring/Hibernate) Stack

To continue reading, Download the FREE report.





NodeJS Performance

Are you considering NodeJS for performance gains?

Are you thinking of setting up a NodeJS cluster? Are you considering NodeJS as an add-on to your existing J2EE backend?    

Talk to TechFerry if you need help with performance gains through 'NodeJS standalone' or 'NodeJS with J2EE'.