Skip to content
Permalink
Browse files
update
  • Loading branch information
beiwei30 committed May 21, 2018
1 parent 62ce23b commit 5077901640b680dda08e0d4f799d48f5b23ee091
Showing 15 changed files with 237 additions and 50 deletions.
@@ -1 +1,35 @@
# dubbo-benchmark
# 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
```
@@ -1,48 +1,70 @@
#!/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
${CMD}
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


@@ -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>
@@ -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&amp;serialization=kryo"/>
url="dubbo://${server.host}:${server.port}"/>
<dubbo:consumer client="netty4" filter="-default"/>
</beans>
@@ -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>
@@ -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>
@@ -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>
@@ -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"/>
@@ -18,11 +18,6 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
</dependency>

<dependency>
<groupId>de.javakaffee</groupId>
<artifactId>kryo-serializers</artifactId>
@@ -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>
@@ -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&amp;serialization=kryo"/>
@@ -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"/>

0 comments on commit 5077901

Please sign in to comment.