commit c7675d04f7cb861f65877d9162da9572eade7242 Author: Karsten Loesing karsten.loesing@gmx.net Date: Wed Nov 30 07:54:53 2011 +0100
Take out top-10 relays by bandwidth history.
Updating this table for a new time interval took 2--5 minutes. That's unacceptable. This happened at least four times a day when the cached table data got stale or whenever a user entered a different start or end date of the time interval. This doesn't just delay page load times, but also keeps the database busy and affects other users.
If we want this table back, we'll have to pre-calculate some values. --- rserve/tables.R | 16 ---------- .../ernie/web/GraphsSubpagesServlet.java | 3 -- .../ernie/web/TableParameterChecker.java | 1 - web/WEB-INF/network.jsp | 30 -------------------- 4 files changed, 0 insertions(+), 50 deletions(-)
diff --git a/rserve/tables.R b/rserve/tables.R index b4ef535..e2e270d 100644 --- a/rserve/tables.R +++ b/rserve/tables.R @@ -70,19 +70,3 @@ write_censorship_events <- function(start, end, path) { write.csv(r, path, quote = FALSE, row.names = FALSE) }
-write_top_10_relays <- function(start, end, path) { - drv <- dbDriver("PostgreSQL") - con <- dbConnect(drv, user = dbuser, password = dbpassword, dbname = db) - q <- paste("SELECT fingerprint, SUM(written_sum) ", - "AS written_sum FROM bwhist WHERE date >= '", start, - "' AND date <= '", end, "' GROUP BY 1 ORDER BY 2 DESC LIMIT 10", - sep = "") - rs <- dbSendQuery(con, q) - c <- fetch(rs, n = -1) - dbDisconnect(con) - dbUnloadDriver(drv) - c <- data.frame(fingerprint = c$fingerprint, - written_sum = round(c$written_sum / 2^40, 2)) - write.csv(c, path, quote = FALSE, row.names = FALSE) -} - diff --git a/src/org/torproject/ernie/web/GraphsSubpagesServlet.java b/src/org/torproject/ernie/web/GraphsSubpagesServlet.java index 16d0db0..c7f3056 100644 --- a/src/org/torproject/ernie/web/GraphsSubpagesServlet.java +++ b/src/org/torproject/ernie/web/GraphsSubpagesServlet.java @@ -36,9 +36,6 @@ public class GraphsSubpagesServlet extends HttpServlet { this.availableGraphsSubpageTables.put("users.html", new HashSet<String>(Arrays.asList( "direct-users,censorship-events".split(",")))); - this.availableGraphsSubpageTables.put("network.html", - new HashSet<String>(Arrays.asList( - "top-10-relays".split(","))));
this.knownCountries = Countries.getInstance().getCountryList(); } diff --git a/src/org/torproject/ernie/web/TableParameterChecker.java b/src/org/torproject/ernie/web/TableParameterChecker.java index 2c0a7be..5b6f627 100644 --- a/src/org/torproject/ernie/web/TableParameterChecker.java +++ b/src/org/torproject/ernie/web/TableParameterChecker.java @@ -41,7 +41,6 @@ public class TableParameterChecker { this.availableTables = new HashMap<String, String>(); this.availableTables.put("direct-users", "start,end,filename"); this.availableTables.put("censorship-events", "start,end,filename"); - this.availableTables.put("top-10-relays", "start,end,filename");
this.knownParameterValues = new HashMap<String, String>(); } diff --git a/web/WEB-INF/network.jsp b/web/WEB-INF/network.jsp index dc7facc..d105575 100644 --- a/web/WEB-INF/network.jsp +++ b/web/WEB-INF/network.jsp @@ -234,36 +234,6 @@ in the network.</p> </form> <p><a href="csv/bandwidth.csv">CSV</a> file containing all data.</p> <br> -<a name="top-10-relays"></a> -<p><b>Top-10 relays by bandwidth history:</b></p> -<table> - <tr> - <th>Fingerprint</th> - <th>Bandwidth history</th> - </tr> - <c:forEach var="row" items="${top_10_relays_tabledata}"> - <tr> - <td><a href="https://metrics.torproject.org/relay.html?fingerprint=${row['fingerprint']}">${row['fingerprint']}</a> </td> - <td><fmt:formatNumber type="number" minFractionDigits="2" value="${row['written_sum']}" /> TiB</td> - </tr> - </c:forEach> -</table> -<br> -<form action="network.html#top-10-relays"> - <div class="formrow"> - <input type="hidden" name="table" value="top-10-relays"> - <p> - <label>Start date (yyyy-mm-dd):</label> - <input type="text" name="start" size="10" - value="<c:choose><c:when test="${fn:length(top_10_relays_start) == 0}">${default_start_date}</c:when><c:otherwise>${top_10_relays_start[0]}</c:otherwise></c:choose>"> - <label>End date (yyyy-mm-dd):</label> - <input type="text" name="end" size="10" - value="<c:choose><c:when test="${fn:length(top_10_relays_end) == 0}">${default_end_date}</c:when><c:otherwise>${top_10_relays_end[0]}</c:otherwise></c:choose>"> - </p><p> - <input class="submit" type="submit" value="Update table"> - </p> - </div> -</form>
<a name="bwhist-flags"></a> <h3><a href="#bwhist-flags" class="anchor">Relay bandwidth by Exit and/or