Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-3067 Improve performance of FetchItemQueues if error state is preserved

Sebastian Nagel63da6267f82e
diff --git a/conf/nutch-default.xml b/conf/nutch-default.xml
index 45e933b4d..88d61b479 100644
--- a/conf/nutch-default.xml
+++ b/conf/nutch-default.xml
@@ -1198,7 +1198,11 @@
<name>fetcher.throughput.threshold.retries</name>
<value>5</value>
<description>The number of times the fetcher.throughput.threshold.pages is allowed to be exceeded.
- This settings prevents accidental slow downs from immediately killing the fetcher thread.
+ This settings prevents accidental slow downs from immediately shutting down the fetcher threads.
+ The throughput is checked approx. every second. Note: the number of retries should be lower
+ than the timeout defined by mapreduce.task.timeout and fetcher.threads.timeout.divisor (see there).
+ For the default values, the timeout is 300 seconds. Consequently, the number of retries should be
+ significantly lower.
</description>
</property>
diff --git a/src/java/org/apache/nutch/fetcher/FetchItemQueues.java b/src/java/org/apache/nutch/fetcher/FetchItemQueues.java
index db2dece17..30ad15ae2 100644
--- a/src/java/org/apache/nutch/fetcher/FetchItemQueues.java
+++ b/src/java/org/apache/nutch/fetcher/FetchItemQueues.java
@@ -260,7 +260,7 @@ public class FetchItemQueues {
// empties the queues (used by fetcher timelimit and throughput threshold)
public synchronized int emptyQueues() {
- int count = 0;
+ int count = 0, queuesDropped = 0;
for (String id : queues.keySet()) {
FetchItemQueue fiq = queues.get(id);
@@ -270,8 +270,12 @@ public class FetchItemQueues {
int deleted = fiq.emptyQueue();
totalSize.addAndGet(-deleted);
count += deleted;
+ queuesDropped++;
}
+ LOG.info("Emptied all queues: {} queues with {} items",
+ queuesDropped, count);
+
return count;
}
diff --git a/src/java/org/apache/nutch/fetcher/Fetcher.java b/src/java/org/apache/nutch/fetcher/Fetcher.java
index 5ae13a52b..e0babd95e 100644
--- a/src/java/org/apache/nutch/fetcher/Fetcher.java
+++ b/src/java/org/apache/nutch/fetcher/Fetcher.java
@@ -163,7 +163,7 @@ public class Fetcher extends NutchTool implements Tool {
StringBuilder status = new StringBuilder();
Long elapsed = Long.valueOf((System.currentTimeMillis() - start) / 1000);
- float avgPagesSec = (float) pages.get() / elapsed.floatValue();
+ float avgPagesSec = pages.get() / elapsed.floatValue();
long avgBytesSec = (bytes.get() / 128l) / elapsed.longValue();
status.append(activeThreads).append(" threads (")
@@ -317,12 +317,15 @@ public class Fetcher extends NutchTool implements Tool {
if (pagesLastSec < throughputThresholdPages) {
throughputThresholdNumRetries++;
LOG.warn(
- "{}: dropping below configured threshold of {} pages per second",
- throughputThresholdNumRetries, throughputThresholdPages);
+ "{}: dropping below configured threshold of {} pages per second (current throughput: {} pages/sec.)",
+ throughputThresholdNumRetries, throughputThresholdPages,
+ pagesLastSec);
// Quit if we dropped below threshold too many times
if (throughputThresholdNumRetries == throughputThresholdMaxRetries) {
- LOG.warn("Dropped below threshold too many times, killing!");
+ LOG.warn(
+ "Dropped below threshold {} times, dropping fetch queues to shut down",
+ throughputThresholdNumRetries);
// Disable the threshold checker
throughputThresholdPages = -1;
@@ -427,7 +430,8 @@ public class Fetcher extends NutchTool implements Tool {
* we stop the fetching now.
*/
if ((System.currentTimeMillis() - lastRequestStart.get()) > timeout) {
- LOG.warn("Aborting with {} hung threads.", activeThreads);
+ LOG.warn("Aborting with {} hung threads{}.", activeThreads,
+ feeder.isAlive() ? " (queue feeder still alive)" : "");
innerContext.getCounter("FetcherStatus", "hungThreads")
.increment(activeThreads.get());
for (int i = 0; i < fetcherThreads.size(); i++) {