Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: CI/CD Pipeline

on:
push:
branches: [ main, master, develop ]
pull_request:
branches: [ main, master, develop ]

jobs:
build-and-test:
runs-on: ubuntu-24.04

services:
nacos:
image: nacos/nacos-server:v2.4.3-slim
env:
MODE: standalone
JAVA_OPT: "-Djdk.attach.allowAttachSelf=true"
ports:
- 8848:8848
- 9848:9848
options: >-
--health-cmd="curl -f http://localhost:8848/nacos/v1/console/health/readiness"
--health-interval=10s
--health-timeout=5s
--health-retries=15
--health-start-period=60s
--cgroupns=host

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'

- name: Build with Maven
run: mvn clean package -DskipTests

- name: Run unit tests
run: mvn test -pl rpc-core,rpc-transport-netty

- name: Run integration tests
run: mvn test -pl rpc-consumer -am -Dtest=FullIntegrationTest
env:
RPC_REGISTRY: local

- name: Check test coverage
run: mvn jacoco:report

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
**/target/surefire-reports/
**/target/site/jacoco/

code-quality:
runs-on: ubuntu-24.04

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'

- name: Run Maven verify
run: mvn verify -DskipTests

- name: Check code style
run: mvn checkstyle:check || true
225 changes: 0 additions & 225 deletions .github/workflows/maven.yml

This file was deleted.

38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,44 @@ Comparison of processing a standard POJO (`RpcRequest`).
- **Protobuf vs. Java**: Protobuf is **77x faster** and **10x smaller** than standard Java serialization.
- **Binary vs. Text**: Kryo (Binary) provides **6x higher throughput** than JSON (Text) for complex objects due to Varint compression and omission of field names.

#### 5.3 End-to-End Load Test (Business Simulation)

Use `LoadTestApp` to simulate microservice-style calls with configurable concurrency, duration, payload size, and output file. It reports QPS, P50/P95/P99 latency, error rate, and basic GC/heap stats.

**1) Build**

```bash
mvn -pl rpc-consumer -am -DskipTests package
```

**2) Start Provider**

```bash
./run_server.sh
```

**3) Run Load Test Client**

```bash
java -cp rpc-consumer/target/rpc-consumer-1.0-SNAPSHOT.jar:rpc-transport-netty/target/rpc-transport-netty-1.0-SNAPSHOT.jar:rpc-core/target/rpc-core-1.0-SNAPSHOT.jar:rpc-common/target/rpc-common-1.0-SNAPSHOT.jar:rpc-api/target/rpc-api-1.0-SNAPSHOT.jar:$(mvn -q dependency:build-classpath -Dmdep.outputFile=/dev/stdout -pl rpc-consumer -am) \
com.xiaoyu.rpc.consumer.LoadTestApp \
--threads=200 --warmup=5 --duration=30 --payload=128 --output=loadtest-results.txt
```

**Parameters**
- `--threads=NUM` Worker threads (default 200)
- `--warmup=SEC` Warmup seconds (default 5)
- `--duration=SEC` Measurement seconds (default 30)
- `--payload=BYTES` Payload size in bytes (default 128)
- `--sample-size=NUM` Latency sample size (default 1,000,000)
- `--output=PATH` Output file path (default `loadtest-results.txt`)
- `--append` Append to output file

**Output format (one line per run)**
```
time=2026-04-29T12:34:56Z threads=200 warmupSec=5 durationSec=30 payloadBytes=128 total=123456 success=123000 error=456 qps=4115.20 successQps=4100.00 errorRatePct=0.37 avgLatencyMs=0.410 minMs=0.120 p50Ms=0.300 p95Ms=0.900 p99Ms=1.500 maxMs=5.000 samples=1000000 heapUsedBytes=12345678 heapTotalBytes=268435456 gcCount=2 gcTimeMs=15
```

---

## 🛠️ Configuration
Expand Down
38 changes: 38 additions & 0 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,44 @@ XiaoYu RPC 专注于极致性能。以下是使用 **JMH** 测得的真实数据
- **Protobuf vs. Java**: Protobuf 的处理速度比 Java 原生序列化快 **77 倍**,且体积缩小了 **10 倍**。
- **二进制 vs. 文本**: 在处理复杂 POJO 时,二进制协议 (Kryo/Protobuf) 的吞吐量比文本协议 (JSON) 高出约 **6 倍**,这归功于 Varint 压缩和去除字段名存储。

#### 5.3 端到端负载测试(业务模拟)

为更贴近微服务调用场景,提供一个可配置的客户端压测入口 `LoadTestApp`,支持 QPS、P50/P95/P99、错误率及 GC/堆内存统计,并可直接写入文件。

**1) 构建**

```bash
mvn -pl rpc-consumer -am -DskipTests package
```

**2) 启动 Provider**

```bash
./run_server.sh
```

**3) 启动压测客户端**

```bash
java -cp rpc-consumer/target/rpc-consumer-1.0-SNAPSHOT.jar:rpc-transport-netty/target/rpc-transport-netty-1.0-SNAPSHOT.jar:rpc-core/target/rpc-core-1.0-SNAPSHOT.jar:rpc-common/target/rpc-common-1.0-SNAPSHOT.jar:rpc-api/target/rpc-api-1.0-SNAPSHOT.jar:$(mvn -q dependency:build-classpath -Dmdep.outputFile=/dev/stdout -pl rpc-consumer -am) \
com.xiaoyu.rpc.consumer.LoadTestApp \
--threads=200 --warmup=5 --duration=30 --payload=128 --output=loadtest-results.txt
```

**参数说明**
- `--threads=NUM` 并发线程数(默认 200)
- `--warmup=SEC` 预热秒数(默认 5)
- `--duration=SEC` 采样秒数(默认 30)
- `--payload=BYTES` 请求字符串大小(默认 128)
- `--sample-size=NUM` 延迟采样容量(默认 1,000,000)
- `--output=PATH` 输出文件路径(默认 `loadtest-results.txt`)
- `--append` 追加写入文件

**输出文件格式(每行一条记录)**
```
time=2026-04-29T12:34:56Z threads=200 warmupSec=5 durationSec=30 payloadBytes=128 total=123456 success=123000 error=456 qps=4115.20 successQps=4100.00 errorRatePct=0.37 avgLatencyMs=0.410 minMs=0.120 p50Ms=0.300 p95Ms=0.900 p99Ms=1.500 maxMs=5.000 samples=1000000 heapUsedBytes=12345678 heapTotalBytes=268435456 gcCount=2 gcTimeMs=15
```

---

## 🛠️ 配置手册
Expand Down
Loading
Loading