--- /dev/null
+FROM debian:bullseye
+
+USER root
+
+ENV DEBIAN_FRONTEND noninteractive
+ENV DEBCONF_NONINTERACTIVE_SEEN true
+
+#========================
+# Packages
+#========================
+RUN apt-get update -qqy \
+ && apt-get -qqy --no-install-recommends install \
+ wondershaper \
+ ca-certificates \
+ python3 \
+ python3-pika \
+ python3-tqdm \
+ poppler-utils \
+ unzip \
+ curl \
+ wget \
+ vim-tiny \
+ nano \
+ sudo \
+ tzdata \
+ locales \
+ net-tools \
+ iputils-ping \
+ && rm -rf /var/lib/apt/lists/* \
+ && apt-get clean
+
+#=====
+# dumb-init trivial PID 1 for Zombie reaping
+#=====
+RUN wget https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_amd64.deb \
+ && dpkg -i dumb-init_*.deb \
+ && rm dumb-init_*.deb
+
+# Get wondershaper
+RUN wget -O /usr/local/sbin/wondershaper "https://raw.githubusercontent.com/magnific0/wondershaper/master/wondershaper" \
+ && chmod +x /usr/local/sbin/wondershaper
+
+# Copy the script into the container
+COPY . /srv/mqlg
+
+#=====
+# Run
+#=====
+ENTRYPOINT ["/usr/bin/dumb-init", "--"]
+#ENV BWLIMIT 100000
+#CMD /bin/bash -c "wondershaper -a eth0 -u $BWLIMIT -d $BWLIMIT && echo $BWLIMIT > /tmp/blah && /srv/mqlg/main.py sm worker"
+CMD /srv/mqlg/main.py sm worker
Requirements on debian:
- apt-get install python3 python3-pika python3-tqdm poppler-utils
+ apt-get install python3 python3-pika python3-tqdm poppler-utils
-To run:
+To run on your machine:
./main.py sm worker
+To run in a docker container:
+
+ 1. Edit run-docker.sh. Set a bandwidth limit and working directory
+ 2. sudo run-docker.sh
+
Notes:
- /tmp: Make sure /tmp is an actual tmpfs (fast disk) before running! You can use a custom directory with the TMPDIR variable.
-- Disk required: About 2GB per thread
-- Memory required: About 0.5GB per thread
+- Disk required: About 1-2GB per thread
+- Memory required: Low, maybe 10MB per thread
- Threads: Defaults to 1 per core, pass `--threads 4` to change.
--- /dev/null
+#!/bin/sh
+set -e
+cd $(dirname $0)
+
+# Workdir path is relative to host
+WORKDIR=${WORKDIR:-/tmp}
+
+# Bandwidth limit
+BWLIMIT=${BWLIMIT:-150mbit}
+
+# build and run the container in background
+docker rm mqlg || true
+docker build -t mqlg:latest .
+docker run \
+ --restart=no \
+ --detach \
+ --name=mqlg \
+ --mount type=bind,source=${WORKDIR},destination=/tmp \
+ mqlg:latest
+
+# limit the inbound bandwidth for the container by limiting the outbound bandwidth for its root veth sibling
+targetif=$(ip a | grep $(sudo docker exec mqlg cat /sys/class/net/eth0/iflink): | cut -d' ' -f2 | cut -d@ -f1)
+tc qdisc add dev $targetif root tbf rate $BWLIMIT latency 50ms burst 1540