This repo is a test using the redbean application server with the "fullmoon" framework for lua-based web applications. Learn more about redbean, the cosmopolitan libc-based redbean application server. This seems to offer good performance according to these benchmarks:
- https://github.com/pkulchenko/fullmoon?tab=readme-ov-file#benchmark
- https://github.com/berwynhoyt/lua-server-benchmark?tab=readme-ov-file
It is a simple test trying out the "fullmoon" lua web framework with a dynamic database with three tables/entities - products, reviews and prices. The solution is packaged as a container and the application provides some routes / API endpoints for those entities (a "backend") and a very very simplistic "frontend" part capable of providing a product listing and some product details (json).
Run this command (which downloads a 25.4 MB container image and starts it) and then open "http://localhost:8080"
podman run --rm -p "8080:8080" ghcr.io/mskyttner/bloodmoon
You can also download the smaller (3.2 MB of which 2.3 MB is taken by the embedded sqlite3 database) binary and run it, if you dare:
wget https://github.com/mskyttner/bloodmoon/raw/main/redbean.com && chmod +x ./redbean.com && ./redbean.com
This step is not required because synth.db
is already provided in the repo.
Synthetic data for products, reviews and prices (10 000 of each) was generated using:
make db
This uses an R script which synthesizes data based on some .json files provided in the repo. The result is the synth.db
sqlite3 database.
The Makefile
makes use of podman
and httpie
(see httpie) and wrk2 (containerized, but see GitHub repo here).
When doing make build
, this database is embedded and used from within the redbean web server which also includes an application utilizing the fullmoon.lua web framework, with the (simplistic!) application code in .init.lua
.
Use the Makefile
to build, start and benchmark etc.
# build a container, 24.6 MB including everything (redbean, fullmoon, application, database)
make build
# start it locally, exposing it on port 8080
make up
# check it out in the browser
make browse
# issue some requests against the "backend" / API endpoints
make request-apis
# issue some requests against the "frontend"
make request-webshop
# run a benchmark
make bench
# clean up
make clean
A build_metal_ape.sh
script is provided for those who might want to build a portable application locally for this project.