mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
feat: benchmark remote framework
This commit is contained in:
parent
8b9d6df172
commit
7b9ee74c21
@ -11,6 +11,7 @@
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>powerjob-remote-framework</module>
|
||||
<module>powerjob-remote-benchmark</module>
|
||||
<module>powerjob-remote-impl-http</module>
|
||||
<module>powerjob-remote-impl-akka</module>
|
||||
</modules>
|
||||
|
52
powerjob-remote/powerjob-remote-benchmark/pom.xml
Normal file
52
powerjob-remote/powerjob-remote-benchmark/pom.xml
Normal file
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>powerjob-remote</artifactId>
|
||||
<groupId>tech.powerjob</groupId>
|
||||
<version>3.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>powerjob-remote-benchmark</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<logback.version>1.2.9</logback.version>
|
||||
<springboot.version>2.7.4</springboot.version>
|
||||
<powerjob-remote-impl-http.version>4.2.0</powerjob-remote-impl-http.version>
|
||||
<powerjob-remote-impl-akka.version>4.2.0</powerjob-remote-impl-akka.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>${logback.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>${springboot.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>tech.powerjob</groupId>
|
||||
<artifactId>powerjob-remote-impl-http</artifactId>
|
||||
<version>${powerjob-remote-impl-http.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>tech.powerjob</groupId>
|
||||
<artifactId>powerjob-remote-impl-akka</artifactId>
|
||||
<version>${powerjob-remote-impl-akka.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,19 @@
|
||||
package tech.powerjob.remote.benchmark;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* 测试工程
|
||||
* 用于 remote 协议压测
|
||||
*
|
||||
* @author tjq
|
||||
* @since 2023/1/7
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class BenchmarkApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BenchmarkApplication.class, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package tech.powerjob.remote.benchmark;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.Getter;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tech.powerjob.common.enums.Protocol;
|
||||
import tech.powerjob.remote.framework.BenchmarkActor;
|
||||
import tech.powerjob.remote.framework.base.Address;
|
||||
import tech.powerjob.remote.framework.base.ServerType;
|
||||
import tech.powerjob.remote.framework.engine.EngineConfig;
|
||||
import tech.powerjob.remote.framework.engine.impl.PowerJobRemoteEngine;
|
||||
import tech.powerjob.remote.framework.transporter.Transporter;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* EngineService
|
||||
*
|
||||
* @author tjq
|
||||
* @since 2023/1/7
|
||||
*/
|
||||
@Service
|
||||
public class EngineService {
|
||||
|
||||
public static final String HOST = "127.0.0.1";
|
||||
|
||||
public static final int SERVER_AKKA_PORT = 10001;
|
||||
public static final int SERVER_HTTP_PORT = 10002;
|
||||
|
||||
public static final int CLIENT_AKKA_PORT = 20001;
|
||||
public static final int CLIENT_HTTP_PORT = 20002;
|
||||
|
||||
@Getter
|
||||
private Transporter akkaTransporter;
|
||||
@Getter
|
||||
private Transporter httpTransporter;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
// http server
|
||||
new PowerJobRemoteEngine().start(new EngineConfig()
|
||||
.setServerType(ServerType.SERVER)
|
||||
.setActorList(Lists.newArrayList(new BenchmarkActor()))
|
||||
.setType(Protocol.HTTP.name())
|
||||
.setBindAddress(new Address().setHost(HOST).setPort(SERVER_HTTP_PORT)));
|
||||
|
||||
// akka server
|
||||
new PowerJobRemoteEngine().start(new EngineConfig()
|
||||
.setServerType(ServerType.SERVER)
|
||||
.setActorList(Lists.newArrayList(new BenchmarkActor()))
|
||||
.setType(Protocol.AKKA.name())
|
||||
.setBindAddress(new Address().setHost(HOST).setPort(SERVER_AKKA_PORT)));
|
||||
|
||||
// http client
|
||||
httpTransporter = new PowerJobRemoteEngine().start(new EngineConfig()
|
||||
.setServerType(ServerType.WORKER)
|
||||
.setActorList(Lists.newArrayList(new BenchmarkActor()))
|
||||
.setType(Protocol.HTTP.name())
|
||||
.setBindAddress(new Address().setHost(HOST).setPort(CLIENT_HTTP_PORT))).getTransporter();
|
||||
|
||||
// akka client
|
||||
akkaTransporter = new PowerJobRemoteEngine().start(new EngineConfig()
|
||||
.setServerType(ServerType.WORKER)
|
||||
.setActorList(Lists.newArrayList(new BenchmarkActor()))
|
||||
.setType(Protocol.AKKA.name())
|
||||
.setBindAddress(new Address().setHost(HOST).setPort(CLIENT_AKKA_PORT))).getTransporter();
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package tech.powerjob.remote.benchmark;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import tech.powerjob.remote.framework.BenchmarkActor;
|
||||
import tech.powerjob.remote.framework.base.Address;
|
||||
import tech.powerjob.remote.framework.base.HandlerLocation;
|
||||
import tech.powerjob.remote.framework.base.URL;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static tech.powerjob.remote.benchmark.EngineService.*;
|
||||
|
||||
/**
|
||||
* 压测测试入口
|
||||
*
|
||||
* @author tjq
|
||||
* @since 2023/1/7
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pressure")
|
||||
public class PressureTestController {
|
||||
|
||||
private static final HandlerLocation HL = new HandlerLocation().setRootPath("benchmark").setMethodPath("standard");
|
||||
|
||||
@Resource
|
||||
private EngineService engineService;
|
||||
|
||||
@GetMapping("/httpTell")
|
||||
public void httpTell(Integer blockMs, Integer responseSize, String content) {
|
||||
URL url = new URL().setLocation(HL).setAddress(new Address().setPort(SERVER_HTTP_PORT).setHost(HOST));
|
||||
final BenchmarkActor.BenchmarkRequest request = new BenchmarkActor.BenchmarkRequest().setContent(content).setBlockingMills(blockMs).setResponseSize(responseSize);
|
||||
engineService.getHttpTransporter().tell(url, request);
|
||||
}
|
||||
|
||||
}
|
@ -81,7 +81,7 @@ public class AkkaCSInitializer implements CSInitializer {
|
||||
log.info("[PowerJob-AKKA] start to process actor[path={},config={}]", rootPath, JsonUtils.toJSONString(actorConfig));
|
||||
|
||||
actorSystem.actorOf(AkkaProxyActor.props(actorInfo)
|
||||
.withDispatcher(actorConfig.getDispatcherName())
|
||||
.withDispatcher("akka.".concat(actorConfig.getDispatcherName()))
|
||||
.withRouter(new RoundRobinPool(cores)), actorConfig.getActorName());
|
||||
|
||||
});
|
||||
|
@ -111,7 +111,7 @@ akka {
|
||||
}
|
||||
|
||||
##################### default config #####################
|
||||
common-dispatcher {
|
||||
common-dispatcher {
|
||||
# Dispatcher is the name of the event-based dispatcher
|
||||
type = Dispatcher
|
||||
# What kind of ExecutionService to use
|
||||
|
@ -10,6 +10,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>powerjob-remote-impl-http</artifactId>
|
||||
<version>4.2.0</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
Loading…
x
Reference in New Issue
Block a user