perf(agentgateway): parallelize MCP fragment and A2A agent card fetching - #334
Open
cassiofariasmachado wants to merge 6 commits into
Open
cassiofariasmachado wants to merge 6 commits into
cassiofariasmachado wants to merge 6 commits into
Conversation
…current MCP tool and agent card fetching
Contributor
|
Missing user-guide and version update |
NicoleMGomes
approved these changes
Sep 15, 2026
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
get_mcp_tools_lobandget_agent_cards_lobpreviously fetched each fragment sequentially withawaitinside aforloop. With N fragments each taking 3–4 s, total load time scaled as O(N × latency) — ~95 s for 22 fragments.This PR replaces both sequential loops with
asyncio.gather(return_exceptions=True), fetching all fragments concurrently. Wall-clock time drops to the latency of the single slowest fragment (~4 s regardless of fragment count).Changes:
get_mcp_tools_lob: two-pass approach — validate URLs into apendinglist up front, thenasyncio.gatherover all of them. Usesisinstance(result, BaseException)(notException) to correctly catchCancelledErrorand otherBaseExceptionsubclasses returned bygather(return_exceptions=True). The final log now reportslen(pending)(fragments that had a valid URL) rather thanlen(fragments)(all fragments including URL-less ones). Timing is logged:Loaded N MCP tool(s) from M fragment(s) in X.XXs.get_agent_cards_lob: same pattern applied — was missed by prior art (issue Parallelize fragment connections inside list_mcp_tools so all fragments are handled concurrently #301 / PR perf(agentgateway): parallelize LoB MCP tool listing across fragments #322).pending_cardscollects(fragment_name, url, ord_id)tuples;asyncio.gatherfetches all concurrently; errors are isolated per-fragment.Related Issue
Closes #301
Type of Change
How to Test
New tests verify:
test_fragments_fetched_concurrently) — usesasyncio.sleepto confirm all N tasks start before any finishChecklist
Additional Notes
PR #322 addressed
get_mcp_tools_lobonly. This PR also fixesget_agent_cards_lobwith the same pattern, and adds a timing log line to make the improvement observable in production logs.