TorrentFlux.com Welcome, Guest. Please login or register.
12-01-2008, 13:04:35
Home Help Search Login Register donate
TorrentFlux Home | TorrentFlux Hosting

+  TorrentFlux Forums
|-+  Bugs, Fixes, and Feature Requests
| |-+  Feature Requests
| | |-+  Global Upload/Download limit
« previous next »
Pages: [1] Go Down Print
Author Topic: Global Upload/Download limit  (Read 3975 times)
barhom
Newbie
*
Offline Offline

Posts: 14



View Profile
« on: 11-04-2005, 15:03:52 »

Well the subject/topic says it all, but it looks hard to enforce something like this since each torrent have its own process if I am not mistaken, this should be something to look at however for future releases. I'm not sure how you could get this to work.
Like perhaps an external program that limits the speed of process XYZ

Also question; if you set upload limit 0kb/s, is it unlimited or 0?
Logged
IhatemyISP
Forum Code Monkey
Hero Member
*****
Offline Offline

TF Base: Linux 2.x
Posts: 842






View Profile WWW
« Reply #1 on: 11-04-2005, 15:07:26 »

Trickle is the best solution I found for this.

It allows for a per torrent limit, or a overall limit of all processes that attach to trickle.

I'll see if I can dig up the post from the old forums explaining everything, and the coding needed for it.
Logged

Pentium III 667mhz | 155GB RAID 0 | 256MB RAM | Redhat 7.3 - 2.4.18-3 | Python 2.4.1 | PHP 5.1.4 (cgi-fcgi) | Lighttpd 1.4.11
barhom
Newbie
*
Offline Offline

Posts: 14



View Profile
« Reply #2 on: 11-04-2005, 15:11:23 »

hah, the old forums, google's cache has some data ^^
Logged
IhatemyISP
Forum Code Monkey
Hero Member
*****
Offline Offline

TF Base: Linux 2.x
Posts: 842






View Profile WWW
« Reply #3 on: 11-04-2005, 15:20:28 »

hah, the old forums, google's cache has some data ^^

Glad to see you found it. Let me know if you need any help setting it up.
Logged

Pentium III 667mhz | 155GB RAID 0 | 256MB RAM | Redhat 7.3 - 2.4.18-3 | Python 2.4.1 | PHP 5.1.4 (cgi-fcgi) | Lighttpd 1.4.11
barhom
Newbie
*
Offline Offline

Posts: 14



View Profile
« Reply #4 on: 11-04-2005, 15:23:46 »

damn it, you got me wrong... I found lots of other google cache data, but not this trickle ;\
Logged
IhatemyISP
Forum Code Monkey
Hero Member
*****
Offline Offline

TF Base: Linux 2.x
Posts: 842






View Profile WWW
« Reply #5 on: 11-04-2005, 15:29:48 »

damn it, you got me wrong... I found lots of other google cache data, but not this trickle ;\

Ah well, was worth a shot. I'll dig it up and post when I can.

Cheers
Logged

Pentium III 667mhz | 155GB RAID 0 | 256MB RAM | Redhat 7.3 - 2.4.18-3 | Python 2.4.1 | PHP 5.1.4 (cgi-fcgi) | Lighttpd 1.4.11
Cyberwizzard
Newbie
*
Offline Offline

Posts: 5



View Profile
« Reply #6 on: 11-06-2005, 15:20:45 »

I found the thread in the Google cache (marvelous feature Tongue) and right now I'm hacking it into TorrentFlux 2.0 beta.

I'll add a post below this one while editing (I'll make the mod so it'll use the configuration).

P.S. I vote for this one to end up in the next version Cheesy
Logged
Cyberwizzard
Newbie
*
Offline Offline

Posts: 5



View Profile
« Reply #7 on: 11-06-2005, 16:34:00 »

Right here we go. For the Gentoo users here:
Code:
echo "net-misc/trickle ~x86" >> /etc/portage/package.keywords
emerge trickle
touch /etc/trickled.conf

Edit 'config.php' and look for:
Code:
$cfg["hide_offline"] = ....
insert after this line:
Code:
// Location of the Trickle binaries - leave blank to disable Trickle support
$cfg["trickle"] = "/usr/bin/trickle";
$cfg["trickled"] = "/usr/bin/trickled -t 0.2"; // Options are allowed here, do not append max up/download here, look below for those

// Maximum total speeds using Trickle
$cfg["trickle_max_upload"] = 90;  // Speed in kb/s - make 0 to ommit
$cfg["trickle_max_download"] = 0; // Speed in kb/s - make 0 to ommit

Next, open up 'index.php' and find the following code:
Code:
if (usingTornado())
        {
                $command = ...

Replace everything between the { } with the following:
Code:
                $trickle_command = "";  // We default to no trickle command
                if ((!empty($cfg["trickle"])) && (!empty($cfg["trickled"]))) {
                    // Test if the daemon is running - if not, start it
                    $t_command = "ps aux | grep trickled | awk '{ print $11 }' | grep trickled";
                    $result = shell_exec($t_command);

                    //echo "executed: $t_command<br>result: $result<br>";

                    // Fire up the daemon if result is empty (the program is not running)
                    if ($result == "") {
                        $t_command = $cfg["trickled"] . (($cfg["trickle_max_upload"] > 0) ? " -u " . $cfg["trickle_max_upload"] : "") .
 (($cfg["trickle_max_download"] > 0) ? " -d " . $cfg["trickle_max_download"] : "");
                        $result = exec($t_command);

                        //echo "executed: $t_command<br>result code: " . $result;
                    }

                    // Actualy start trickle
                    $trickle_command = $cfg["trickle"] . " ";

                }

                $command = "cd " . $cfg["path"] . $owner . "; HOME=".$cfg["path"]."; export HOME; nohup ". $trickle_command
 .$cfg["btphpbin"] . " ".$runtime." ".$sharekill." ".$cfg["torrent_file_path"].$alias.".stat ".$owner." --responsefile
'".$cfg["torrent_file_path"].$torrent."' --display_interval 5 --max_download_rate ". $drate ." --max_upload_rate ".$rate."
--max_uploads ".$maxuploads." --minport ".$minport." --maxport ".$maxport." --super_seeder ".$superseeder."
".$cfg["cmd_options"]." > /dev/null &";   

I've made the long lines into multiple lines here for the sake of keeping the forum layout in tact - please make them into the same line again when using this code snippet.

Note that I just hacked it into the BitTornado part - if you want to make it for both clients move the Trickle code outside the if statement and modify the BT execute string to include the Trickle start.

It works like a charm for me! Cheesy

P.S. I see a high CPU load which slows down my server when I run 15 torrents at once but I think I can fix that by nice-ing the bt client - this should be possible by simply editing cfg["trickle"] and appending something like "nice -n20" to the end of the command (the script simply executes the command, it does not care we also start nice along the way). *This is untested*
P.P.S. Adjust the -t parameter in cfg["trickled"] to smooth data limiting - my troughput goes from 84 to 96 which I find perfectly acceptable as the maximum is 120kb/s (leaves me room for webpages and email traffic).

P.P.P.S. I'll post this under the 2.0 hacks as well Smiley
« Last Edit: 11-06-2005, 16:42:49 by Cyberwizzard » Logged
barhom
Newbie
*
Offline Offline

Posts: 14



View Profile
« Reply #8 on: 11-07-2005, 12:49:01 »

hmm pretty weird, I never found that in google's cache, was this that post you were going to post, ihatemyisp?

Anyways, thanks cyberwizard, I'll play around with it soon and about that nice thing, it does work perfectly for me, I run nice -n 5 on my torrents and my server is running MUCH faster than it was without the nice and lots of torrents, my server loads went down from 3-4 to 0.5 with that nice -n 5
Logged
Pages: [1] Go Up Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by SMF 1.1.1 | SMF © 2006, Simple Machines LLC Powered by PHP