Git Product home page Git Product logo

javavsnode's Introduction

JavaVsNode

This is a project that is designed to analyze the efficiency of both Java and JavaScript when processing a large number of requests. This is supporting code for my blog post Performance Comparison: Java vs Node. In my blog post I provide runtime results of this implementation as well as the justification for the implementation choices that I made. In short, I chose to simulate blocking IO for the Java implementation. Some may argue that using blocking IO isn’t a fair comparison of Java’s performance, but here is why I think it is both accurate and fair. First, Java’s JDBC spec remains a blocking spec. That means that whenever anyone connects to a relational database using a standard JDBC driver, they have to block. Secondly, Apache Tomcat 8.5 finished implementing the first non-blocking servlet spec only seven months ago in June of 2016, so that means that the overwhelming majority of production Java applications still block when they do IO. So since Java is being used in a blocking way currently by most organizations, I feel it is the most representative of the Java to block in these simulations as well.

Open project from pom.xml file in the Java IDE of choice

Java

Open src/main/java/RequestLoadSimulator.java

Setup your simulation by setting the following constants at top of RequestLoadSimulator to the values desired for your test.

NUMBER_OF_REQUESTS - The number of requests that will be processed by the simulator. THREAD_POOL_SIZE - The size of the pool that will be used to process the requests. AVG_QUERIES_PER_REQUEST - The number of times the simulator will block per simulated request. AVG_QUERY_TIME_MILLIS - The number of times the simulator will block per simulated request. NTH_PRIME_TO_FIND - the computational load that will be processed on each request. Increase this to make the computation more difficult. 1500 is about 77 millis worth of work. PATH_TO_TEST_FILE - point the code to a file that you want it to load and process on each request. The bigger the file, the more the IO and the more CPU will be used to process it.

Run src/main/java/RequestLoadSimulator.java

Node

Open src/main/js/RequestLoadSimulator.js

Setup your simulation by setting the following constants at top of RequestLoadSimulator to the values desired for your test.

NUMBER_OF_REQUESTS - The number of requests that will be processed by the simulator. NUMBER_OF_PROCESSES - The number of Node processes that will be used to process your request. Defaults to the number of CPUs detected. AVG_QUERIES_PER_REQUEST - The number of times the simulator will block per simulated request. AVG_QUERY_TIME_MILLIS - The number of times the simulator will block per simulated request. NTH_PRIME_TO_FIND - the computational load that will be processed on each request. Increase this to make the computation more difficult. 1500 is about 77 millis worth of work. PATH_TO_TEST_FILE - point the code to a file that you want it to load and process on each request. The bigger the file, the more the IO and the more CPU will be used to process it.

Run src/main/js/RequestLoadSimulator.js

javavsnode's People

Contributors

johnrjenson avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.