This application demonstrates the use of Blobs that can be used to store and read a blob created by it to and from a storage area respectively.
In this example, the client sends a request to the server which then sends the response back to it. Both the request and response are saved as a blob at the client side to a local file storage at a path given in the configuration.
The client runs on port 9091 and the server on 9090.
-
Build the application using
mvn clean package
-
Post build use the following commands to:
-
Run the client on localhost:9091
java -jar target/blobExample-service-1.0-SNAPSHOT.jar sampleClient
-
Run the server on localhost:9090
java -jar target/blobExample-service-1.0-SNAPSHOT.jar sampleServer
-
Send a request:
curl http://localhost:9091/displayMessage
You will know that the app is working fine if you get the correct json response like:
{ "clientMessage": "Hello ServerResource. I am ClientResource!", "serverResponse": { "serverName": "ServerResource", "message": "Hi ClientResource! I am ServerResource!" } }
-
To enable the recording of the blobs, set enabled
to true in config-client.yaml
, run the client and server again and hit the above URL.
You will be able to find the blobs created inside blobsRelativePath
set in the same config file.
Defaults:
areBlobsEnabled: true
blobsRelativePath: ./blobs
The tool used to benchmark the library is JMH.
Build docker image in local:
docker build -t blobs:blobs-example .
Run docker image
docker run --name blobsExample -v <Source>:/app/bin/blobs_home/JMH-BenchmarkingResults --cpus <Cores> -m <Memory> <IMAGE_ID>
Where,
Source=Full path of the directory you want to save the JMH benchmark run result to.
Cores=Number of CPU cores you want to allocate to the container. Example: 3.0, 5.5, 4.
IMAGE_ID=Docker IMAGE ID which can be found out by running `docker images` in CMD and then looking for `blobs` Repository.
Memory=Container RAM. Example: 8192m.
Look for the json
file created in the Source
which will contain the results for the benchmark run.
Use JMH-Visualizer(Online Version) to present the benchmark results.
The benchmarking was done for 3 different parameters with the blobs library added to the application to store the blobs in local storage and without storing any blob.
The benchmarking was performed with following parameters:
- CPU: 4
- RAM: 8GB
- Warm-ups: 10
- Iterations: 15
- Environment: MacOS