Last active
June 25, 2024 19:08
-
-
Save joshlong/ae16d649f44cbcf4d509493ac1e15132 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.demo; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.stereotype.Controller; | |
import org.springframework.web.bind.annotation.GetMapping; | |
import org.springframework.web.bind.annotation.ResponseBody; | |
import org.springframework.web.client.RestClient; | |
import java.util.Map; | |
// test with | |
// hey -n 60 -c 20 http://localhost:8080/go | |
@Controller | |
@ResponseBody | |
@SpringBootApplication | |
public class DemoApplication { | |
public static void main(String[] args) { | |
Map.of("spring.threads.virtual.enabled", Boolean.toString(true), | |
"server.tomcat.threads.max", Integer.toString(16)) | |
.forEach(System::setProperty); | |
SpringApplication.run(DemoApplication.class, args); | |
} | |
private final RestClient restClient; | |
DemoApplication(RestClient.Builder b) { | |
this.restClient = b.build(); | |
} | |
@GetMapping("/go") | |
String go() { | |
return restClient | |
.get() | |
.uri("https://httpbin.org/delay/4") | |
.retrieve() | |
.body(String.class); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment