Skip to content

Commit

Permalink
Merge pull request #40 from vpa1977/add-benchmark
Browse files Browse the repository at this point in the history
Add spring boot acmeair benchmark application
  • Loading branch information
vpa1977 authored Feb 24, 2023
2 parents 7880732 + d0e0789 commit bbbc7c3
Show file tree
Hide file tree
Showing 14 changed files with 445 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
pdfbox-2.0.27
?
sh
*.war
*.jar
34 changes: 34 additions & 0 deletions benchmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Acme Air Sample and Benchmark (monolithic simple spring boot version)

This application shows an implementation of a fictitious airline called "Acme Air". The application was built with some key business requirements: the ability to scale to billions of web API calls per day, and the need to develop and deploy the application targeting multiple cloud platforms (including Public, Private and hybrid). The application can be deployed both on-prem as well as on Cloud platforms.

This version of acmeair supports deployment to:
- WebSphere Liberty Profile to Mongodb
- Apache Tomcat

# Building & Running

Run `./build.sh` to clone and build acmeair project.

## Official Docker Images

Run `docker-compose -f docker-compose.liberty.yml up` to bring up WebSphere liberty.
Run `docker-compose -f docker-compose.tomcat.yml up` to bring up Tomcat.

Wait for the application startup and navigate to http://localhost:9080/ to explore the application.

## Chiselled Docker Images

Run `docker-compose -f docker-compose.cliberty.yml up` to bring up chiselled WebSphere liberty.
Run `docker-compose -f docker-compose.ctomcat.yml up` to bring up Tomcat.

Wait for the application startup and navigate to http://localhost:9080/ to explore the application.


# Running Benchmarks

Run `(cd ./acmeair-monolithic-java/jmeter/ && ./build.sh)` to prepare the environment.

Start the application and load the database by navigating to http://localhost:9080/rest/info/loader/load?numCustomers=10000.

Running test in GUI: `(cd ./acmeair-monolithic-java/jmeter/ && ./apache-jmeter-5.5/bin/jmeter.sh -DusePureIDs=true )`
29 changes: 29 additions & 0 deletions benchmark/acmeair-cliberty/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ARG BASE_IMAGE=ubuntu/chiselled-jre:8_edge
ARG LIBERTY_IMAGE=acmeair-liberty
FROM $LIBERTY_IMAGE as builder
FROM $BASE_IMAGE

USER 1001:0

COPY --from=builder /opt/ibm/fixes /opt/ibm/fixes
COPY --from=builder /opt/ibm/wlp /opt/ibm/wlp

# liberty launcher support
COPY --from=builder /bin/grep /usr/bin/
COPY --from=builder /usr/bin/tr /usr/bin/
COPY --from=builder /bin/cat /usr/bin/
COPY --from=builder /bin/uname /usr/bin/
COPY --from=builder /usr/bin/dirname /usr/bin/
COPY --from=builder /bin/readlink /usr/bin/
COPY --from=builder /bin/sed /usr/bin/
COPY --from=builder /lib/x86_64-linux-gnu/libacl.so.1 /lib/x86_64-linux-gnu/
COPY --from=builder /usr/bin/basename /usr/bin/
COPY --from=builder /bin/chmod /usr/bin/
COPY --from=builder /bin/sh /bin/sh
COPY --from=builder /bin/mkdir /usr/bin

ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre

WORKDIR /

ENTRYPOINT ["/opt/ibm/wlp/bin/server", "run", "defaultServer"]
38 changes: 38 additions & 0 deletions benchmark/acmeair-ctomcat/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
ARG BASE_IMAGE=ubuntu/chiselled-jre:8_edge
ARG TOMCAT_IMAGE=acmeair-tomcat
FROM $TOMCAT_IMAGE as builder
FROM $BASE_IMAGE

COPY --chown=$UID:$GID --from=builder \
/usr/local/tomcat /usr/local/tomcat

# launcher support
COPY --from=builder /bin/sh /bin/sh
COPY --from=builder /usr/bin/chmod /usr/bin/chmod
COPY --from=builder /usr/bin/uname /usr/bin/uname
COPY --from=builder /usr/bin/dirname /usr/bin/dirname

# tomcat native support
#(openssl)
COPY --from=builder /usr/lib/x86_64-linux-gnu/engines-3/*.so /usr/lib/x86_64-linux-gnu/engines-3/
COPY --from=builder /usr/lib/x86_64-linux-gnu/libcrypto.so.3 /usr/lib/x86_64-linux-gnu/libcrypto.so.3
COPY --from=builder /usr/lib/x86_64-linux-gnu/libssl.so.3 /usr/lib/x86_64-linux-gnu/libssl.so.3
COPY --from=builder /usr/lib/x86_64-linux-gnu/ossl-modules/* /usr/lib/x86_64-linux-gnu/ossl-modules/
# libapr
COPY --from=builder /usr/lib/x86_64-linux-gnu/libapr-1.so.0 /usr/lib/x86_64-linux-gnu/libapr-1.so.0
COPY --from=builder /usr/lib/x86_64-linux-gnu/libuuid.so.1 /usr/lib/x86_64-linux-gnu/libuuid.so.1

# add default logging properties
COPY --from=builder /opt/java/openjdk/lib/logging.properties /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/

ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre

ENV CATALINA_HOME=/usr/local/tomcat
ENV PATH=$CATALINA_HOME/bin:$PATH
WORKDIR $CATALINA_HOME

ENV TOMCAT_NATIVE_LIBDIR=$CATALINA_HOME/native-jni-lib
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$TOMCAT_NATIVE_LIBDIR

ENTRYPOINT [ "/bin/sh" ]
CMD [ "/usr/local/tomcat/bin/catalina.sh", "run" ]
10 changes: 10 additions & 0 deletions benchmark/acmeair-liberty/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM websphere-liberty:23.0.0.1-full-java8-ibmjava

COPY --chown=1001:0 config/server.xml /opt/ibm/wlp/usr/servers/defaultServer/server.xml

RUN installUtility install defaultServer

COPY --chown=1001:0 config/jvm.options /opt/ibm/wlp/usr/servers/defaultServer/jvm.options
COPY --chown=1001:0 acmeair-java-2.0.0-SNAPSHOT.jar /opt/ibm/wlp/usr/servers/defaultServer/apps/

CMD ["/opt/ibm/wlp/bin/server", "run", "defaultServer"]
1 change: 1 addition & 0 deletions benchmark/acmeair-liberty/config/jvm.options
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Xmx2048M
24 changes: 24 additions & 0 deletions benchmark/acmeair-liberty/config/server.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">
<featureManager>
<feature>springBoot-2.0</feature>
<feature>servlet-4.0</feature>
</featureManager>
<basicRegistry id="basic">
<user name="admin" password="adminpwd" />
<user name="reader" password="readerpwd" />
</basicRegistry>
<administrator-role>
<user>admin</user>
</administrator-role>
<reader-role>
<user>reader</user>
</reader-role>
<keyStore id="defaultKeyStore" password="Liberty" />
<httpEndpoint id="defaultHttpEndpoint"
host="*"
httpPort="9080"
httpsPort="9443" />

<springBootApplication location="acmeair-java-2.0.0-SNAPSHOT.jar" contextRoot="/"/>
</server>
4 changes: 4 additions & 0 deletions benchmark/acmeair-tomcat/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM tomcat:9.0.71-jre8-temurin-jammy

ADD config/server.xml /usr/local/tomcat/conf/server.xml
ADD acmeair-java-2.0.0-SNAPSHOT.war /usr/local/tomcat/webapps
174 changes: 174 additions & 0 deletions benchmark/acmeair-tomcat/config/server.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
-->
<!-- APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>

<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">

<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->


<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443
This connector uses the NIO implementation. The default
SSLImplementation will depend on the presence of the APR/native
library and the useOpenSSL attribute of the AprLifecycleListener.
Either JSSE or OpenSSL style configuration may be used regardless of
the SSLImplementation selected. JSSE style configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true">
<SSLHostConfig>
<Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
type="RSA" />
</SSLHostConfig>
</Connector>
-->
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
This connector uses the APR/native implementation which always uses
OpenSSL for TLS.
Either JSSE or OpenSSL style configuration may be used. OpenSSL style
configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
maxThreads="150" SSLEnabled="true" >
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
<SSLHostConfig>
<Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
certificateFile="conf/localhost-rsa-cert.pem"
certificateChainFile="conf/localhost-rsa-chain.pem"
type="RSA" />
</SSLHostConfig>
</Connector>
-->

<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector protocol="AJP/1.3"
address="::1"
port="8009"
redirectPort="8443" />
-->

<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->

<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">

<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->

<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>

<Host name="localhost" appBase="webapps"
deployOnStartup="false"
unpackWARs="false"
autoDeploy="false"
createDirs="false">
<Context path="" docBase="acmeair-java-2.0.0-SNAPSHOT"/>

<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->

<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b" />

</Host>
</Engine>
</Service>
</Server>
22 changes: 22 additions & 0 deletions benchmark/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
PROJECT=acmeair-monolithic-java
TAG=chiselled-demo
ACMEAIR_REPO=https://github.com/vpa1977/${PROJECT}

git clone --branch ${TAG} ${ACMEAIR_REPO} || \
(cd ${PROJECT} && \
git checkout ${TAG})

pushd ${PROJECT}

mvn clean package -Pexternal-tomcat
cp target/acmeair-java-2.0.0-SNAPSHOT.war ../acmeair-tomcat/
mvn -DskipTests=true package -Pexternal-liberty
cp target/acmeair-java-2.0.0-SNAPSHOT.jar ../acmeair-liberty/

popd

docker build -t acmeair-liberty acmeair-liberty
docker build -t acmeair-cliberty acmeair-cliberty
docker build -t acmeair-tomcat acmeair-tomcat
docker build -t acmeair-ctomcat acmeair-ctomcat
26 changes: 26 additions & 0 deletions benchmark/docker-compose.cliberty.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '3'
services:
acmeair-db:
container_name: acmeair-db
image: mongo
ports:
- "27017:27017"
networks:
- acme

liberty:
container_name: acmeair-cliberty
image: acmeair-cliberty
networks:
- acme
ports:
- "9080:9080"
- "9443:9443"
- "7777:7777"
environment:
- MONGO_HOST=acmeair-db
tmpfs:
- /tmp
networks:
acme:
driver: bridge
Loading

0 comments on commit bbbc7c3

Please sign in to comment.