log-file-analysis-crawl-budget-large-sites.html
< BACK 光线昏暗的服务器机房走廊,琥珀色照明和排列整齐的黑色服务器机架

50,000页网站的爬虫预算日志文件分析

早在 2021 年,我接手了一个客户——一个位于伯明翰的电商零售商,大约有 52,000 个已索引的 URL——他们搞不明白为什么大约 18,000 个产品页面在三个多月内没有被爬取过。他们的开发团队一直在猜测。添加 XML 地图。在 Google Search Console 中 Ping。什么都没有效果。然后我查看了他们的原始服务器日志,大约四十分钟内答案就变得完全显而易见了:Googlebot 在分页过滤 URL、会话参数和一个损坏的内部搜索 facet 上耗尽了每日爬取配额,这个 facet 每周生成大约 4,000 个唯一但毫无价值的 URL。完全浪费。彻底的废话。

关键要点:服务器日志准确显示 Googlebot 在 50,000 页网站上实际读取的页面;日志分析是爬取预算决策的唯一真实来源。Server logs show exactly which pages Googlebot actually reads on a 50,000-page site; log analysis is the only ground truth for crawl-budget decisions.

这才是日志文件分析的真正用途——不是虚荣指标,不是董事会演讲稿,而是找出爬虫在任何一个星期二在你的网站上做什么,并无情地削减浪费。

为什么爬虫预算在大规模上真正重要

大多数人搞错的地方在这里。爬取预算对于 200 页的宣传网站不是问题。Googlebot 几分钟就能扫完。但一旦你超过了大约 20,000 个 URL——尤其是当你有 50,000 个或更多时——Google 的爬虫会做出明确的优先级决定。Google 自己的文档把这叫做"爬取预算",并将其分为两个组件:爬取速率限制(Googlebot 在不给服务器造成压力的情况下爬取的速度)和爬取需求(Google 根据热度和新鲜度信号实际想要爬取的量)。Google's own documentation calls this "crawl budget" and breaks it down into two components: crawl rate limit (how fast Googlebot crawls without hammering your server) and crawl demand (how much Google actually wants to crawl based on popularity and freshness signals).

这两个都可以被操纵。但你无法操纵你无法衡量的东西。而且你无法在没有日志的情况下正确衡量它。

Google Search Console这样的分析工具会给你一份抓取统计报告。作为起点还不错。但它是汇总的、延迟的,而且它不会告诉你哪些特定的网址在消耗预算。服务器日志会。它们显示Googlebot发出的每一个请求、请求的网址、请求的时间,以及它收到的HTTP状态码。那是原始材料。which specific URLs are eating the budget. Server logs do. They show you every single request Googlebot made, to which URL, at what time, and what HTTP status code it received back. That's the raw material.

获取日志

这听起来很明显,但大多数人在这里就卡住了。取决于你的托管设置,日志的位置各不相同。

在像 WP Engine 或 Kinsta 这样的托管 WordPress 主机上,你可以从仪表板或通过 SFTP 拉取原始访问日志——查看 /logs/ 目录。在运行 Nginx 的 VPS 上,访问日志通常位于 /var/log/nginx/access.log。Apache 将其放在 /var/log/apache2/access.log。如果你使用像 Cloudflare 这样的 CDN,你需要 Cloudflare Logpush(企业级)或者你只会看到 CDN 边缘请求,而不是源站——这是个重要的区别。WordPress host like WP Engine or Kinsta, you can pull raw access logs from the dashboard or via SFTP -- look in the/logs/directory. On a VPS running Nginx, your access log is typically at/var/log/nginx/access.log. Apache puts it at/var/log/apache2/access.log. If you're on a CDN like Cloudflare, you'll need Cloudflare Logpush (enterprise tier) or you'll only see CDN-edge requests, not origin -- important distinction.

对于那个伯明翰的客户端,他们使用的是Kinsta托管服务器。我提取了30天的日志,压缩后约为4.2GB的.gz文件。这对于一个繁忙的50K页面网站来说是正常的大小。.gz files. That's a normal size for a busy 50K-page site.

解析原始日志而不崩溃

你这里有两个真正的选择:

  1. Screaming Frog Log File Analyser——这是我 90% 的时间使用的工具。你直接导入日志文件,按 Googlebot user agent 过滤,它会给你一个可排序的爬取 URL 细分、爬取频率、状态码和响应时间的列表。老实说,对于大多数代理工作,这是正确的工具。Screaming Frog 的日志分析器能处理数 GB 的文件而不崩溃,这很重要。 -- This is what I use 90% of the time. You import the log files directly, filter by Googlebot user agent, and it gives you a sortable breakdown of crawled URLs, crawl frequency, status codes, and response times. Honestly, for most agency work it's the right tool.Screaming Frog's log analyser handles files up to several GB without falling over, which matters.
  2. ELK Stack(Elasticsearch、Logstash、Kibana)——更多设置,明显更强大的功能。如果你需要为大客户或企业合同进行持续监控,这值得投资。Seahawk 有几个客户把日志直接送入 Kibana 仪表板。实时的、漂亮的,而且你可以在 Googlebot 爬取频率突然下降时设置警报。 -- More setup, significantly more power. If you've got ongoing monitoring needs for a large client or an enterprise contract, this is worth the investment. Seahawk has a couple of clients where we pipe logs directly into a Kibana dashboard. Real-time, beautiful, and you can set alerts when Googlebot crawl frequency drops suddenly.

对于一次性审计,Screaming Frog Log File Analyser 就可以。对于任何持续性工作,构建 ELK stack 或至少考虑 GoAccess——它是开源的,在终端中运行,处理大日志文件的速度比我测试过的几乎任何其他工具都快。GoAccess -- it's open source, runs in the terminal, and processes large log files faster than almost anything else I've tested.

实际上应该关注什么

数据加载好后,大多数人盯着看却不知道该问什么问题。这是我在日志审计中实际关注的内容:

抓取频率分布

按爬取频率对你的 URL 进行排序——Googlebot 在 30 天窗口内点击每个 URL 的次数。你几乎总是会找到双峰分布。一组重要 URL 被频繁爬取(好的)和一条垃圾 URL 的长尾也被频繁爬取(非常不好)。那条垃圾尾巴就是你的问题。

在那个伯明翰网站上,排名前500的已抓取网址中有340个是筛选/多面体组合。它们都没有被索引。它们都没有任何搜索量。Googlebot访问?colour=red&size=M&sort=price_asc的频率比访问实际分类页面的频率还要高。太疯狂了。?colour=red&size=M&sort=price_asc more often than it was visiting the actual category pages. Wild.

状态码分解

筛选出所有不是200的内容。具体来说:

  • 404被重复爬取——这是爬虫预算的严重浪费。用301重定向修复,或者修正指向它们的内部链接。 -- These are a crawl budget haemorrhage. Fix them with 301 redirects or patch the internal links that point to them.
  • 301重定向链——A → B → C这样的重定向链是两次无谓的跳转。Googlebot会跟随它们,但每次跳转都消耗预算,PageRank也会流失。 -- A redirect that goes A → B → C is two wasted hops. Googlebot follows them but it costs budget and PageRank leaks at each jump.
  • 500错误——如果Googlebot访问返回500的页面后进行重试,你既在浪费爬虫预算,又在长期损害Google对你网站可爬性的评分。 -- If Googlebot is hitting pages that return 500s and then retrying them, you're wasting budget AND damaging your crawlability score with Google over time.
  • 304 Not Modified——实际上没问题。说明Google在检查更新,你的缓存头工作正常。 -- Actually fine. Means Google is checking freshness and your caching headers are working correctly.

响应时间尖峰

Google公开表示服务器响应速度慢会导致Googlebot爬取不那么积极。如果你的日志显示爬取URL的平均响应时间超过500ms——特别是分类页或产品页——那就是优化服务器端缓存的信号,这应该是首要任务。 that slow server response times cause Googlebot to crawl less aggressively. If your logs show average response times above 500ms for crawled URLs -- particularly category or product pages -- that's a signal to fix your server-side caching before anything else.

识别预算杀手

我来给你列出在大型网站上我常看到的吃掉爬取预算的东西,大致按我遇到它们的频率排列:

  1. 没有noindex或disallow的分面导航——筛选器、颜色选择器、尺寸选择器、排序选项。这些会几何级增加你的URL数量。一个有10个筛选选项和5种排序方式的产品分类会生成50多个URL变体。在一个5万页的网站上,这可能会产生数十万个URL。 -- Filters, colour pickers, size selectors, sort orders. These multiply your URL count geometrically. A product category with 10 filter options and 5 sort orders generates 50+ duplicate URL variants. Across a 50K-page site, that's potentially hundreds of thousands of URLs.
  2. 无限爬取的分页归档——/page/2、/page/3...../page/847。如果你博客归档的第200页内容在有机搜索中没有任何价值,你需要要么noindex它,要么在robots.txt中disallow分页路径。 -- /page/2,/page/3.../page/847. If the content on page 200 of your blog archive has zero organic search value, you need to either noindex it or disallow the pagination path in robots.txt.
  3. URL中的会话ID——旧版CMS平台(以及某些遗留的WooCommerce设置)会在URL后附加会话令牌,如?sessionid=abc123def456。每个会话都生成一个独特的URL。Googlebot会爬取所有这些URL。这是旧网站上的灾难级预算浪费。 -- Old CMS platforms (and some legacy WooCommerce setups) append session tokens like?sessionid=abc123def456 to URLs. Every session generates a unique URL. Googlebot crawls all of them. This is a catastrophic budget leak on older sites.
  4. 通过URL参数产生的重复内容——内部链接中的?utm_source=email、泄漏到可爬取URL中的追踪参数、附属插件附加的?ref=homepage。在Google Search Console的URL参数工具中修复,并在HTML级别进行规范化。 -- ?utm_source=email in internal links, tracking parameters leaking into crawlable URLs,?ref=homepage appended by affiliate plugins. Fix in Google Search Console's URL parameter tool and canonicalise at the HTML level.
  5. 孤立页面没有内部链接但仍在sitemap中——Googlebot通过sitemap找到它们并爬取,但找不到内部信号就会降低优先级。不过它们仍然会在发现爬取中消耗预算。 -- Googlebot finds them via sitemap, crawls them, finds no internal signal, deprioritises them over time. But they still eat budget on discovery crawls.
  6. Soft 404页面返回200状态——无搜索结果的搜索页面、空的分类页面、已删除账户的用户资料页面。Google浪费时间抓取这些页面,有时还会索引它们。 -- Search pages with no results, empty category pages, user profile pages for deleted accounts. Google wastes time crawling these and sometimes indexes them.

修复你发现的问题

说实话,分析部分比较简单。真正的难点在实施阶段,这时项目往往会变得很复杂。

这是我完成日志审计后需要提交建议时的实际工作流程:

  • 在Robots.txt中Disallow不应被抓取的URL模式——会话参数、过滤器组合、内部搜索结果URL。我使用Disallow: /*?sessionid=*这样的通配符规则。在部署前,在Google Search Console的robots.txt测试工具中测试每条规则。 for URL patterns that should never be crawled -- session parameters, filter combinations, internal search result URLs. I use Disallow: /*?sessionid=style wildcard rules. Test every rule in Google Search Console's robots.txt tester before deploying.
  • 在第2或3页之后的分页页面上使用noindex + nofollow,具体取决于内容的新鲜度。不要完全禁止分页,否则你会破坏Googlebot发现链接内容的能力。 on paginated pages beyond page 2 or 3, depending on content freshness. Don't disallow pagination entirely or you break Googlebot's ability to discover linked content.
  • 在所有参数化URL变体上使用规范标签,指向干净的规范URL。这与robots.txt一起构成了双重保障。 on all parameterised URL variants pointing to the clean canonical URL. This is belt-and-braces alongside robots.txt.
  • 在源头修复404——要么更新内部链接,要么实施301重定向。我使用Screaming Frog的主爬虫结合日志数据来找出哪些页面链接到已失效的URL。 -- Either update the internal links or implement 301 redirects. I use Screaming Frog's main crawler alongside the log data to find which pages are linking to dead URLs.
  • XML Sitemap卫生——从你的sitemap中删除任何返回非200状态、被noindexed或是重定向的URL。你的sitemap应该是一份精选列表,只包含你想被索引的页面。 -- Remove any URL from your sitemap that returns a non-200, is noindexed, or is a redirect. Your sitemap should be a curated list of pages you want indexed, nothing else.

Seahawk去年有一个金融科技客户——大约65,000个页面,主要是动态内容——仅仅通过修复robots.txt来阻止内部搜索URL模式,就在六周内将Googlebot对垃圾URL的抓取减少了61%。剩余的39%抓取预算转移到产品和分类页面。新内容的索引速度从平均23天下降到6天。这就是真实的影响。

设置持续监控

一次日志审计是一个快照。良好的抓取预算管理是持续进行的。这在实际操作中究竟是什么样子呢?

对于超过30,000个页面的网站,我至少建议每月拉取和解析日志。查看你排名前100的收入驱动URL的抓取频率趋势。如果Googlebot访问这些页面的频率在下降,说明有些东西改变了——新的抓取预算泄漏、服务器性能问题或PageRank信号下降。

如果你想做得更精细一些,可以设置GoAccess作为一个cron任务来处理每日日志快照,并通过邮件发送摘要报告。配置大约需要两个小时,可以让你不会在季度审计之间的缓慢抓取预算流失过程中掉以轻心。

常见问题

如果我已经被完全索引了,抓取预算还重要吗?

有点是。今天完全索引并不意味着它会一直保持这样。如果你经常发布新内容——新产品、新博客文章、新着陆页——抓取预算决定了新内容被发现的速度。一个有抓取预算泄漏的网站可能会有新页面数周未被检查。如果你在一个快速发展的细分领域,这是真正的竞争劣势。

我应该使用robots.txt来完全阻止Googlebot访问某些子文件夹吗?

在特定情况下是的。管理员区域、测试路径、内部搜索结果和参数繁重的过滤URL都是合理的Disallow规则候选。我要提醒的一件事是不要阻止JavaScript或CSS文件——Googlebot需要这些文件来正确呈现你的页面。很多老的SEO建议说要阻止JS;忽视它。

我应该分析多少日志数据?

30天对大多数网站来说是理想时间段。少于这个时间,你看不到低频爬取模式。超过这个时间,文件大小会变得难以管理,除非你运行的是完整的ELK堆栈。对于季节性电商网站,我有时会查看跨越高峰期的60天数据,以便理解流量负载下的爬取行为。

如果我的主机商不提供原始访问日志怎么办?

对你的托管提供商施压——大多数托管主机都提供此功能,即使它在仪表板中没有突出显示。如果你真的无法获得原始日志,Cloudflare的bot分析可以为在Cloudflare代理后的网站提供部分信息,尽管这是真实日志数据的不完美替代品。如果这是大客户账户上的经常性障碍,考虑更换主机商。Cloudflare's bot analytics can give you a partial picture for sites behind the Cloudflare proxy, though it's a pale substitute for real log data. Consider switching hosts if this is a recurring blocker on a large client account.

Google Search Console的爬取统计数据足够吗?

对于小型网站,可以说是的。对于任何超过20K页面的网站,不行。GSC抓取统计数据按天汇总,不显示URL级别的数据。你可以看到Googlebot在周二抓取了12,000个页面,但看不到具体是哪12,000个页面。日志文件给你那样的分辨率。两个工具一起使用——那才是完整的图景。which 12,000 pages. Log files give you that resolution. Both tools together -- that's the complete picture.

---

看,大多数SEO专家跳过日志文件分析,因为这感觉像是DevOps的领地。这不够光鲜。你需要查阅数以千兆计的时间戳和user-agent字符串。但在大型网站上,这是在猜测你的爬取预算花在哪儿和真正知道它花在哪儿之间的区别。根据我的经验,知道真相总是值得花那两个小时去整理数据的。

< BACK