I want to implement a RESTful API service based on Webflux and Netty, and I have found some implementation demos on the official website and the Internet, but according to the current implementation method. I tested it on Jmeter and it doesn't seem to work very well, I wonder if it's a problem with my implementation, or if it's a problem with my thinking。
application.yml
Server:
port:10001
spring:
r2dbc:
url:r2dbc:mssql://localhost:1433/TutorialDB
username:sa
password:123456
pool:
max-size:32
max-idle-time:2m
max-life-time:10m
acquire-retry:3
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.5.8</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
<version>3.6.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.6.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-r2dbc</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-pool</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-mssql</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.asyncer</groupId>
<artifactId>r2dbc-mysql</artifactId>
<version>1.0.6</version>
</dependency>
Repository
public interface DeviceTypeDetailRepository extends ReactiveCrudRepository<DeviceTypeDetail, Long>{
}
Service
@Service
public class DeviceTypeDetailServiceImpl implements DeviceTypeDetailService {
private final DeviceTypeDetailRepository deviceTypeDetailRepository;
public DeviceTypeDetailServiceImpl(DeviceTypeDetailRepository deviceTypeDetailRepository) {
this.deviceTypeDetailRepository = deviceTypeDetailRepository;
}
@Override
public Flux<DeviceTypeDetail> FetchAll(){
return deviceTypeDetailRepository.findAll();
}
}
Controller
@CrossOrigin
@RestController
@RequestMapping("/api/devicetypedetail")
public class DeviceTypeDetailController {
@Autowired
private DeviceTypeDetailService deviceTypeDetailService;
@GetMapping("/all")
public Flux<DeviceTypeDetail> FetchAll() {
return deviceTypeDetailService.FetchAll();
}
}
Jmeter Aggregate Report --Webflux
Number of Threads = 1000 Ramp-up = 1 loop Count = 100

Jmeter Aggregate Report --MVC
Number of Threads = 1000 Ramp-up = 1 loop Count = 100

I wonder if it's the wrong way I've implemented it or what's the case.
Never mind, I give up on using the combination of WebFlux + R2DBC. It's possible that R2DBC is causing a decrease in throughput compared to MVC + JDBC. When I use Vert.x alone, it feels good, and there's a throughput improvement of 3-5 times.