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.
BUG=chromium:343365
TEST=Unit-tests pass.
Change-Id: I8aaa064a6789296d49984bac7a2b6e065a4c2aa7
Reviewed-on: https://chromium-review.googlesource.com/187917
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
diff --git a/common/constants.h b/common/constants.h
index 0eb0f95..640fffe 100644
--- a/common/constants.h
+++ b/common/constants.h
@@ -19,8 +19,9 @@
// kMaxSimultaneousDownloads.
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
--- a/http_server/connection_delegate.h
+++ b/http_server/connection_delegate.h
@@ -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
//
// https://code.google.com/p/chromium/issues/detail?id=246325
- static const unsigned int kPayloadBufferSize = 1048576;
+ static const unsigned int kPayloadBufferSize = 65536;
DISALLOW_COPY_AND_ASSIGN(ConnectionDelegate);
};