http_server: Lower maximum download rate from 1 MB/s to 125 kB/s.
We've found evidence that the current limit of 1 MB/s is overwhelming
some sites when p2p is enabled. If you do the numbers, 1 MB/s with
three concurrent downloads (the current limit) works out to a
bandwidth usage of 48 MBit/s which definitely overwhelms any
802.11a/b/g wireless network in use today.
Therefore, lower the bandwidth limit to 125 kB/s. With three
concurrent downloads, this works out to 6 MBit/s which is just a tad
more than half the nominal bandwidth of a 802.11b wireless network
(the slowest wireless standard in use today.)
Also lower the buffer size to avoid bursts.
Reviewed-by: Chris Sosa <firstname.lastname@example.org>
Commit-Queue: David Zeuthen <email@example.com>
Tested-by: David Zeuthen <firstname.lastname@example.org>
diff --git a/common/constants.h b/common/constants.h
index 0eb0f95..640fffe 100644
@@ -19,8 +19,9 @@
constexpr int kMaxSimultaneousDownloadsPollTimeSeconds = 30;
-// The maximum rate per download, in bytes per second.
-constexpr int64 kMaxSpeedPerDownload = 1 * 1000 * 1000;
+// The maximum rate per download, in bytes per second. Currently set
+// to 125 kB/s.
+constexpr int64 kMaxSpeedPerDownload = 125 * 1000;
// The name of p2p server binary.
constexpr char kServerBinaryName = "p2p-server";
diff --git a/http_server/connection_delegate.h b/http_server/connection_delegate.h
index 2e32dd0..18e831b 100644
@@ -158,14 +158,16 @@
// Number of bytes to read at once when processing HTTP headers.
static const unsigned int kLineBufSize = 256;
- // Number of bytes to read/send at once.
+ // Number of bytes to read/send at once. With a max speed of 125
+ // kB/s - see common/constants.h - 64 KiB works out to sending
+ // approximately twice a second.
// TODO(zeuthen): Verify this is a good buffer size e.g. that it's a
// good tradeoff between wakeups and smooth streaming. Many factors to
// consider here. This is tracked in
- static const unsigned int kPayloadBufferSize = 1048576;
+ static const unsigned int kPayloadBufferSize = 65536;