Heuristic:AKSW RDFUnit Endpoint Rate Limiting
| Knowledge Sources | |
|---|---|
| Domains | Optimization, SPARQL_Endpoint, Resilience |
| Last Updated | 2026-10-16 00:00 GMT |
Overview
SPARQL endpoint queries are rate-limited with configurable TTL caching, query delays, pagination, and result limits to avoid overwhelming remote endpoints.
Description
When RDFUnit validates data from a remote SPARQL endpoint (via `EndpointTestSource`), it applies a `QueryingConfig` with four rate-limiting parameters:
- Cache TTL: Time-to-live for cached query results. Default = 1 week (7 × 24 × 60 × 60 × 1000 ms). Avoids re-querying for unchanged data.
- Query Delay: Delay between consecutive queries. Default = 5 seconds. Prevents rapid-fire requests that could trigger endpoint rate limits or bans.
- Pagination: Number of results per page. Default = 800 records. Controls memory usage for large result sets.
- Query Limit: Maximum number of results returned. Default = pagination - 1 (799). Slightly below pagination to detect overflow.
For in-memory sources (`createInMemory()`), all parameters are set to 0 since there is no network overhead. The `RDFUnitConfiguration` class allows overriding these defaults via `setEndpointQueryDelayMS()`, `setEndpointQueryCacheTTL()`, `setEndpointQueryPagination()`, and `setEndpointQueryLimit()`.
Usage
Use this heuristic when validating against remote SPARQL endpoints. The defaults are conservative (5-second delay, 800-record pagination) to protect public endpoints. For private or high-capacity endpoints, increase pagination and decrease delay. For rate-limited public endpoints (e.g., DBpedia), keep defaults or increase delay.
The Insight (Rule of Thumb)
- Action: Use `QueryingConfig.createEndpoint()` for endpoint sources (applies defaults); override via `RDFUnitConfiguration` setters if needed.
- Value: Defaults: cacheTTL=1 week, queryDelay=5s, pagination=800, limit=799.
- Trade-off: Conservative defaults are safe but slow; aggressive values risk endpoint bans or incomplete results.
- Compatibility: In-memory sources use all-zero config via `createInMemory()`.
Reasoning
Public SPARQL endpoints (e.g., DBpedia, Wikidata) often have rate limits and may ban clients that send too many requests too quickly. The 5-second delay between queries is a safe default that most public endpoints tolerate. Pagination at 800 records balances memory usage (loading results in batches) against the number of HTTP requests needed. The query limit of 799 (one less than pagination) allows detecting whether more results exist that were truncated. The 1-week cache TTL leverages the fact that RDF datasets change infrequently, making repeated validation runs much faster.
Code Evidence
Default configuration from `QueryingConfig.java:16-31`:
/**
* cache time to live (in ms), set to 1 week by default for endpoints
*/
private static final long CACHE_TTL = 7L * 24L * 60L * 60L * 1000L;
/**
* Pagination for big results, set to 800 records by default for endpoints
*/
private static final long PAGINATION = 800;
/**
* Delay between queries in a SPARQL Endpoint, set to 5 seconds by default for endpoints
*/
private static final long QUERY_DELAY = 5L * 1000L;
/**
* Pose a limit on the returned results. Limit to pagination by default for endpoints
*/
private static final long QUERY_LIMIT = PAGINATION - 1;
Factory methods from `QueryingConfig.java:55-61`:
public static QueryingConfig createEndpoint() {
return create();
}
public static QueryingConfig createInMemory() {
return new QueryingConfig(0, 0, 0, 0);
}
Override via configuration from `RDFUnitConfiguration.java:206-220`:
if (this.endpointQueryCacheTTL >= 0) {
testSourceBuilder.setCacheTTL(this.endpointQueryCacheTTL);
}
if (this.endpointQueryDelayMS >= 0) {
testSourceBuilder.setQueryDelay(this.endpointQueryDelayMS);
}
if (this.endpointQueryPagination >= 0) {
testSourceBuilder.setPagination(this.endpointQueryPagination);
}
if (this.endpointQueryLimit >= 0) {
testSourceBuilder.setQueryLimit(this.endpointQueryLimit);
}