Algorithm Search⌘K

Problemadvanced

Crawl revisit policy

Also called page refresh scheduling, crawl freshness optimization.

Choose how often to refetch each page, given its change rate, so that the average freshness of the local copy is highest.

The crawl revisit policy problem asks how often a crawler should fetch each page again, so that its stored copies stay close to the live web. The crawler can fetch only a fixed number of pages per day, and pages change at very different rates: a news front page changes every few minutes, and an old paper never changes. Junghoo Cho and Hector Garcia-Molina modelled the changes of each page as a Poisson process, defined the freshness and the age of a copy, and proved a result that surprised many people: spreading the fetches evenly over all pages gives a higher average freshness than fetching each page in proportion to how often it changes. The best policy even gives up on pages that change too often. Real crawlers estimate the rates from past visits, weigh pages by importance, and measure how well the policy does.

In plain words

A search engine keeps a copy of each page it has read, but the real pages keep changing, so some copies go out of date. The crawler can only reread a fixed number of pages each day. The question is how to share those rereads between the pages. It seems natural to reread a page more often if it changes more often. But a page that changes all the time is out of date again a moment after the reread, so time spent on it is mostly wasted. A page that changes now and then stays good for a long time after each reread. So it is better to spend the effort on pages that you can actually keep up to date. Giving every page the same share already beats giving shares by change rate, and a careful split does a bit better still.

Definition

There are NN pages. Page ii changes at the times of a Poisson process with rate λi>0\lambda_i > 0, independently of the other pages. The crawler refreshes page ii at rate fi≥0f_i \ge 0, at equal intervals of length Ii=1/fiI_i = 1/f_i (fixed-order refresh), and the total rate is fixed: ∑ifi=F\sum_i f_i = F. A refresh copies the live page at that moment.

  • The freshness of page ii at time tt is Fi(t)=1F_i(t) = 1 if the copy equals the live page, and 0 if not.
  • The age of page ii at time tt is Ai(t)=0A_i(t) = 0 if the copy is fresh, and else tt minus the time of the first change since the last refresh.

The freshness of the collection is 1N∑iFi(t)\frac{1}{N} \sum_i F_i(t) and its age is 1N∑iAi(t)\frac{1}{N} \sum_i A_i(t). Their long-run time averages are Fˉ\bar F and Aˉ\bar A. The task is to choose the rates fif_i that maximize Fˉ\bar F, or minimize Aˉ\bar A, under ∑ifi=F\sum_i f_i = F.

For one page with rate λ\lambda and refresh interval II, the copy is fresh at time t∈[0,I)t \in [0, I) after a refresh with probability e−λte^{-\lambda t}, the chance of no change in [0,t][0, t]. So the expected fraction of time it is fresh is

1I∫0Ie−λt dt=1−e−rr=:g(r),r=λI=λ/f.\frac{1}{I} \int_0^I e^{-\lambda t}\, dt = \frac{1 - e^{-r}}{r} =: g(r), \qquad r = \lambda I = \lambda / f.

If the first change after the refresh is at time s≤ts \le t, the age at time tt is t−st - s. Averaging over ss and over t∈[0,I)t \in [0, I) gives the expected time-averaged age

Aˉ=1f(12−1r+1−e−rr2)=:φ(r)f.\bar A = \frac{1}{f} \left( \frac{1}{2} - \frac{1}{r} + \frac{1 - e^{-r}}{r^2} \right) =: \frac{\varphi(r)}{f}.

Both depend on the page only through rr, the expected number of changes between two refreshes. With f=0f = 0 the page is never fresh in the long run.

Variants

  • Order of refreshes. Cho and Garcia-Molina also study random-order refresh, which refreshes each page once per cycle in a new random order, and purely random refresh, which picks the next page at random. For purely random refresh at rate ff, the copy is a two-state Markov chain that goes stale at rate λ\lambda and fresh at rate ff, so Fˉ=f/(f+λ)=1/(1+r)\bar F = f/(f + \lambda) = 1/(1 + r). Fixed order gives the highest freshness of the three, as Cho and Garcia-Molina show; this page proves only the comparison with purely random refresh, below.
  • Weights. Weigh page ii by an importance wiw_i, such as its PageRank or how often users click it, and maximize ∑iwiFˉi\sum_i w_i \bar F_i.
  • Unknown rates. The rates are not given and must be estimated from past visits, which show only whether the page changed since the last visit, not how many times.
  • Degree of change. Count a change only if it matters, for example if the page is no longer a near duplicate of the copy, or if the change affects search results.
  • Politeness. The refreshes must also respect a gap per host, so the schedule feeds a URL frontier.

Examples

Take two pages with λ1=9\lambda_1 = 9 and λ2=1\lambda_2 = 1 changes per day, and F=2F = 2 refreshes per day.

policy f1,f2f_1, f_2 freshness of page 1, 2 mean freshness mean age (days)
uniform 1, 1 0.1111, 0.6321 0.3716 0.2667
proportional 1.8, 0.2 0.1987, 0.1987 0.1987 0.9437
best for freshness 0.2359, 1.7641 0.3948
best for age 1.1514, 0.8486 0.2570

The proportional policy gives both pages r=5r = 5, so both are fresh only about a fifth of the time. The uniform policy lets page 2 stay fresh 63% of the time and loses little on page 1, which would be stale most of the time anyway. The best policy for freshness gives the fast page only about one refresh in four days, while the best policy for age gives it more refreshes than the slow page, because age punishes a copy more the longer it has been stale.

Known algorithms

Uniform allocation. Set fi=F/Nf_i = F/N. It needs no estimates of the rates and is at least as good as proportional allocation for both freshness and age (see Bounds).

Optimal allocation. For freshness, maximize ∑iFˉi(fi)\sum_i \bar F_i(f_i) with Fˉi(f)=fλi(1−e−λi/f)\bar F_i(f) = \frac{f}{\lambda_i}\left(1 - e^{-\lambda_i/f}\right), subject to ∑ifi=F\sum_i f_i = F and fi≥0f_i \ge 0. Each Fˉi\bar F_i is concave and increasing in ff, so the optimum has the same marginal gain Fˉi′(fi)=μ\bar F_i'(f_i) = \mu on every page with fi>0f_i > 0, and a page gets fi=0f_i = 0 when even its first refresh gains less than μ\mu. Find μ\mu by bisection, and each fif_i by a one-dimensional search. Cho and Garcia-Molina solve it this way and show that the optimal fif_i first grows with λi\lambda_i and then falls, so that the pages that change fastest get few refreshes or none.

Estimating the rates. A crawler that visits page ii every II days and sees a change in XX of nn visits can use λ^=−ln⁡(1−X/n)/I\hat\lambda = -\ln(1 - X/n)/I, since the chance of at least one change in an interval is 1−e−λI1 - e^{-\lambda I}. Cho and Garcia-Molina give corrected estimators for small nn and for visits at irregular times.

In practice. Crawlers sort known pages into tiers by estimated change rate and importance, and refresh each tier at its own rate. The tiers then set priorities in the frontier.

Bounds

Theorem. For all rates λ1,…,λN>0\lambda_1, \ldots, \lambda_N > 0 and budget F>0F > 0, uniform allocation gives at least the mean freshness and at most the mean age of proportional allocation fi=Fλi/∑jλjf_i = F \lambda_i / \sum_j \lambda_j. Both comparisons are strict unless all λi\lambda_i are equal.

Proof. Let fˉ=F/N\bar f = F/N, ri=λi/fˉr_i = \lambda_i / \bar f and rˉ=1N∑iri\bar r = \frac{1}{N} \sum_i r_i. Under proportional allocation, λi/fi=∑jλj/F=rˉ\lambda_i / f_i = \sum_j \lambda_j / F = \bar r for every page.

First, gg is strictly convex and φ\varphi is strictly concave on (0,∞)(0, \infty), because

g(r)=∫01e−rs ds,φ(r)=∫01(1−s)(1−e−rs)ds.g(r) = \int_0^1 e^{-rs}\, ds, \qquad \varphi(r) = \int_0^1 (1 - s)\left(1 - e^{-rs}\right) ds.

The first identity is direct integration. For the second, the age at time τ/f\tau / f after a refresh, times ff, has expectation τ−(1−e−rτ)/r=∫0τ(1−e−rs) ds\tau - (1 - e^{-r\tau})/r = \int_0^\tau (1 - e^{-rs})\, ds; its mean over τ∈[0,1]\tau \in [0, 1] is ∫01(1−s)(1−e−rs) ds\int_0^1 (1 - s)(1 - e^{-rs})\, ds, and integration confirms that this equals 12−1r+1−e−rr2\frac{1}{2} - \frac{1}{r} + \frac{1 - e^{-r}}{r^2}. Each e−rse^{-rs} with s>0s > 0 is strictly convex in rr, the weights 11 and 1−s1 - s are positive on (0,1)(0, 1), and an integral of convex functions with positive weights is convex. The second derivatives are ∫01s2e−rsds>0\int_0^1 s^2 e^{-rs} ds > 0 and −∫01(1−s)s2e−rsds<0-\int_0^1 (1 - s) s^2 e^{-rs} ds < 0.

Freshness. Uniform gives 1N∑ig(ri)\frac{1}{N} \sum_i g(r_i) and proportional gives g(rˉ)g(\bar r). By Jensen's inequality for the convex gg, 1N∑ig(ri)≥g(rˉ)\frac{1}{N} \sum_i g(r_i) \ge g(\bar r), with equality only if all rir_i are equal.

Age. Uniform gives 1N∑iφ(ri)/fˉ\frac{1}{N} \sum_i \varphi(r_i) / \bar f. Proportional gives 1N∑iφ(rˉ)/fi\frac{1}{N} \sum_i \varphi(\bar r)/f_i, and fi=λi/rˉ=fˉri/rˉf_i = \lambda_i / \bar r = \bar f r_i / \bar r, so it equals φ(rˉ)fˉ⋅rˉ⋅1N∑i1ri\frac{\varphi(\bar r)}{\bar f} \cdot \bar r \cdot \frac{1}{N} \sum_i \frac{1}{r_i}. By Jensen for the concave φ\varphi, 1N∑iφ(ri)≤φ(rˉ)\frac{1}{N} \sum_i \varphi(r_i) \le \varphi(\bar r). By the inequality of the arithmetic and harmonic means, rˉ⋅1N∑i1/ri≥1\bar r \cdot \frac{1}{N} \sum_i 1/r_i \ge 1, and φ(rˉ)>0\varphi(\bar r) > 0 because the integrand is positive. Together, the uniform age is at most the proportional age, with equality only if all rir_i are equal. □\square

Other facts. g(r)≤1g(r) \le 1 and g(r)≥1−r/2g(r) \ge 1 - r/2, so a page with rr well below 1 is almost always fresh; and g(r)<1/rg(r) < 1/r, so a page refreshed at rate ff adds less than f/λf/\lambda to the freshness sum, which is why fast pages are a poor use of the budget. Under the same constraints, fixed-order refresh gives at least the freshness of purely random refresh: g(r)≥1/(1+r)g(r) \ge 1/(1 + r) for all r>0r > 0, which is er≥1+re^{r} \ge 1 + r rearranged.

Reductions

  • The optimal allocation is a separable concave resource allocation problem: maximize a sum of concave functions of fif_i under one linear budget. Greedy allocation in small units, or a search on the common marginal gain, solves it.
  • With weights wiw_i, the same method applies with wiFˉiw_i \bar F_i in place of Fˉi\bar F_i.
  • The schedule of refresh times for given rates is a scheduling problem with a gap per host, handled by the frontier.

Applications

  • Incremental crawlers of web search engines. The revisit policy decides which known pages to fetch again, and splits the crawl budget between new and known pages.
  • Caches and replicas. The same model applies to caches that poll an origin server, to mirrors of databases, and to feeds that must be polled for new items.
  • Web archives. An archive that wants to keep many versions of each page chooses revisit rates by change rate and by how much each version is worth.

References

  1. Junghoo Cho and Hector Garcia-Molina, Effective page refresh policies for Web crawlers, ACM Transactions on Database Systems 28(4), 390-426, 2003, the definitions of freshness and age, the Poisson model of change, the time-averaged freshness and age of fixed-order, random-order and purely random refresh, the comparison of uniform and proportional allocation, and the optimal allocation
  2. Junghoo Cho and Hector Garcia-Molina, Synchronizing a database to improve freshness, Proceedings of the 2000 ACM SIGMOD International Conference on Management of Data, the first statement of the freshness and age measures and of the result that uniform allocation is better than proportional allocation
  3. Junghoo Cho and Hector Garcia-Molina, Estimating frequency of change, ACM Transactions on Internet Technology 3(3), 2003, the estimators of the change rate of a page from repeated visits that see only whether the page changed
  4. Christopher Olston and Marc Najork, Web crawling, Foundations and Trends in Information Retrieval 4(3), 175-246, 2010, the chapter on revisiting pages for freshness, which surveys the Poisson model, the policies and later work on weighting by importance and content change

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a known algorithm
  • a contract.yaml