Difference between revisions of "Trickle"

From ArchWiki
Jump to: navigation, search
(fix heading levels)
(Systemd integration: -> remove)
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Category:Internet Applications]]
+
[[Category:Internet applications]]
 
{{pkg|trickle}} is a portable lightweight userspace bandwidth shaper, that either runs in collaborative mode (together with trickled) or in stand alone mode.
 
{{pkg|trickle}} is a portable lightweight userspace bandwidth shaper, that either runs in collaborative mode (together with trickled) or in stand alone mode.
  
 
It works by preloading its own socket library wrappers, that limit traffic by delaying data.
 
It works by preloading its own socket library wrappers, that limit traffic by delaying data.
  
Also trickle runs entirely in userspace.[http://monkey.org/~marius/pages/?page=trickle]
+
Trickle runs entirely in userspace. [http://monkey.org/~marius/pages/?page=trickle] {{Dead link|2015|08|28}}
  
 
== Installation ==
 
== Installation ==
{{Warning|Programs that generate heavy traffic, but get controlled via a web interfaces (with very light traffic), will also have the web interface traffic shaped. This means that they will barely be accessible!}}
+
 
{{Warning|Trickle can only limit traffic of programs that do not fork, so shaping a FTP server's traffic won't really work that way!}}
+
Install the {{pkg|trickle}} package.
Install {{pkg|trickle}} from [[Official Repositories]].
+
  
 
== Usage ==
 
== Usage ==
 +
 +
{{Warning|
 +
* Programs that generate heavy traffic, but get controlled via a web interfaces (with very light traffic), will also have the web interface traffic shaped. This means that they will barely be accessible.
 +
* Trickle can only limit traffic of programs that do not fork, so shaping a FTP server's traffic will not work that way.}}
 +
 
If you are running the daemon (see below), just start any program with "trickle" in front of it:
 
If you are running the daemon (see below), just start any program with "trickle" in front of it:
  trickle pacman -Syu
+
 
 +
  # trickle pacman -Syu
  
 
Otherwise also specify upload and download limit as well as other configuration options (see [http://monkey.org/~marius/trickle/trickle.1.txt trickle(1)] for more information):
 
Otherwise also specify upload and download limit as well as other configuration options (see [http://monkey.org/~marius/trickle/trickle.1.txt trickle(1)] for more information):
  trickle -d200 -u50 pacman -Syu
+
 
 +
  # trickle -d200 -u50 pacman -Syu
  
 
=== Modifying other systemd services ===
 
=== Modifying other systemd services ===
Copy the desired .service file from {{ic|/usr/lib/systemd/system/|}} to {{ic|/etc/systemd/system}} and add
+
 
/usr/bin/trickle
+
[[Systemd#Editing provided units|Modify]] {{ic|ExecStart}} for a desired systemd service,  appending {{ic|/usr/bin/trickle}}. For example:
in front of the ExecStart= value, eg:
+
 
  ExecStart=/usr/bin/yourdaemon
+
  ExecStart=/usr/bin/''daemon''
 +
 
 
changes to
 
changes to
ExecStart=/usr/bin/trickle /usr/bin/yourdaemon
 
  
In case you would like to use the standalone mode, also add the config options like described in the [[Trickle#Usage|Usage]] section above.
+
ExecStart=/usr/bin/trickle /usr/bin/''daemon''
  
 +
When using the standalone mode, also add the config options as described in [[#Usage]]. [[Restart]] the daemon, which should now have shaped bandwith.
  
Run this command after changing .service files:
+
=== Use with rsync ===
systemctl --system daemon-reload
+
  
And now restart your daemon, it should have shaped bandwith now.
+
Instead of putting trickle in front of the rsync command (which won't work, since rsync presumably forks the ssh process), you call rsync like this:
 +
 
 +
rsync --rsh="trickle -d 10 -u 10 ssh" SRC DEST
  
 
== Daemon configuration ==
 
== Daemon configuration ==
Line 46: Line 54:
  
 
=== Systemd integration ===
 
=== Systemd integration ===
 +
 +
{{Remove|Please document systemd services upstream for inclusion, or at least in the Bug tracker.}}
 +
 
Create the following two files and customize them to your needs.
 
Create the following two files and customize them to your needs.
  

Latest revision as of 15:51, 7 February 2016

trickle is a portable lightweight userspace bandwidth shaper, that either runs in collaborative mode (together with trickled) or in stand alone mode.

It works by preloading its own socket library wrappers, that limit traffic by delaying data.

Trickle runs entirely in userspace. [1] [dead link 2015-08-28]

Installation

Install the trickle package.

Usage

Warning:
  • Programs that generate heavy traffic, but get controlled via a web interfaces (with very light traffic), will also have the web interface traffic shaped. This means that they will barely be accessible.
  • Trickle can only limit traffic of programs that do not fork, so shaping a FTP server's traffic will not work that way.

If you are running the daemon (see below), just start any program with "trickle" in front of it:

# trickle pacman -Syu

Otherwise also specify upload and download limit as well as other configuration options (see trickle(1) for more information):

# trickle -d200 -u50 pacman -Syu

Modifying other systemd services

Modify ExecStart for a desired systemd service, appending /usr/bin/trickle. For example:

ExecStart=/usr/bin/daemon

changes to

ExecStart=/usr/bin/trickle /usr/bin/daemon

When using the standalone mode, also add the config options as described in #Usage. Restart the daemon, which should now have shaped bandwith.

Use with rsync

Instead of putting trickle in front of the rsync command (which won't work, since rsync presumably forks the ssh process), you call rsync like this:

rsync --rsh="trickle -d 10 -u 10 ssh" SRC DEST

Daemon configuration

If you want to have application specific settings with trickled, create the optional /etc/trickled.conf file as described in the trickled.conf(5) man page. For example:

[ssh]
Priority = 1
Time-Smoothing = 0.1
Length-Smoothing = 2
[ftp]
Priority = 8
Time-Smoothing = 5
Length-Smoothing = 20

Systemd integration

Tango-edit-cut.pngThis section is being considered for removal.Tango-edit-cut.png

Reason: Please document systemd services upstream for inclusion, or at least in the Bug tracker. (Discuss in Talk:Trickle#)

Create the following two files and customize them to your needs.

/etc/systemd/system/trickled.service
[Unit]
Description=trickle bandwith shaper

[Service]
EnvironmentFile=/etc/conf.d/trickled_systemd
ExecStart=/usr/bin/trickled -u${TRICKLE_UP} -d${TRICKLE_DOWN} -w${TRICKLE_WSIZE} -t${TRICKLE_STIME} -l${TRICKLE_SLENGTH} -f
Type=simple
User=nobody
Group=nobody

[Install]
WantedBy=network.target
/etc/conf.d/trickled_systemd
# Upload bandwidth limit in KBit/s
TRICKLE_UP=

# Download bandwidth limit in KBit/s
TRICKLE_DOWN=

# Set peak detection window size to size KB. This determines
# how aggressive trickled is at eliminating bandwidth consump-
# tion peaks.  Lower values will be more aggressive, but may
# also result in over shaping.
TRICKLE_WSIZE=512

# Set smoothing time to seconds s.  The smoothing time deter-
# mines with what intervals trickled will try to let the ap-
# plication transcieve data.  Smaller values will result in a
# more continuous (smooth) session, while larger values may
# produce bursts in the sending and receiving data.  Smaller
# values (0.1 - 1 s) are ideal for interactive applications
# while slightly larger values (1 - 10 s) are better for ap-
# plications that need bulk transfer.  This parameter is cus-
# tomizable on a per-application basis via trickled.conf(5).
TRICKLE_STIME=5

# Set smoothing length to length KB.  The smoothing length is
# a fallback of the smoothing time.  If trickled cannot meet
# the requested smoothing time, it will instead fall back on
# sending length KB of data.  The default value is 10 KB.
TRICKLE_SLENGTH=10