Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rate limiting issue #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@

# HTTP
HTTP_BIND=127.0.0.1
HTTP_PORT=4080
HTTP_PORT=4080

# Traffic control qdisc TRF fields
QDISC_TBF_BURST=5kb
QDISC_TBF_LATENCY=50ms
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ ENV DOCKER_TC_VERSION="${VERSION:-dev}" \
S6_KILL_GRACETIME=0 \
S6_KILL_FINISH_MAXTIME=0 \
S6_KEEP_ENV=1 \
S6_BEHAVIOUR_IF_STAGE2_FAILS=2
S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
QDISC_TBF_BURST=5kb \
QDISC_TBF_LATENCY=50ms
LABEL maintainer="Łukasz Lach <[email protected]>" \
org.opencontainers.image.title="docker-tc" \
org.opencontainers.image.description="Docker Traffic Control" \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Docker Traffic Control recognizes the following labels:
* `bit`, `kbit`, `mbit`, `gbit`, `tbit`
* `bps`, `kbps`, `mbps`, `gbps`, `tbps`
* to specify in IEC units, replace the SI prefix (k-, m-, g-, t-) with IEC prefix (ki-, mi-, gi- and ti-) respectively
* to configure other [rate specific parameters](https://linux.die.net/man/8/tc-tbf#:~:text=to%201mbit/s.-,Parameters,-See%20tc(8)), setup env variables `QDISC_TBF_BURST` and `QDISC_TBF_LATENCY` before running docker-tc
* `com.docker-tc.delay` - length of time packets will be delayed, accepts a floating point number followed by an optional unit:
* `s`, `sec`, `secs`
* `ms`, `msec`, `msecs`
Expand Down
2 changes: 1 addition & 1 deletion bin/tc-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ qdisc_netm() {
qdisc_tbf() {
IF="$1"
shift
tc qdisc add dev "$IF" $QDISC_HANDLE tbf burst 5kb latency 50ms $@
tc qdisc add dev "$IF" $QDISC_HANDLE tbf burst $QDISC_TBF_BURST latency $QDISC_TBF_LATENCY $@
qdisc_next
}
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ services:
environment:
HTTP_BIND: "${HTTP_BIND:-127.0.0.1}"
HTTP_PORT: "${HTTP_PORT:-4080}"
QDISC_TBF_BURST: "${QDISC_TBF_BURST:-5kb}"
QDISC_TBF_LATENCY: "${QDISC_TBF_LATENCY:-50ms}"
network_mode: host

networks:
Expand Down