As we've discussed in T269581: Add Link engineering: Allow external traffic to linkrecommendation service, T277297: 504 timeout and 503 errors when accessing linkrecommendation service and related patches, generating link recommendations is slow. This is not as big of a problem for the internal consumer of the service (refreshLinkRecommendations.php) but it's not great for the external traffic release. We've hacked around that some by lengthening the timeout for the service (potentially problematic) and returning all possible results within a timeout period.
Another idea would be to query the GrowthExperiments cache for the relevant article link recommendations before (re)generating link recommendations for the article.
The workflow would be:
- GET request is made to https://api.wikimedia.org/service/linkrecommendation/v1/linkrecommendations/wikipedia/cs/Lipsko
- the application does a GET request to https://cs.wikipedia.org/w/rest.php/growthexperiments/v0/suggestions/addlink/Lipsko
- if results are found, it returns that
- if not, does the expensive link recommendation generation
For larger wikis, there would be mostly cache misses but for smaller wikis there'd be a higher cache hit-to-miss ratio (our initial task pool size will be 25,000 articles per wiki).