Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tugayesilyurt/springboot3-haproxy-java21-prometheus-grafana-virtual-thread
Spring Boot 3 -HAProxy-Prometheus-Grafana-Java 21 ( Virtual Thread and Platform Thread and String Templates )
https://github.com/tugayesilyurt/springboot3-haproxy-java21-prometheus-grafana-virtual-thread
grafana haproxy prometheus spring-boot-3 virtual-thread
Last synced: about 20 hours ago
JSON representation
Spring Boot 3 -HAProxy-Prometheus-Grafana-Java 21 ( Virtual Thread and Platform Thread and String Templates )
- Host: GitHub
- URL: https://github.com/tugayesilyurt/springboot3-haproxy-java21-prometheus-grafana-virtual-thread
- Owner: tugayesilyurt
- Created: 2023-10-06T17:28:11.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-09T06:32:31.000Z (over 1 year ago)
- Last Synced: 2024-01-28T23:10:57.257Z (about 1 year ago)
- Topics: grafana, haproxy, prometheus, spring-boot-3, virtual-thread
- Language: Java
- Homepage:
- Size: 425 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Project Name
Spring Boot 3 -HAProxy-Prometheus-Grafana-Java 21 ( Virtual Thread and Platform Thread and String Template )
## Tech Stack
- Java 21
- Spring Boot 3
- HAProxy
- Prometheus
- Grafana
- Docker Compose## Installation
```shell
docker-compose up -d
```
## Medium[Read the full article on Medium](https://medium.com/@htyesilyurt/spring-boot-3-haproxy-prometheus-grafana-java-21-virtual-thread-and-platform-thread-and-string-9e62a121730e)
## HAProxy UI
![HAProxy UI](https://github.com/tugayesilyurt/springboot3-haproxy-java21-prometheus-grafana-virtual-thread/blob/main/assets/haproxyui.png)
## Service Call Count in Grafana
![Grafana UI](https://github.com/tugayesilyurt/springboot3-haproxy-java21-prometheus-grafana-virtual-thread/blob/main/assets/grafana.png)
- `haproxy.cfg`
```
global
maxconn 4000defaults
mode http
timeout connect 5000
timeout client 50000
timeout server 50000frontend stats
bind *:4444
mode http
stats uri /
stats show-legends
stats enable
stats auth tugay:tugayfrontend backend_service_listen
bind *:1905
default_backend backend_servicebackend backend_service
mode http
option httpclose
balance roundrobin
server virtual-thread host.docker.internal:8091 check port 8091
server platform-thread host.docker.internal:8090 check port 8090
```- `Java 21 String Templates`
```java
var threadName = Thread.currentThread().toString();var response = STR."""
{
"thradName" :\{threadName}
"port" : "8091"
"applicationName" : "virtual-thread"
}
""";
```- `Enable Virtual thread in Spring Boot Configuration`
```java
@Bean
TomcatProtocolHandlerCustomizer> protocolHandlerVirtualThreadExecutorCustomizer() {
return protocolHandler -> {
protocolHandler.setExecutor(Executors.newVirtualThreadPerTaskExecutor());
};
}
```Apache Benchmark provides various options to control the benchmarking process.
Examples
Perform 100 requests to a website with a concurrency of 100:
```shell
# Platform Thread
ab -n 100 -c 100 http://localhost:1905/v1/api
```