Handling of crawler throttling

AI-generated summary

The discussion revolves around the handling of crawler throttling in Discourse. vchuravy pointed out that Discourse throttling is implemented by throwing an error, which returns a generic 505 Internal Server Error, instead of the recommended HTTP 429 (Too many requests) or 503 (Site unavailable) status code. This has caused issues with Google Search Console, which reports 5xx errors and drastically reduced indexing and impressions. Falco clarified that the error is rescued by a global controller, which sets the status code. However, vchuravy and vchuravy further explained that Google Search Console still reports 5xx errors, even for the sitemap.xml file, which is problematic and likely caused a gap in coverage.

I had a general question how crawler throttling is implemented.

According to Reduce Google Crawl Rate | Google Crawling Infrastructure  |  Crawling infrastructure  |  Google for Developers the recommended HTTP status is 429 (Too many requests) or 503 (Site unavailable).

But reading through the source code it looks like throttling is implemented by
throwing an error: discourse/lib/rate_limiter.rb at 85fddf58bc1e751d0ac5b8192a630c59a34aed7d · discourse/discourse · GitHub

My Ruby on Rails days are long behind me, but I am assuming that this raises a generic 505?

The Google crawler doesn’t quite understand discourse’s throttling and in Google Search Console I can see that our indexing and therefore impressions drastically reduced after throttling was implemented, but not due to throttling, but due to 5xx server errors.

I understand that throttling instances may be sometimes necessary if they cause to much traffic, but I was expecting that discourse reports a HTTP 429, instead of serving the crawler a 505 Internal Error.

I think what you looking for is

Which is the “global” controller rescue for that error that sets the status code.

Thanks! That’s reassuring, but doesn’t quite explain why Google Search Console is reporting 5xx errors that correlate with the moment throttling was implemented.

It even reports that it couldn’t fetch the discourse sitemap.xml

In particular throttling the sitemap.xml seems problematic.

I assume that’s what caused the gap in coverage. I could believe Google misreporting 429 as 5xx.