PostgreSQL is an open-source relational database management system that runs as a database server. A REST API can connect to it through a pooled client connection and use SQL to produce HTTP responses. section 3.5
REST API request path
A Rust Actix Web handler obtains a connection from a mobc pool, executes SELECT 'hello world', and returns the first result. Running the service with DATABASE_URL and measuring /hello with wrk makes database and network latency observable. section 3.5
Listing 3.2 The HTTP request handler with PostgreSQL
async fn say_hello(
pool: web::Data<DatabasePool>,
) -> anyhow::Result<String, Error> {
let conn = pool
.get()
.await
.map_err(ErrorInternalServerError)?;
let result = conn
.query_one("SELECT 'hello world'", &[])
.await
.map_err(ErrorInternalServerError)?;
Ok(result.get(0))
}
Inspect the handler that acquires a pooled PostgreSQL connection, executes a query, maps failures to HTTP errors, and returns the result. section 3.5
Compared with an embedded SQLite database, PostgreSQL introduces network-access variability: the measured REST API showed higher latency and lower throughput, while retaining the client-server deployment model. section 3.5










