Skip to content

Add limit parameter to paginated actions - #109

Open
pavog wants to merge 1 commit into
SpigotMC:masterfrom
pavog:add-limit-parameter
Open

pavog wants to merge 1 commit into
SpigotMC:masterfrom
pavog:add-limit-parameter

Conversation

@pavog

@pavog pavog commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

All paginated actions return 10 results per page.
Listing all ~92k resources takes ~9,2k requests, and every request has fixed costs (TLS, PHP, database connection, queries).

This PR adds an optional parameter limit to the endpoints:

  • listResources
  • getResourcesByAuthor
  • getResourceUpdates

Without it, a page still has 10 results, so existing clients get the same responses. The maximum is 100.

Please note:

  • Values above 100 are treated as 100, and invalid values as 10.
    That is how page already behaves: an invalid page falls back to 1 instead of returning an error.
    README and openapi.yaml state the maximum.
  • 100 as the maximum, because larger pages do not reduce the load further.
    I measured limits from 10 to 1,000 with all four PRs applied:
limit requests to list all resources requests for all updates of all resources response size PHP memory resources per sec with 8 crawlers
10 9,214 126,285 0.05 MB 0.8 MB 34,100
25 3,686 101,305 0.12 MB 1.1 MB 54,600
50 1,843 95,110 0.25 MB 1.8 MB 64,400
100 922 92,960 0.55 MB 3.3 MB 66,700
250 369 92,249 1.45 MB 7.6 MB 69,400
500 185 92,151 3.01 MB 15.1 MB 64,400
1,000 93 92,138 6.28 MB 30.5 MB 58,200

Beyond 100, the throughput stays the same and then drops, while memory, response size and the delay of other requests keep growing. For updates, a larger page hardly saves requests, because more than half of the resources have no updates.

Not covered here:

Benchmark

Setup: Tables of XenForo 1.5.24 and Resource Manager 1.1.2, MySQL 8.0.32, PHP 7.0.33, data the size of SpigotMC, median of three rounds. The client sends limit=100.

Scenario master this PR
All updates of 300 random resources 421 requests, 69.4 s database time 302 requests, 29.8 s
All updates of a resource with 1,001 updates 99 requests, 29.8 s 10 requests, 3.0 s
First 1,000 resources 100 requests, 128.8 ms 10 requests, 47.2 ms
1,000 resources after offset 90,000 100 requests, 23.4 s 10 requests, 2.5 s

Changes

  • add parameter limit to listResources, getResourcesByAuthor and getResourceUpdates
  • limit pages to at most 100 results
  • document limit in the README and in openapi.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant