怼上数据库(postgres)后简单模拟了一下 quarkus 在有限内存的情况
implementation("io.quarkus:quarkus-hibernate-reactive")
implementation("io.quarkus:quarkus-resteasy-reactive-jackson")
implementation("io.quarkus:quarkus-hibernate-reactive-panache-kotlin")
implementation("io.quarkus:quarkus-kotlin")
implementation("io.quarkus:quarkus-reactive-pg-client")
@
Entityclass Todo : PanacheEntity() {
companion object : PanacheCompanion<Todo>
var title: String? = null
var description: String? = null
var completed: Boolean? = null
@
Column(name = "due_date")
var dueDate: LocalDate? = null
@
Column(name = "created_at", updatable = false)
var createdAt: LocalDate? = null
@
Column(name = "updated_at")
var updatedAt: LocalDate? = null
}
@
Path("todo")
class TodoApi {
@
GET fun getAll() = Todo.listAll()
@
POST fun save(todo: Todo): Uni<Todo> {
if (
todo.id == null) {
return todo.persistAndFlush<Todo>()
}
throw WebApplicationException("id shouldn't exist", 499)
}
@
GET @
Path("{id}")
fun getOne(@RestPath id: Long) = Todo.findById(id)
}
version: '3.8'
services:
postgres:
deploy:
resources:
limits:
memory: 100m
cpus: "0.1"
image: postgres:latest
environment:
POSTGRES_DB: yazinnnn
POSTGRES_USER: yazinnnn
POSTGRES_PASSWORD: yazinnnn
sample:
image: yazi/sample:1.0
deploy:
resources:
limits:
memory: 20m
cpus: "0.1"
ports:
- "80:8080"
depends_on:
- postgres
environment:
"QUARKUS_DATASOURCE_REACTIVE_URL": vertx-reactive:postgresql://postgres/yazinnnn
➜ postgres wrk -t 12 -c 100 -d 10s http://localhost/todo 18:09:49
Running 10s test @ http://localhost/todo
12 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 536.18ms 143.86ms 999.36ms 75.14%
Req/Sec 16.39 10.27 80.00 71.69%
1750 requests in 10.09s, 3.31MB read
Requests/sec: 173.39
Transfer/sec: 335.78KB
➜ postgres wrk -t 12 -c 100 -d 10s http://localhost/todo/1 18:10:03
Running 10s test @ http://localhost/todo/1
12 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 256.09ms 78.20ms 499.31ms 84.83%
Req/Sec 31.49 17.98 191.00 60.73%
3686 requests in 10.08s, 705.52KB read
Requests/sec: 365.55
Transfer/sec: 69.97KB