A simple PHP Apache API application and MariaDB, containerized with Docker.
PHP Container: FROM php:8.4-apache
- OS Debian GNU/Linux: 13
- PHP: 8.4.11
- pdo
- pdo_mysql
- opcache
MariaDB Container: FROM mariadb:lts-ubi9
- OS Red Hat Enterprise Linux: 9.6 (Plow)
- MariaDB: 11.8.2
Adminer Container: FROM adminer:5-standalone
- OS Alpine Linux: 3.22.1
- Adminer: 5.3.0
Grafana/k6 Container: FROM grafana/k6:1.1.0
- OS Alpine Linux: 3.22.0
- Grafana/k6: 1.1.0
git clone https://github.com/opsnoopop/api_php_apache_mariadb.gitcd api_php_apache_mariadbdocker compose up -d --builddocker exec -i container_mariadb mariadb -u'testuser' -p'testpass' testdb -e "
CREATE TABLE IF NOT EXISTS testdb.users (
user_id INT NOT NULL AUTO_INCREMENT ,
username VARCHAR(50) NOT NULL ,
email VARCHAR(100) NOT NULL ,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY (user_id)
) ENGINE = InnoDB;"curl -X GET http://localhost/curl -X POST http://localhost/users -H 'Content-Type: application/json' -d '{"username":"optest","email":"opsnoopop@hotmail.com"}'curl -X GET http://localhost/users/1step 1 prepare
step 2 run test someting
step 3 cleanup
sysbench \
...
oltp_read_write prepare; # step 1 prepare สร้าง table
sysbench \
...
oltp_read_write run; # step 2 run test อ่าน เขียน พร้อมกัน
sysbench \
...
oltp_read_only run; # step 2 run test อ่าน อย่างเดียว
sysbench \
...
oltp_write_only run; # step 2 run test เขียน อย่างเดียว
sysbench \
...
oltp_update_index run; # step 2 run test update index
sysbench \
...
oltp_point_select run; # step 2 run test query แบบเลือก row เดียว
sysbench \
...
oltp_delete run; # step 2 run test delete rows
sysbench \
...
oltp_read_write cleanup; # step 3 cleanup ลบ table
docker run \
--name container_sysbench \
--rm \
-it \
--network global_optest \
opsnoopop/ubuntu:24.04 \
sysbench \
--threads=2 \
--time=10 \
--db-driver="mysql" \
--mysql-host="container_mariadb" \
--mysql-port=3306 \
--mysql-user="testuser" \
--mysql-password="testpass" \
--mysql-db="testdb" \
--tables=10 \
--table-size=100000 \
oltp_read_write prepare;docker run \
--name container_sysbench \
--rm \
-it \
--network global_optest \
-v ./sysbench/:/sysbench/ \
opsnoopop/ubuntu:24.04 \
sysbench \
--threads=2 \
--time=10 \
--db-driver="mysql" \
--mysql-host="container_mariadb" \
--mysql-port=3306 \
--mysql-user="testuser" \
--mysql-password="testpass" \
--mysql-db="testdb" \
--tables=10 \
--table-size=100000 \
oltp_read_write run > ./sysbench/sysbench_raw_$(date +"%Y%m%d_%H%M%S").txt;docker run \
--name container_sysbench \
--rm \
-it \
--network global_optest \
opsnoopop/ubuntu:24.04 \
sysbench \
--threads=2 \
--time=10 \
--db-driver="mysql" \
--mysql-host="container_mariadb" \
--mysql-port=3306 \
--mysql-user="testuser" \
--mysql-password="testpass" \
--mysql-db="testdb" \
--tables=10 \
--table-size=100000 \
oltp_read_write cleanup;docker run \
--name container_k6 \
--rm \
-it \
--network global_optest \
-v ./k6/:/k6/ \
grafana/k6:1.1.0 \
run /k6/k6_1_ramping_health_check.jsdocker run \
--name container_k6 \
--rm \
-it \
--network global_optest \
-v ./k6/:/k6/ \
grafana/k6:1.1.0 \
run /k6/k6_2_ramping_create_user.jsdocker run \
--name container_k6 \
--rm \
-it \
--network global_optest \
-v ./k6/:/k6/ \
grafana/k6:1.1.0 \
run /k6/k6_3_ramping_get_user_by_id.jsdocker run \
--name container_wrk \
--rm \
-it \
--network global_optest \
-v ./wrk/:/wrk/ \
opsnoopop/ubuntu:24.04 \
wrk -c1000 -t2 -d10s http://172.16.0.11:80docker run \
--name container_wrk \
--rm \
-it \
--network global_optest \
-v ./wrk/:/wrk/ \
opsnoopop/ubuntu:24.04 \
wrk -c1000 -t2 -d10s -s /wrk/create_user.lua http://172.16.0.11:80/usersdocker run \
--name container_wrk \
--rm \
-it \
--network global_optest \
-v ./wrk/:/wrk/ \
opsnoopop/ubuntu:24.04 \
wrk -c1000 -t2 -d10s http://172.16.0.11:80/users/1docker exec -i container_mariadb mariadb -u'testuser' -p'testpass' testdb -e "
Truncate testdb.users;"docker exec -i container_mariadb mariadb -u'testuser' -p'testpass' testdb -e "
DELETE FROM testdb.users;"docker compose down