Skip to content

Commit

Permalink
Merge pull request #40 from Unknow0/30-servlet-support-http2
Browse files Browse the repository at this point in the history
30 servlet support http2
  • Loading branch information
Unknow0 authored Jun 29, 2024
2 parents 243087b + a47867e commit 8dc3e04
Show file tree
Hide file tree
Showing 105 changed files with 4,190 additions and 2,292 deletions.
34 changes: 30 additions & 4 deletions .github/workflows/bench.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ jobs:
- name: build native image
run: native-image --install-exit-handlers --static --no-fallback -jar unknow-server-test/unknow-server-test-jar/target/server.jar server-native

- name: bench
run: java -jar unknow-server-bench/target/benchmark.jar

- uses: actions/upload-artifact@v4
if: always()
with:
name: bench
path: unknow-server-bench/target/benchmark.jar
- uses: actions/upload-artifact@v4
if: always()
with:
Expand All @@ -32,6 +35,27 @@ jobs:
server-native
unknow-server-test/*/target/*.war
bench:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/download-artifact@v4
with:
name: bench
- uses: graalvm/setup-graalvm@v1
with:
version: latest
java-version: 11
components: native-image
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: bench
run: java -jar benchmark.jar
- uses: actions/upload-artifact@v4
if: always()
with:
name: results-bench
path: bench.log

test:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -69,7 +93,7 @@ jobs:

result:
runs-on: ubuntu-latest
needs: test
needs: [test, bench]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
Expand All @@ -78,4 +102,6 @@ jobs:
path: out/
merge-multiple: true
- name: result
run: bash bench/result.sh out
run: |
cat out/bench.log
bash bench/result.sh out
4 changes: 4 additions & 0 deletions bench/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ VER=$(wget -q -O - "https://dlcdn.apache.org/tomcat/tomcat-$TOMCAT/" | grep "<a
mkdir -p tomcat
wget -O - https://dlcdn.apache.org/tomcat/tomcat-$TOMCAT/v$VER/bin/apache-tomcat-$VER.tar.gz | tar xzf - --strip-components=1 -C tomcat
rm -r tomcat/webapps/*
cp bench/server.xml tomcat/conf/

VER=$(wget -q -O - https://archive.apache.org/dist/jmeter/binaries/ | grep -Po '(?<=>apache-jmeter-).*(?=.tgz)' | sort -rV | head -1)
mkdir -p jmeter
wget -O - https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-$VER.tgz | tar xzf - --strip-components=1 -C jmeter
Expand All @@ -17,3 +19,5 @@ mkdir -p logs

# avoid going out of ephemeral port
sudo sysctl net.ipv4.tcp_tw_reuse=1

sudo apt install nghttp2-client
12 changes: 11 additions & 1 deletion bench/result.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ parse()
done < <(sort -t , -r -k 3,1n "$1" | sort -t , -k 3 -u)
}

for i in $1/*; do echo $i; time parse "$i"; done
for i in $1/*.csv; do parse "$i"; done

echo
echo 'throughput:'
Expand Down Expand Up @@ -60,3 +60,13 @@ do
for n in "${!tests[@]}"; do printf ' %10s' "${error[$s:$n]:-0}"; done
echo
done

echo
echo "Http2 result"

for s in "${!servers[@]}"
do
echo
echo "$s"
tail -n 9 "$1/$s.log"
done
10 changes: 7 additions & 3 deletions bench/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ trap '[[ "$pid" ]] && kill -9 $pid' EXIT

${1}_start
sleep 10
echo "Warming up"
echo -e "\nWarming up"
$JMETER -n -t bench/test.jmx -Jhost=127.0.0.1 -Jt=20 -Jport=8080 -Jout=/dev/null
sleep 10
echo "Testing.."
$JMETER -n -t bench/test.jmx -Jhost=127.0.0.1 -Jt=60 -Jport=8080 -Jout=out/$1.csv
echo -e "\nTesting.."
$JMETER -n -t bench/test.jmx -Jhost=127.0.0.1 -Jt=60 -Jc=10 -Jport=8080 -Jout=out/$1.csv

echo -e "\n launch http2 bench"
h2load -c 10 -t 10 -m 10 -D 60 --warm-up-time=10 http://127.0.0.1:8080/test > out/$1.log

${1}_stop
sleep 10
53 changes: 53 additions & 0 deletions bench/server.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?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 : HTTP Connector: /docs/config/http.html AJP Connector: /docs/config/ajp.html Define a non-SSL/TLS HTTP/1.1 Connector on port 8080 -->
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" maxParameterCount="1000">
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
</Connector>
<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" unpackWARs="true" autoDeploy="true">

<!-- 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>
Loading

0 comments on commit 8dc3e04

Please sign in to comment.