update
diff --git a/README.md b/README.md
index 91b601e..b91ade0 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,35 @@
-# dubbo-benchmark
\ No newline at end of file
+# Dubbo Benchmark
+
+This project focuses on benchmarking and profiling dubbo framework with the combination of different serialization and transporter options. The code and the idea behinds it is inspired by [RPC Benchmark](https://github.com/hank-whu/rpc-benchmark).
+
+## How To Run Benchmark
+
+Clone this project onto your desktop, then
+
+* Start the target server first, for example:
+```bash
+./benchmark.sh dubbo-kryo-server
+```
+
+* Start the corresponding client, for example:
+```bash
+./benchmark.sh dubbo-kryo-client
+```
+
+## How to Run Profiling
+
+* Start the target server in profiling mode, for example:
+```bash
+./benchmark.sh -m profiling dubbo-kryo-server
+```
+
+* Start the corresponding client, for example:
+```bash
+./benchmark.sh dubbo-kryo-client
+```
+
+## Specify hostname and port for service
+
+```bash
+./benchmark.sh -s [hostname|ip address] -p port
+```
\ No newline at end of file
diff --git a/benchmark.sh b/benchmark.sh
index 1959c92..90c9fe4 100755
--- a/benchmark.sh
+++ b/benchmark.sh
@@ -1,39 +1,29 @@
#!/usr/bin/env bash
-PROGRAM_NAME=$0
-TASK=$1
-PROFILE=$2
-
-if [ ! -d "${TASK}" ]; then
- usage
-fi
-
usage() {
- echo "Usage: ${PROGRAM_NAME} directory-name {profiling|benchmark}"
- echo "run in benchmark mode by default if mode is not specified."
- exit 2
+ echo "Usage: ${PROGRAM_NAME} -m {profiling|benchmark} -s hostname -p port dirname"
}
build() {
- mvn clean package
+ mvn -Dserver.host=${SERVER} -Dserver.port=${PORT} --projects benchmark-base,${PROJECT_DIR} clean package
}
-options() {
+java_options() {
JAVA_OPTIONS="-server -Xmx1g -Xms1g -XX:MaxDirectMemorySize=1g -XX:+UseG1GC"
- if [ "x${PROFILE}" = "xprofiling" ]; then
+ if [ "x${MODE}" = "xprofiling" ]; then
JAVA_OPTIONS="${JAVA_OPTIONS} \
-XX:+UnlockCommercialFeatures \
-XX:+FlightRecorder \
--XX:StartFlightRecording=duration=30s,filename=${TASK}.jfr \
+-XX:StartFlightRecording=duration=30s,filename=${PROJECT_DIR}.jfr \
-XX:FlightRecorderOptions=stackdepth=256"
fi
}
run() {
- if [ -d "${TASK}/target" ]; then
- JAR=`find ${TASK}/target/*.jar | head -n 1`
+ if [ -d "${PROJECT_DIR}/target" ]; then
+ JAR=`find ${PROJECT_DIR}/target/*.jar | head -n 1`
echo
- echo "RUN ${TASK} IN ${PROFILE:-benchmark} MODE"
+ echo "RUN ${PROJECT_DIR} IN ${MODE:-benchmark} MODE"
CMD="java ${JAVA_OPTIONS} -jar ${JAR}"
echo "command is: ${CMD}"
echo
@@ -41,8 +31,40 @@
fi
}
+PROGRAM_NAME=$0
+MODE="benchmark"
+SERVER="localhost"
+PORT="8080"
+OPTIND=1
+
+while getopts "h?m:s:p:" opt; do
+ case "$opt" in
+ h|\?)
+ usage
+ exit 0
+ ;;
+ m)
+ MODE=${OPTARG}
+ ;;
+ s)
+ SERVER=${OPTARG}
+ ;;
+ p)
+ PORT=${OPTARG}
+ ;;
+ esac
+done
+
+shift $((OPTIND-1))
+PROJECT_DIR=$1
+
+if [ ! -d "${PROJECT_DIR}" ]; then
+ usage
+ exit 0
+fi
+
build
-options
+java_options
run
diff --git a/dubbo-hessianlite-client/pom.xml b/dubbo-hessianlite-client/pom.xml
index 36640db..fd24a64 100644
--- a/dubbo-hessianlite-client/pom.xml
+++ b/dubbo-hessianlite-client/pom.xml
@@ -11,5 +11,63 @@
<artifactId>dubbo-hessianlite-client</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>benchmark-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openjdk.jmh</groupId>
+ <artifactId>jmh-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openjdk.jmh</groupId>
+ <artifactId>jmh-generator-annprocess</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.1.0</version>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>
+ ${project.build.directory}/libs
+ </outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.1.0</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>libs/</classpathPrefix>
+ <mainClass>org.apache.dubbo.benchmark.Client</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
</project>
\ No newline at end of file
diff --git a/dubbo-hessianlite-client/src/main/resources/consumer.xml b/dubbo-hessianlite-client/src/main/resources/consumer.xml
index 22c89f9..e036f94 100644
--- a/dubbo-hessianlite-client/src/main/resources/consumer.xml
+++ b/dubbo-hessianlite-client/src/main/resources/consumer.xml
@@ -1,10 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
- <dubbo:application name="dubbo-client-kyro"/>
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
+ <context:property-placeholder location="classpath:benchmark.properties" system-properties-mode="OVERRIDE"/>
+ <dubbo:application name="dubbo-hessianlite-client"/>
<dubbo:reference id="userService" check="false"
interface="org.apache.dubbo.benchmark.service.UserService"
- url="dubbo://localhost:8080?optimizer=org.apache.dubbo.benchmark.serialize.SerializationOptimizerImpl&serialization=kryo"/>
+ url="dubbo://${server.host}:${server.port}"/>
<dubbo:consumer client="netty4" filter="-default"/>
</beans>
\ No newline at end of file
diff --git a/dubbo-hessianlite-client/src/main/resources/logback.xml b/dubbo-hessianlite-client/src/main/resources/logback.xml
index cb8c9fd..cf75589 100644
--- a/dubbo-hessianlite-client/src/main/resources/logback.xml
+++ b/dubbo-hessianlite-client/src/main/resources/logback.xml
@@ -10,19 +10,17 @@
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>logs/dubbo-kyro-client.log</file>
+ <file>logs/dubbo-hessianlite-client.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>logs/benchmark-rpc-client.%d{yyyy-MM-dd}.log.gz</fileNamePattern>
+ <fileNamePattern>logs/dubbo-hessianlite-client.%d{yyyy-MM-dd}.log.gz</fileNamePattern>
</rollingPolicy>
<encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n </pattern>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
- <logger name="benchmark.rpc" level="INFO"/>
-
<root level="INFO">
- <appender-ref ref="CONSOLE" />
+ <appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
</configuration>
diff --git a/dubbo-hessianlite-server/pom.xml b/dubbo-hessianlite-server/pom.xml
index 7b095f2..3cf144a 100644
--- a/dubbo-hessianlite-server/pom.xml
+++ b/dubbo-hessianlite-server/pom.xml
@@ -11,5 +11,80 @@
<artifactId>dubbo-hessianlite-server</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>benchmark-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openjdk.jmh</groupId>
+ <artifactId>jmh-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openjdk.jmh</groupId>
+ <artifactId>jmh-generator-annprocess</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.1.0</version>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>
+ ${project.build.directory}/libs
+ </outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.1.0</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>libs/</classpathPrefix>
+ <mainClass>org.apache.dubbo.benchmark.Server</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
diff --git a/dubbo-hessianlite-server/src/main/resources/logback.xml b/dubbo-hessianlite-server/src/main/resources/logback.xml
index 6b20820..033bde0 100644
--- a/dubbo-hessianlite-server/src/main/resources/logback.xml
+++ b/dubbo-hessianlite-server/src/main/resources/logback.xml
@@ -10,9 +10,9 @@
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>logs/dubbo-kryo-server.log</file>
+ <file>logs/dubbo-hessianlite-server.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>logs/dubbo-kryo-server.%d{yyyy-MM-dd}.log.gz</fileNamePattern>
+ <fileNamePattern>logs/dubbo-hessianlite-server.%d{yyyy-MM-dd}.log.gz</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
diff --git a/dubbo-hessianlite-server/src/main/resources/provider.xml b/dubbo-hessianlite-server/src/main/resources/provider.xml
index c0ba8cd..937ecf5 100644
--- a/dubbo-hessianlite-server/src/main/resources/provider.xml
+++ b/dubbo-hessianlite-server/src/main/resources/provider.xml
@@ -4,9 +4,8 @@
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:property-placeholder location="classpath:benchmark.properties" system-properties-mode="OVERRIDE"/>
- <dubbo:application name="dubbo-kryo-server"/>
- <dubbo:protocol name="dubbo" host="${server.host}" server="netty4" port="${server.port}" serialization="kryo"
- optimizer="org.apache.dubbo.benchmark.serialize.SerializationOptimizerImpl"/>
+ <dubbo:application name="dubbo-hessianlite-server"/>
+ <dubbo:protocol name="dubbo" host="${server.host}" server="netty4" port="${server.port}"/>
<dubbo:registry address="N/A"/>
<dubbo:service interface="org.apache.dubbo.benchmark.service.UserService" ref="userService" filter="-default"/>
<bean id="userService" class="org.apache.dubbo.benchmark.service.UserServiceServerImpl"/>
diff --git a/dubbo-kryo-client/pom.xml b/dubbo-kryo-client/pom.xml
index eeee860..d79c37f 100644
--- a/dubbo-kryo-client/pom.xml
+++ b/dubbo-kryo-client/pom.xml
@@ -19,11 +19,6 @@
</dependency>
<dependency>
- <groupId>com.esotericsoftware</groupId>
- <artifactId>kryo</artifactId>
- </dependency>
-
- <dependency>
<groupId>de.javakaffee</groupId>
<artifactId>kryo-serializers</artifactId>
</dependency>
@@ -49,6 +44,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
+ <version>3.1.0</version>
<executions>
<execution>
<id>copy-dependencies</id>
@@ -68,6 +64,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
+ <version>3.1.0</version>
<configuration>
<archive>
<manifest>
diff --git a/dubbo-kryo-client/src/main/resources/consumer.xml b/dubbo-kryo-client/src/main/resources/consumer.xml
index 22c89f9..e87fbda 100644
--- a/dubbo-kryo-client/src/main/resources/consumer.xml
+++ b/dubbo-kryo-client/src/main/resources/consumer.xml
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
- <dubbo:application name="dubbo-client-kyro"/>
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
+ <context:property-placeholder location="classpath:benchmark.properties" system-properties-mode="OVERRIDE"/>
+ <dubbo:application name="dubbo-kyro-client"/>
<dubbo:reference id="userService" check="false"
interface="org.apache.dubbo.benchmark.service.UserService"
url="dubbo://localhost:8080?optimizer=org.apache.dubbo.benchmark.serialize.SerializationOptimizerImpl&serialization=kryo"/>
diff --git a/dubbo-kryo-client/src/main/resources/logback.xml b/dubbo-kryo-client/src/main/resources/logback.xml
index cb8c9fd..359128e 100644
--- a/dubbo-kryo-client/src/main/resources/logback.xml
+++ b/dubbo-kryo-client/src/main/resources/logback.xml
@@ -12,15 +12,13 @@
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/dubbo-kyro-client.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>logs/benchmark-rpc-client.%d{yyyy-MM-dd}.log.gz</fileNamePattern>
+ <fileNamePattern>logs/dubbo-kryo-client.%d{yyyy-MM-dd}.log.gz</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n </pattern>
</encoder>
</appender>
- <logger name="benchmark.rpc" level="INFO"/>
-
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE"/>
diff --git a/dubbo-kryo-server/pom.xml b/dubbo-kryo-server/pom.xml
index 4d5f6bd..44415ee 100644
--- a/dubbo-kryo-server/pom.xml
+++ b/dubbo-kryo-server/pom.xml
@@ -65,6 +65,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
+ <version>3.1.0</version>
<executions>
<execution>
<id>copy-dependencies</id>
@@ -84,6 +85,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
+ <version>3.1.0</version>
<configuration>
<archive>
<manifest>
diff --git a/dubbo-kryo-server/src/main/resources/logback.xml b/dubbo-kryo-server/src/main/resources/logback.xml
index 3ba87e6..6b20820 100644
--- a/dubbo-kryo-server/src/main/resources/logback.xml
+++ b/dubbo-kryo-server/src/main/resources/logback.xml
@@ -12,17 +12,15 @@
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/dubbo-kryo-server.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>logs/benchmark-rpc-client.%d{yyyy-MM-dd}.log.gz</fileNamePattern>
+ <fileNamePattern>logs/dubbo-kryo-server.%d{yyyy-MM-dd}.log.gz</fileNamePattern>
</rollingPolicy>
<encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n </pattern>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
- <logger name="benchmark.rpc" level="INFO"/>
-
<root level="INFO">
- <appender-ref ref="CONSOLE" />
+ <appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
</configuration>
diff --git a/dubbo-kryo-server/src/main/resources/provider.xml b/dubbo-kryo-server/src/main/resources/provider.xml
index 3666e87..c0ba8cd 100644
--- a/dubbo-kryo-server/src/main/resources/provider.xml
+++ b/dubbo-kryo-server/src/main/resources/provider.xml
@@ -4,7 +4,7 @@
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:property-placeholder location="classpath:benchmark.properties" system-properties-mode="OVERRIDE"/>
- <dubbo:application name="dubbo-server-kryo" />
+ <dubbo:application name="dubbo-kryo-server"/>
<dubbo:protocol name="dubbo" host="${server.host}" server="netty4" port="${server.port}" serialization="kryo"
optimizer="org.apache.dubbo.benchmark.serialize.SerializationOptimizerImpl"/>
<dubbo:registry address="N/A"/>
diff --git a/pom.xml b/pom.xml
index 20bea57..4f37b2d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,6 +26,8 @@
<module>benchmark-base</module>
<module>dubbo-kryo-client</module>
<module>dubbo-kryo-server</module>
+ <module>dubbo-hessianlite-client</module>
+ <module>dubbo-hessianlite-server</module>
</modules>
<dependencies>