You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by zh...@apache.org on 2019/07/09 13:59:06 UTC

[servicecomb-pack] branch SCB-1321 updated (e09f01f -> 1c3e389)

This is an automated email from the ASF dual-hosted git repository.

zhanglei pushed a change to branch SCB-1321
in repository https://gitbox.apache.org/repos/asf/servicecomb-pack.git.


    from e09f01f  SCB-1321 Update README.md for Saga State Machine Module
     new 7392ae3  SCB-1321 Add alpha benchmark tools
     new 1c3e389  SCB-1321 Add benchmark report

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../alpha-benchmark}/pom.xml                       |  50 +++---
 .../pack/alpha/benchmark/Application.java          |  97 +++++++++++
 .../pack/alpha/benchmark/BenchmarkMetrics.java     | 102 ++++++++++++
 .../pack/alpha/benchmark/SagaEventBenchmark.java   | 170 +++++++++++++++++++
 .../src/main/resources/application.yaml            |  10 +-
 alpha/alpha-fsm/Benchmark.md                       | 185 +++++++++++++++++++++
 alpha/alpha-fsm/README.md                          |   2 +
 alpha/alpha-fsm/assets/cmd-0.4.0-1w-100.png        | Bin 0 -> 153094 bytes
 alpha/alpha-fsm/assets/cmd-0.4.0-1w-500.png        | Bin 0 -> 154756 bytes
 alpha/alpha-fsm/assets/cmd-0.5.0-1w-100.png        | Bin 0 -> 151211 bytes
 alpha/alpha-fsm/assets/cmd-0.5.0-1w-1000.png       | Bin 0 -> 152949 bytes
 alpha/alpha-fsm/assets/cmd-0.5.0-1w-2000.png       | Bin 0 -> 156713 bytes
 alpha/alpha-fsm/assets/cmd-0.5.0-1w-500.png        | Bin 0 -> 151538 bytes
 alpha/alpha-fsm/assets/cmd-0.5.0-5w-1000.png       | Bin 0 -> 150555 bytes
 alpha/alpha-fsm/assets/cmd-0.5.0-5w-2000.png       | Bin 0 -> 157909 bytes
 alpha/alpha-fsm/assets/cmd-0.5.0-5w-3000.png       | Bin 0 -> 162355 bytes
 alpha/alpha-fsm/assets/vm-0.4.0-1w-100.png         | Bin 0 -> 82508 bytes
 alpha/alpha-fsm/assets/vm-0.4.0-1w-500.png         | Bin 0 -> 91880 bytes
 alpha/alpha-fsm/assets/vm-0.5.0-1w-100.png         | Bin 0 -> 89345 bytes
 alpha/alpha-fsm/assets/vm-0.5.0-1w-1000.png        | Bin 0 -> 84643 bytes
 alpha/alpha-fsm/assets/vm-0.5.0-1w-2000.png        | Bin 0 -> 84967 bytes
 alpha/alpha-fsm/assets/vm-0.5.0-1w-500.png         | Bin 0 -> 78440 bytes
 alpha/alpha-fsm/assets/vm-0.5.0-5w-1000.png        | Bin 0 -> 92723 bytes
 alpha/alpha-fsm/assets/vm-0.5.0-5w-2000.png        | Bin 0 -> 86282 bytes
 alpha/alpha-fsm/assets/vm-0.5.0-5w-3000.png        | Bin 0 -> 90599 bytes
 alpha/pom.xml                                      |   1 +
 26 files changed, 589 insertions(+), 28 deletions(-)
 copy {persistence/persistence-jpa => alpha/alpha-benchmark}/pom.xml (66%)
 create mode 100644 alpha/alpha-benchmark/src/main/java/org/apache/servicecomb/pack/alpha/benchmark/Application.java
 create mode 100644 alpha/alpha-benchmark/src/main/java/org/apache/servicecomb/pack/alpha/benchmark/BenchmarkMetrics.java
 create mode 100644 alpha/alpha-benchmark/src/main/java/org/apache/servicecomb/pack/alpha/benchmark/SagaEventBenchmark.java
 copy {demo/saga-servicecomb-demo/scb-booking => alpha/alpha-benchmark}/src/main/resources/application.yaml (90%)
 create mode 100644 alpha/alpha-fsm/Benchmark.md
 create mode 100644 alpha/alpha-fsm/assets/cmd-0.4.0-1w-100.png
 create mode 100644 alpha/alpha-fsm/assets/cmd-0.4.0-1w-500.png
 create mode 100644 alpha/alpha-fsm/assets/cmd-0.5.0-1w-100.png
 create mode 100644 alpha/alpha-fsm/assets/cmd-0.5.0-1w-1000.png
 create mode 100644 alpha/alpha-fsm/assets/cmd-0.5.0-1w-2000.png
 create mode 100644 alpha/alpha-fsm/assets/cmd-0.5.0-1w-500.png
 create mode 100644 alpha/alpha-fsm/assets/cmd-0.5.0-5w-1000.png
 create mode 100644 alpha/alpha-fsm/assets/cmd-0.5.0-5w-2000.png
 create mode 100644 alpha/alpha-fsm/assets/cmd-0.5.0-5w-3000.png
 create mode 100644 alpha/alpha-fsm/assets/vm-0.4.0-1w-100.png
 create mode 100644 alpha/alpha-fsm/assets/vm-0.4.0-1w-500.png
 create mode 100644 alpha/alpha-fsm/assets/vm-0.5.0-1w-100.png
 create mode 100644 alpha/alpha-fsm/assets/vm-0.5.0-1w-1000.png
 create mode 100644 alpha/alpha-fsm/assets/vm-0.5.0-1w-2000.png
 create mode 100644 alpha/alpha-fsm/assets/vm-0.5.0-1w-500.png
 create mode 100644 alpha/alpha-fsm/assets/vm-0.5.0-5w-1000.png
 create mode 100644 alpha/alpha-fsm/assets/vm-0.5.0-5w-2000.png
 create mode 100644 alpha/alpha-fsm/assets/vm-0.5.0-5w-3000.png


[servicecomb-pack] 01/02: SCB-1321 Add alpha benchmark tools

Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zhanglei pushed a commit to branch SCB-1321
in repository https://gitbox.apache.org/repos/asf/servicecomb-pack.git

commit 7392ae3fac841e3f6af9f0fa554e3ba24fe0129d
Author: Lei Zhang <zh...@apache.org>
AuthorDate: Tue Jul 9 21:46:29 2019 +0800

    SCB-1321 Add alpha benchmark tools
---
 alpha/alpha-benchmark/pom.xml                      |  88 +++++++++++
 .../pack/alpha/benchmark/Application.java          |  97 ++++++++++++
 .../pack/alpha/benchmark/BenchmarkMetrics.java     | 102 +++++++++++++
 .../pack/alpha/benchmark/SagaEventBenchmark.java   | 170 +++++++++++++++++++++
 .../src/main/resources/application.yaml            |  28 ++++
 alpha/pom.xml                                      |   1 +
 6 files changed, 486 insertions(+)

diff --git a/alpha/alpha-benchmark/pom.xml b/alpha/alpha-benchmark/pom.xml
new file mode 100644
index 0000000..fcc3277
--- /dev/null
+++ b/alpha/alpha-benchmark/pom.xml
@@ -0,0 +1,88 @@
+<?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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>alpha</artifactId>
+    <groupId>org.apache.servicecomb.pack</groupId>
+    <version>0.5.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>alpha-benchmark</artifactId>
+  <name>Pack::Alpha::Benchmark</name>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-dependencies</artifactId>
+        <version>${spring.boot.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.pack</groupId>
+      <artifactId>alpha-fsm</artifactId>
+      <exclusions>
+        <exclusion>
+          <artifactId>log4j-slf4j-impl</artifactId>
+          <groupId>org.apache.logging.log4j</groupId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.pack</groupId>
+      <artifactId>omega-spring-starter</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.pack</groupId>
+      <artifactId>omega-connector-grpc</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.github.seanyinx</groupId>
+      <artifactId>unit-scaffolding</artifactId>
+      <scope>compile</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <!-- mixin plugin configurations declared in another pom,
+      just like importing dependencies managed in another pom -->
+      <plugin>
+        <groupId>com.github.odavid.maven.plugins</groupId>
+        <artifactId>mixin-maven-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/alpha/alpha-benchmark/src/main/java/org/apache/servicecomb/pack/alpha/benchmark/Application.java b/alpha/alpha-benchmark/src/main/java/org/apache/servicecomb/pack/alpha/benchmark/Application.java
new file mode 100644
index 0000000..0a74910
--- /dev/null
+++ b/alpha/alpha-benchmark/src/main/java/org/apache/servicecomb/pack/alpha/benchmark/Application.java
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ */
+
+package org.apache.servicecomb.pack.alpha.benchmark;
+
+import org.apache.servicecomb.pack.omega.transaction.SagaMessageSender;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class Application implements CommandLineRunner {
+
+  @Autowired
+  SagaEventBenchmark sagaEventBenchmark;
+
+  @Autowired(required = false)
+  SagaMessageSender sender;
+
+  @Value("${alpha.cluster.address}")
+  String address;
+
+  @Value("${n:0}")
+  int requests;
+
+  @Value("${c:1}")
+  int concurrency;
+
+  public static void main(String[] args) {
+    boolean hasAlphaAddress = false;
+    for(String arg : args){
+      if(arg.startsWith("--alpha.cluster.address")){
+        hasAlphaAddress = true;
+      }
+    }
+    if(!hasAlphaAddress){
+      printHelp();
+      System.exit(0);
+    }
+    SpringApplication.run(Application.class, args);
+  }
+
+  @Override
+  public void run(String... args) {
+
+    try {
+      if (checkParamter()) {
+        sagaEventBenchmark.send(requests, concurrency);
+      } else {
+        printHelp();
+      }
+    } finally {
+      sender.onDisconnected();
+      System.exit(0);
+    }
+
+  }
+
+  private boolean checkParamter() {
+    if (address == null) {
+      return false;
+    } else {
+      if (requests == 0) {
+        return false;
+      } else {
+        return true;
+      }
+    }
+  }
+
+  private static void printHelp() {
+    System.out.println("\nalpha-benchmark: wrong number of arguments");
+    System.out.println(
+        "Usage: java -jar alpha-benchmark-0.5.0-SNAPSHOT-exec.jar --alpha.cluster.address=0.0.0.0:8080 --n=1000 --c=1");
+    System.out.println("Options are:");
+    System.out.println(
+        String.format("%-5s %-15s %-25s", "  --n", "requests", "Number of requests to perform"));
+    System.out.println(String.format("%-5s %-15s %-25s", "  --c", "concurrency",
+        "Number of multiple requests to make at a time"));
+  }
+}
diff --git a/alpha/alpha-benchmark/src/main/java/org/apache/servicecomb/pack/alpha/benchmark/BenchmarkMetrics.java b/alpha/alpha-benchmark/src/main/java/org/apache/servicecomb/pack/alpha/benchmark/BenchmarkMetrics.java
new file mode 100644
index 0000000..e15a50d
--- /dev/null
+++ b/alpha/alpha-benchmark/src/main/java/org/apache/servicecomb/pack/alpha/benchmark/BenchmarkMetrics.java
@@ -0,0 +1,102 @@
+/*
+ * 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.
+ */
+
+package org.apache.servicecomb.pack.alpha.benchmark;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class BenchmarkMetrics {
+
+  private int requests;
+  private AtomicInteger completeRequests = new AtomicInteger();
+  private AtomicInteger failedRequests = new AtomicInteger();
+  private int concurrency;
+  private long timeTaken;
+  private List<Long> transactionTime = Collections.synchronizedList(new ArrayList());
+
+  private int beforeProgress;
+
+  public void setRequests(int requests) {
+    this.requests = requests;
+  }
+
+  //并发用户数
+  public int getConcurrency() {
+    return concurrency;
+  }
+
+  public void setConcurrency(int concurrency) {
+    this.concurrency = concurrency;
+  }
+
+  public void addTransactionTime(long time) {
+    transactionTime.add(time);
+  }
+
+  public long getTimeTaken() {
+    return timeTaken / 1000;
+  }
+
+  public void setTimeTaken(long timeTaken) {
+    this.timeTaken = timeTaken;
+  }
+
+  public int getCompleteRequests() {
+    return completeRequests.get();
+  }
+
+  public int getFailedRequests() {
+    return failedRequests.get();
+  }
+
+  //总请求数量
+  public void completeRequestsIncrement() {
+    completeRequests.incrementAndGet();
+    printProgress();
+  }
+
+  //失败的请求数量
+  public void failedRequestsIncrement() {
+    failedRequests.incrementAndGet();
+    printProgress();
+  }
+
+  //吞吐率
+  public long getRequestsPerSecond() {
+    return this.completeRequests.get() / (timeTaken / 1000);
+  }
+
+  //用户平均请求等待时间
+  public long getTimePerRequest() {
+    return this.timeTaken / (completeRequests.get() / concurrency);
+  }
+
+  public List<Long> getTransactionTime() {
+    return transactionTime;
+  }
+
+  private void printProgress() {
+    int progress = (int) ((float) completeRequests.get() / (float) requests * 100);
+    if (beforeProgress != progress) {
+      System.out.print("░");
+      beforeProgress = progress;
+    }
+  }
+}
diff --git a/alpha/alpha-benchmark/src/main/java/org/apache/servicecomb/pack/alpha/benchmark/SagaEventBenchmark.java b/alpha/alpha-benchmark/src/main/java/org/apache/servicecomb/pack/alpha/benchmark/SagaEventBenchmark.java
new file mode 100644
index 0000000..47e62aa
--- /dev/null
+++ b/alpha/alpha-benchmark/src/main/java/org/apache/servicecomb/pack/alpha/benchmark/SagaEventBenchmark.java
@@ -0,0 +1,170 @@
+/*
+ * 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.
+ */
+
+package org.apache.servicecomb.pack.alpha.benchmark;
+
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.OptionalDouble;
+import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+
+import org.apache.servicecomb.pack.common.EventType;
+import org.apache.servicecomb.pack.omega.transaction.SagaMessageSender;
+import org.apache.servicecomb.pack.omega.transaction.TxEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SagaEventBenchmark {
+
+  private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+  @Autowired(required = false)
+  SagaMessageSender sender;
+
+  BenchmarkMetrics metrics = new BenchmarkMetrics();
+
+  public void send(int requests, int concurrency) {
+    System.out.print("Benchmarking ");
+    metrics.setRequests(requests);
+    metrics.setConcurrency(concurrency);
+    long s = System.currentTimeMillis();
+    CountDownLatch begin = new CountDownLatch(1);
+    CountDownLatch end = new CountDownLatch(concurrency);
+    begin.countDown();
+    for (int i = 0; i < concurrency; i++) {
+      Execute execute = new Execute(sender, requests / concurrency, begin, end, metrics);
+      new Thread(execute).start();
+    }
+    try {
+      end.await();
+      long e = System.currentTimeMillis();
+      metrics.setTimeTaken(e - s);
+      System.out.println("\n");
+      System.out.println(String.format("%-25s %s", "Concurrency Level", metrics.getConcurrency()));
+      System.out.println(
+          String.format("%-25s %s", "Time taken for tests", metrics.getTimeTaken() + " seconds"));
+      System.out
+          .println(String.format("%-25s %s", "Complete requests", metrics.getCompleteRequests()));
+      System.out.println(String.format("%-25s %s", "Failed requests", metrics.getFailedRequests()));
+      System.out.println(String
+          .format("%-25s %s", "Requests per second", metrics.getRequestsPerSecond() + " [#/sec]"));
+      System.out.println(
+          String.format("%-25s %s", "Time per request", metrics.getTimePerRequest() + " [ms]"));
+      System.out.println();
+      System.out.println("Percentage of the requests served within a certain time (ms)");
+
+      int size = metrics.getTransactionTime().size();
+      int percentage = 50;
+      for (int i = 0; i <= 5; i++) {
+        float peek = size * ((float) percentage / 100);
+        System.out.println(String.format("%-5s %.2f", percentage + "%", getAverage(
+            metrics.getTransactionTime().subList(0, (int) peek)).getAsDouble()));
+        percentage = percentage + 10;
+      }
+
+    } catch (InterruptedException e) {
+      LOG.error(e.getMessage(), e);
+    }
+    LOG.info("OK");
+  }
+
+  private OptionalDouble getAverage(List<Long> times) {
+    try{
+      return times.stream().mapToLong(Long::longValue).average();
+    }catch (Exception e){
+
+      throw e;
+    }
+  }
+
+  private class Execute implements Runnable {
+
+    SagaMessageSender sender;
+    CountDownLatch begin;
+    CountDownLatch end;
+    int requests;
+
+    public Execute(SagaMessageSender sender, int requests, CountDownLatch begin,
+        CountDownLatch end, BenchmarkMetrics metrics) {
+      this.sender = sender;
+      this.requests = requests;
+      this.begin = begin;
+      this.end = end;
+    }
+
+    @Override
+    public void run() {
+      try {
+        begin.await();
+        for (int i = 0; i < requests; i++) {
+          metrics.completeRequestsIncrement();
+          long s = System.currentTimeMillis();
+          final String globalTxId = UUID.randomUUID().toString();
+          final String localTxId_1 = UUID.randomUUID().toString();
+          final String localTxId_2 = UUID.randomUUID().toString();
+          final String localTxId_3 = UUID.randomUUID().toString();
+          try {
+            sagaSuccessfulEvents(globalTxId, localTxId_1, localTxId_2, localTxId_3).stream()
+                .forEach(event -> sender.send(event));
+          } catch (Throwable e) {
+            metrics.failedRequestsIncrement();
+          }finally {
+            long e = System.currentTimeMillis();
+            metrics.addTransactionTime(e - s);
+          }
+        }
+        end.countDown();
+      } catch (InterruptedException e) {
+        LOG.error(e.getMessage(), e);
+      }
+    }
+  }
+
+  public List<TxEvent> sagaSuccessfulEvents(String globalTxId, String localTxId_1,
+      String localTxId_2, String localTxId_3) {
+    List<TxEvent> sagaEvents = new ArrayList<>();
+    sagaEvents.add(
+        new TxEvent(EventType.SagaStartedEvent, globalTxId, globalTxId, globalTxId, "", 0, null,
+            0));
+    sagaEvents.add(
+        new TxEvent(EventType.TxStartedEvent, globalTxId, localTxId_1, globalTxId, "service a", 0,
+            null, 0));
+    sagaEvents.add(
+        new TxEvent(EventType.TxEndedEvent, globalTxId, localTxId_1, globalTxId, "service a", 0,
+            null, 0));
+    sagaEvents.add(
+        new TxEvent(EventType.TxStartedEvent, globalTxId, localTxId_2, globalTxId, "service b", 0,
+            null, 0));
+    sagaEvents.add(
+        new TxEvent(EventType.TxEndedEvent, globalTxId, localTxId_2, globalTxId, "service b", 0,
+            null, 0));
+    sagaEvents.add(
+        new TxEvent(EventType.TxStartedEvent, globalTxId, localTxId_3, globalTxId, "service c", 0,
+            null, 0));
+    sagaEvents.add(
+        new TxEvent(EventType.TxEndedEvent, globalTxId, localTxId_3, globalTxId, "service c", 0,
+            null, 0));
+    sagaEvents.add(
+        new TxEvent(EventType.SagaEndedEvent, globalTxId, globalTxId, globalTxId, "", 0, null, 0));
+    return sagaEvents;
+  }
+}
diff --git a/alpha/alpha-benchmark/src/main/resources/application.yaml b/alpha/alpha-benchmark/src/main/resources/application.yaml
new file mode 100644
index 0000000..2124ca9
--- /dev/null
+++ b/alpha/alpha-benchmark/src/main/resources/application.yaml
@@ -0,0 +1,28 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+spring:
+  main:
+    banner-mode: "off"
+  application:
+    name: alpha-benchmark
+
+alpha:
+  cluster:
+    address: localhost:8080
+
+omega:
+  enabled: true
\ No newline at end of file
diff --git a/alpha/pom.xml b/alpha/pom.xml
index 3dfaf13..18ab23e 100644
--- a/alpha/pom.xml
+++ b/alpha/pom.xml
@@ -33,6 +33,7 @@
   <modules>
     <module>alpha-core</module>
     <module>alpha-fsm</module>
+    <module>alpha-benchmark</module>
     <module>alpha-spring-boot-compatibility</module>
     <module>alpha-spring-cloud-starter-eureka</module>
     <module>alpha-spring-cloud-starter-consul</module>


[servicecomb-pack] 02/02: SCB-1321 Add benchmark report

Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zhanglei pushed a commit to branch SCB-1321
in repository https://gitbox.apache.org/repos/asf/servicecomb-pack.git

commit 1c3e389cace9b9c4750e1f8a5983818f1ab30441
Author: Lei Zhang <zh...@apache.org>
AuthorDate: Tue Jul 9 21:48:22 2019 +0800

    SCB-1321 Add benchmark report
---
 alpha/alpha-fsm/Benchmark.md                 | 185 +++++++++++++++++++++++++++
 alpha/alpha-fsm/README.md                    |   2 +
 alpha/alpha-fsm/assets/cmd-0.4.0-1w-100.png  | Bin 0 -> 153094 bytes
 alpha/alpha-fsm/assets/cmd-0.4.0-1w-500.png  | Bin 0 -> 154756 bytes
 alpha/alpha-fsm/assets/cmd-0.5.0-1w-100.png  | Bin 0 -> 151211 bytes
 alpha/alpha-fsm/assets/cmd-0.5.0-1w-1000.png | Bin 0 -> 152949 bytes
 alpha/alpha-fsm/assets/cmd-0.5.0-1w-2000.png | Bin 0 -> 156713 bytes
 alpha/alpha-fsm/assets/cmd-0.5.0-1w-500.png  | Bin 0 -> 151538 bytes
 alpha/alpha-fsm/assets/cmd-0.5.0-5w-1000.png | Bin 0 -> 150555 bytes
 alpha/alpha-fsm/assets/cmd-0.5.0-5w-2000.png | Bin 0 -> 157909 bytes
 alpha/alpha-fsm/assets/cmd-0.5.0-5w-3000.png | Bin 0 -> 162355 bytes
 alpha/alpha-fsm/assets/vm-0.4.0-1w-100.png   | Bin 0 -> 82508 bytes
 alpha/alpha-fsm/assets/vm-0.4.0-1w-500.png   | Bin 0 -> 91880 bytes
 alpha/alpha-fsm/assets/vm-0.5.0-1w-100.png   | Bin 0 -> 89345 bytes
 alpha/alpha-fsm/assets/vm-0.5.0-1w-1000.png  | Bin 0 -> 84643 bytes
 alpha/alpha-fsm/assets/vm-0.5.0-1w-2000.png  | Bin 0 -> 84967 bytes
 alpha/alpha-fsm/assets/vm-0.5.0-1w-500.png   | Bin 0 -> 78440 bytes
 alpha/alpha-fsm/assets/vm-0.5.0-5w-1000.png  | Bin 0 -> 92723 bytes
 alpha/alpha-fsm/assets/vm-0.5.0-5w-2000.png  | Bin 0 -> 86282 bytes
 alpha/alpha-fsm/assets/vm-0.5.0-5w-3000.png  | Bin 0 -> 90599 bytes
 20 files changed, 187 insertions(+)

diff --git a/alpha/alpha-fsm/Benchmark.md b/alpha/alpha-fsm/Benchmark.md
new file mode 100644
index 0000000..019fb77
--- /dev/null
+++ b/alpha/alpha-fsm/Benchmark.md
@@ -0,0 +1,185 @@
+# Benchmark for Alpha
+
+基准测试使用 alpha-benchmark 工具模拟发送事务,模拟器和Alpha分别部署在两个不同的服务器
+
+## 配置
+
+### 物理服务器配置
+
+| 名称     | 描述                                                        |
+| -------- | ----------------------------------------------------------- |
+| 服务器   | Dell PowerEdge R720xd                                       |
+| CPU      | Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz                   |
+| 核数     | 24                                                          |
+| 内存     | 128G                                                        |
+| 硬盘     | 机械                                                        |
+| 网卡     | Broadcom Corporation NetXtreme BCM5720 Gigabit Ethernet * 4 |
+| 管理程序 | VMware ESXi, 6.0.0, 3073146                                 |
+
+### 虚拟机
+
+| 服务器 | CPU  | 内存 | 磁盘 | 网络     |      |
+| ------ | ---- | ---- | ---- | -------- | ---- |
+| VM     | 4    | 16   | 200G | VMXNET 3 |      |
+| VM     | 4    | 16   | 200G | VMXNET 3 |      |
+
+### 网络带宽
+
+> 服务器之间共享网络带宽(6.94 Gbits/sec)
+
+```shell
+[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
+[  4]   0.00-1.00   sec   695 MBytes  5.83 Gbits/sec  136    711 KBytes
+[  4]   1.00-2.00   sec   776 MBytes  6.51 Gbits/sec    0    960 KBytes
+[  4]   2.00-3.00   sec   882 MBytes  7.41 Gbits/sec    0    960 KBytes
+[  4]   3.00-4.00   sec  1.04 GBytes  8.89 Gbits/sec    0   1.08 MBytes
+[  4]   4.00-5.00   sec   946 MBytes  7.93 Gbits/sec    0   1.08 MBytes
+[  4]   5.00-6.00   sec   736 MBytes  6.18 Gbits/sec    0   1.11 MBytes
+[  4]   6.00-7.00   sec   726 MBytes  6.09 Gbits/sec    0   1.16 MBytes
+[  4]   7.00-8.00   sec   829 MBytes  6.95 Gbits/sec    0   1.20 MBytes
+[  4]   8.00-9.00   sec  1009 MBytes  8.46 Gbits/sec  813    440 KBytes
+[  4]   9.00-10.00  sec   615 MBytes  5.16 Gbits/sec    0    641 KBytes
+- - - - - - - - - - - - - - - - - - - - - - - - -
+[ ID] Interval           Transfer     Bandwidth       Retr
+[  4]   0.00-10.00  sec  8.08 GBytes  6.94 Gbits/sec  949             sender
+[  4]   0.00-10.00  sec  8.08 GBytes  6.94 Gbits/sec                  receiver
+```
+
+### 操作系统配置
+
+* ulimit -n 65535
+
+### Alpha配置
+
+```bash
+java -Xmx3g -Xms3g -Xss256k \
+		-Dcom.sun.management.jmxremote \
+    -Dcom.sun.management.jmxremote.port=9090 \
+	  -Dcom.sun.management.jmxremote.ssl=false \
+    -Dcom.sun.management.jmxremote.authenticate=false \
+    -jar ${PRONAME} \
+  	--spring.datasource.username=saga-user \
+  	--spring.datasource.password=saga-password \
+  	--spring.datasource.url="jdbc:postgresql://10.22.1.234:5432/saga?useSSL=false" \
+  	--spring.profile.active=prd \
+  	--alpha.feature.akka.enabled=true
+```
+
+## 测试报告
+
+总结:
+
+* 0.5.0 Akka的性能比0.4.0版本提升一个数量级,吞吐率最高可达到每秒1351笔全局事务,每笔全局事务包含包含3个子事务,Alpha gPRC 接口吞吐量 1.8w/每秒
+* 0.5.0版本单节点Alpha最优并发量为 500~1000,平均耗<1s,吞吐率 1200+/秒, CPU利用率稳定工作在80%
+* 本测试客户端和服务端分别部署在不同的服务器,模拟真实网络通讯
+* Alpha估算:Alpha部署数量=最大吞吐量/1200
+
+| 节点数 | 并发数 | 总耗时(s) | 平均耗时(ms) | 吞吐率 | 事务量 |
+| ------ | ------ | --------- | ---- | ------ | ---- |
+| 0.4.0  | 100    | 102       | 1026 | 98/sec | 10000 |
+| 0.4.0  | 500    | 99      | 4970 | 101/sec | 10000 |
+| 0.5.0 | 100  | 14      | 142 | 714/sec | 10000 |
+| 0.5.0 | 500  | 8      | 418 | 1250/sec | 10000 |
+| 0.5.0 | 1000 | 8       | 858 | 1250/sec | 10000 |
+| 0.5.0 | 2000 | 14      | 2888 | 714/sec | 10000 |
+| 0.5.0 | 1000   | 39      | 786 | 1282/sec | 50000 |
+| 0.5.0 | 2000 | 37 | 1519 | 1351/sec | 50000 |
+| 0.5.0 | 3000 | 43 | 2687 | 1116/sec | 50000 |
+
+## 测试详细说明
+
+### Alpha 0.5.0 without Akka
+
+#### 测试1
+
+- 全局事务量 10000
+
+- 并发数 100
+
+  ![cmd-0.4.0-1w-100](assets/cmd-0.4.0-1w-100.png)
+
+  ![vm-0.4.0-1w-100](assets/vm-0.4.0-1w-100.png)
+
+#### 测试2
+
+- 全局事务量 10000
+
+- 并发数 500
+
+  ![image-20190709204048497](assets/cmd-0.4.0-1w-500.png)
+
+  ![image-20190709204030504](assets/vm-0.4.0-1w-500.png)
+
+### Alpha 0.5.0 with Akka
+
+测试工具模拟发送全局事务,通过多线程模拟并发(一个全局事务包含8条消息)
+
+#### 测试1
+
+* 全局事务量 10000
+
+* 并发数 100
+
+  ![image-20190709204433024](assets/cmd-0.5.0-1w-100.png)
+
+  ![image-20190709204528142](assets/vm-0.5.0-1w-100.png)
+
+#### 测试2
+
+* 全局事务量 10000
+
+* 并发数 500
+
+  ![image-20190709212111756](assets/cmd-0.5.0-1w-500.png)
+
+  ![image-20190709212159459](assets/vm-0.5.0-1w-500.png)
+
+#### 测试3
+
+- 全局事务量 10000
+
+- 并发数 1000
+
+  ![image-20190709204824851](assets/cmd-0.5.0-1w-1000.png)
+
+  ![image-20190709204941639](assets/vm-0.5.0-1w-1000.png)
+
+#### 测试4
+
+- 全局事务量 10000
+
+- 并发数 2000
+
+  ![image-20190709205508957](assets/cmd-0.5.0-1w-2000.png)
+
+  ![image-20190709205525636](assets/vm-0.5.0-1w-2000.png)
+
+#### 测试5
+
+- 全局事务量 50000
+
+- 并发数 1000
+
+  ![image-20190709205844656](assets/cmd-0.5.0-5w-1000.png)
+
+  ![image-20190709205931592](assets/vm-0.5.0-5w-1000.png)
+
+#### 测试6
+
+- 全局事务量 50000
+
+- 并发数 2000
+
+  ![image-20190709211609257](assets/cmd-0.5.0-5w-2000.png)
+
+  ![image-20190709211702492](assets/vm-0.5.0-5w-2000.png)
+
+#### 测试7
+
+- 全局事务量 50000
+
+- 并发数 3000
+
+  ![image-20190709212515846](assets/cmd-0.5.0-5w-3000.png)
+
+  ![image-20190709212629941](assets/vm-0.5.0-5w-3000.png)
\ No newline at end of file
diff --git a/alpha/alpha-fsm/README.md b/alpha/alpha-fsm/README.md
index 416e2ee..b5ebffc 100644
--- a/alpha/alpha-fsm/README.md
+++ b/alpha/alpha-fsm/README.md
@@ -69,4 +69,6 @@ alpha.feature.akka.enabled=true
 ### Tools
 - [ ]  Alpha Benchmark tools
 
+## Benchmark
 
+[benchmark](Benchmark.md)
\ No newline at end of file
diff --git a/alpha/alpha-fsm/assets/cmd-0.4.0-1w-100.png b/alpha/alpha-fsm/assets/cmd-0.4.0-1w-100.png
new file mode 100644
index 0000000..f3384c2
Binary files /dev/null and b/alpha/alpha-fsm/assets/cmd-0.4.0-1w-100.png differ
diff --git a/alpha/alpha-fsm/assets/cmd-0.4.0-1w-500.png b/alpha/alpha-fsm/assets/cmd-0.4.0-1w-500.png
new file mode 100644
index 0000000..9713e1d
Binary files /dev/null and b/alpha/alpha-fsm/assets/cmd-0.4.0-1w-500.png differ
diff --git a/alpha/alpha-fsm/assets/cmd-0.5.0-1w-100.png b/alpha/alpha-fsm/assets/cmd-0.5.0-1w-100.png
new file mode 100644
index 0000000..1ff71a0
Binary files /dev/null and b/alpha/alpha-fsm/assets/cmd-0.5.0-1w-100.png differ
diff --git a/alpha/alpha-fsm/assets/cmd-0.5.0-1w-1000.png b/alpha/alpha-fsm/assets/cmd-0.5.0-1w-1000.png
new file mode 100644
index 0000000..403b8c4
Binary files /dev/null and b/alpha/alpha-fsm/assets/cmd-0.5.0-1w-1000.png differ
diff --git a/alpha/alpha-fsm/assets/cmd-0.5.0-1w-2000.png b/alpha/alpha-fsm/assets/cmd-0.5.0-1w-2000.png
new file mode 100644
index 0000000..44e9210
Binary files /dev/null and b/alpha/alpha-fsm/assets/cmd-0.5.0-1w-2000.png differ
diff --git a/alpha/alpha-fsm/assets/cmd-0.5.0-1w-500.png b/alpha/alpha-fsm/assets/cmd-0.5.0-1w-500.png
new file mode 100644
index 0000000..bad6ee8
Binary files /dev/null and b/alpha/alpha-fsm/assets/cmd-0.5.0-1w-500.png differ
diff --git a/alpha/alpha-fsm/assets/cmd-0.5.0-5w-1000.png b/alpha/alpha-fsm/assets/cmd-0.5.0-5w-1000.png
new file mode 100644
index 0000000..67e3ef8
Binary files /dev/null and b/alpha/alpha-fsm/assets/cmd-0.5.0-5w-1000.png differ
diff --git a/alpha/alpha-fsm/assets/cmd-0.5.0-5w-2000.png b/alpha/alpha-fsm/assets/cmd-0.5.0-5w-2000.png
new file mode 100644
index 0000000..af6d050
Binary files /dev/null and b/alpha/alpha-fsm/assets/cmd-0.5.0-5w-2000.png differ
diff --git a/alpha/alpha-fsm/assets/cmd-0.5.0-5w-3000.png b/alpha/alpha-fsm/assets/cmd-0.5.0-5w-3000.png
new file mode 100644
index 0000000..b122c5e
Binary files /dev/null and b/alpha/alpha-fsm/assets/cmd-0.5.0-5w-3000.png differ
diff --git a/alpha/alpha-fsm/assets/vm-0.4.0-1w-100.png b/alpha/alpha-fsm/assets/vm-0.4.0-1w-100.png
new file mode 100644
index 0000000..5488d84
Binary files /dev/null and b/alpha/alpha-fsm/assets/vm-0.4.0-1w-100.png differ
diff --git a/alpha/alpha-fsm/assets/vm-0.4.0-1w-500.png b/alpha/alpha-fsm/assets/vm-0.4.0-1w-500.png
new file mode 100644
index 0000000..46c9520
Binary files /dev/null and b/alpha/alpha-fsm/assets/vm-0.4.0-1w-500.png differ
diff --git a/alpha/alpha-fsm/assets/vm-0.5.0-1w-100.png b/alpha/alpha-fsm/assets/vm-0.5.0-1w-100.png
new file mode 100644
index 0000000..86b5957
Binary files /dev/null and b/alpha/alpha-fsm/assets/vm-0.5.0-1w-100.png differ
diff --git a/alpha/alpha-fsm/assets/vm-0.5.0-1w-1000.png b/alpha/alpha-fsm/assets/vm-0.5.0-1w-1000.png
new file mode 100644
index 0000000..d8d0c18
Binary files /dev/null and b/alpha/alpha-fsm/assets/vm-0.5.0-1w-1000.png differ
diff --git a/alpha/alpha-fsm/assets/vm-0.5.0-1w-2000.png b/alpha/alpha-fsm/assets/vm-0.5.0-1w-2000.png
new file mode 100644
index 0000000..3a301e3
Binary files /dev/null and b/alpha/alpha-fsm/assets/vm-0.5.0-1w-2000.png differ
diff --git a/alpha/alpha-fsm/assets/vm-0.5.0-1w-500.png b/alpha/alpha-fsm/assets/vm-0.5.0-1w-500.png
new file mode 100644
index 0000000..d144a74
Binary files /dev/null and b/alpha/alpha-fsm/assets/vm-0.5.0-1w-500.png differ
diff --git a/alpha/alpha-fsm/assets/vm-0.5.0-5w-1000.png b/alpha/alpha-fsm/assets/vm-0.5.0-5w-1000.png
new file mode 100644
index 0000000..5e9afb9
Binary files /dev/null and b/alpha/alpha-fsm/assets/vm-0.5.0-5w-1000.png differ
diff --git a/alpha/alpha-fsm/assets/vm-0.5.0-5w-2000.png b/alpha/alpha-fsm/assets/vm-0.5.0-5w-2000.png
new file mode 100644
index 0000000..133ea92
Binary files /dev/null and b/alpha/alpha-fsm/assets/vm-0.5.0-5w-2000.png differ
diff --git a/alpha/alpha-fsm/assets/vm-0.5.0-5w-3000.png b/alpha/alpha-fsm/assets/vm-0.5.0-5w-3000.png
new file mode 100644
index 0000000..9aa081c
Binary files /dev/null and b/alpha/alpha-fsm/assets/vm-0.5.0-5w-3000.png differ