# A prod-faithful stack in one container, with the box's RAM and CPU as the two # things you can turn. It exists to answer "would more RAM or more CPU fix this" # by measurement rather than by argument, so the packages are the PUBLISHED debs # at versions you name - never a local build - and the data directory is a copy # of a real one, bind-mounted from outside. # # Nothing here is specific to a machine: every path, version and limit comes # from the environment (see .env.example). Copy that to .env, fill it in, then: # # docker compose -f packaging/devstack/docker-compose.yml build # docker compose -f packaging/devstack/docker-compose.yml up # # The limits are enforced by the kernel, not requested: `docker stats` and # /sys/fs/cgroup inside the container both report them, which is what makes a # measurement taken here a statement about a box of that size. services: devstack: build: context: . dockerfile: Dockerfile args: # Which debs the image installs. Point DEB_DIR at a directory holding # them and name the versions; the build copies exactly these, so the # artefact under test is the artefact prod runs. DB_VERSION: ${DB_VERSION:?set DB_VERSION, e.g. 2.21.2-1} DB_CLIENT_VERSION: ${DB_CLIENT_VERSION:?set DB_CLIENT_VERSION, e.g. 2.20.0-1} VAPI_VERSION: ${VAPI_VERSION:?set VAPI_VERSION, e.g. 0.18.0-1} image: svapi-devstack:${VAPI_VERSION}-db${DB_VERSION} # The whole point of the file, and it takes BOTH settings to model a small # box. `cpus` is a CPU-time quota: it bounds throughput correctly, but the # container still SEES every host core, so `nproc` reported 32 on a # 2-core quota - and cpp-httplib sizes its request pool from # hardware_concurrency, so vectorapi would run 31 threads where a real # 2-core box runs 8. Measured, not assumed. `cpuset` pins the container to # named cores so the COUNT is right as well as the quota, which is what # makes a concurrency measurement here mean anything. cpus: ${DEVSTACK_CPUS:-2} cpuset: ${DEVSTACK_CPUSET:-0-1} mem_limit: ${DEVSTACK_MEM:-4g} # Equal to mem_limit asks for NO swap, because a figure measured with swap # available is a figure about swap. Verify it rather than trusting it: # `docker inspect --format {{.HostConfig.MemorySwap}}` reported -1 # (unlimited) here even with this set, and what actually guaranteed no # swapping was the HOST having no swap device - check `swapon --show` # before reading any memory result off this container. memswap_limit: ${DEVSTACK_MEMSWAP:-${DEVSTACK_MEM:-4g}} volumes: # A COPY of a data directory, never a live one. Read-write, because the # server replays its WAL and writes snapshots. - ${DEVSTACK_DATA_DIR:?set DEVSTACK_DATA_DIR to a copy of a data directory}:/var/lib/smartbotic-database # The database's own config, so the stack under test has the same memory # budget and eviction thresholds as the deployment being modelled. - ${DEVSTACK_DB_CONFIG:?set DEVSTACK_DB_CONFIG}:/etc/smartbotic-database/config.json:ro - ${DEVSTACK_DB_CONFD:?set DEVSTACK_DB_CONFD}:/etc/smartbotic-database/conf.d:ro ports: - "${DEVSTACK_PORT:-8099}:8080" environment: # Only consulted on a FRESH store. With a copied data directory the keys # already exist, so this seeds nothing and the real keys keep working. SMARTBOTIC_VECTORAPI_KEY: ${SMARTBOTIC_VECTORAPI_KEY:-} stop_grace_period: 120s