Coder Social home page Coder Social logo

dapr-java-sdk-http-benchmark's Introduction

Benchmark for OkHttp and Java HTTP Client

This benchmark repository provides methods for benchmarking and comparing the OkHttp Client and Java HTTP Client (introduced in Java 11) in a dapr-java-sdk environment.

The DaprHttp class from the dapr-java-sdk is turned into a simplified interface. For both clients, an equal implementation of this interface has been made to get a fair comparison. Both implementations use JMH (Java Microbenchmark Harness) for benchmarking.

Both HTTP clients send their requests to an Nginx webserver that serves a static JSON response. ApacheBench (also provided in this repository) can be used to benchmark this Nginx Webserver, to get an idea of how fast the webserver can go. The result of the ApacheBench benchmark can be used as baseline measurement for the comparison of the results of the HTTP client benchmarks.

All measurements will be shown in milliseconds per operation (ms/op). Keep in mind that the results of the benchmarks depend on the environment you run the benchmarks in. That's why ApacheBench is also provided in this repository, to get a baseline measurement before running the JMH benchmark.

How to run

Prerequisites

Make sure you have the following prerequisites installed on your machine.

  • Docker for Desktop
  • Java 11 or above
  • Apache Maven 3.6.3 or above

Instructions

In order to run everything in the right way and get good measurements, you can follow the following steps:

1. Run the Nginx webserver in a Docker container

To send HTTP requests to the webserver, you first have to start the Nginx webserver that serves a static JSON response in a Docker container. You can execute the run_nginx.sh shell script in the infrastructure/nginx folder to start the webserver.

The static JSON response will be served at http://localhost:4005/employees.json

2. Run ApacheBench from a Docker container

When the Nginx webserver is running you can benchmark the webserver using ApacheBench to get a baseline measurement. To do this you can execute the run_apache_bench.sh shell script in the infrastructure/ab folder.

3. Run the JMH benchmarks for OkHttp Client and Java HTTP Client

To run the JMH benchmarks for the OkHttp Client an Java HTTP client you can execute the following command in the root of the repository

mvn clean compile exec:java

You can also run the nl.julian.benchmark.BenchMarkRunner mainClass from your IDE (IntelliJ).

4. Compare the results

After running the ApacheBench benchmark and JMH benchmarks you can compare the measurements.

Result example

ApacheBench

ApacheBench Measurements

JMH

JMH Measurements

dapr-java-sdk-http-benchmark's People

Contributors

juliandb1708 avatar managedservicesdevopsteam3 avatar

Watchers

 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.