mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
perf: batch NIO dispatch on project open (one HTTP per compute)
Project open used to create each link by issuing two NIO POSTs from the
controller to the compute — ~5000 HTTP round-trips for a 2500-link
topology, all funnelling through the single shared controller/compute
event loop and capping throughput near 12 links/s.
Replace it with a bulk path:
- UDPLink split into _prepare() (local: ports, peer addrs, link_data)
and _commit_nios() (dispatch). create() = prepare + commit (interactive).
- Link.add_node gains batch=True: attach both nodes without triggering
per-link NIO HTTP.
- compute: new POST /projects/{id}/nios/batch endpoint with a unified
_add_nio_binding dispatch across node types (docker/qemu/iou/vpcs/
builtin differ in signature).
- project.open: prepare all links locally, group NIO entries by compute,
send each compute a single /nios/batch, then finalise (wire node/port
refs, mark created, notify, apply marker defs) in parallel.
Cuts controller->compute HTTP from O(links) to O(computes). Test added
for the batch endpoint.
This commit is contained in:
7 files changed
+280
-29
No files matched your search
@@ -211,6 +211,34 @@ class TestDockerNodesRoutes:
|
||||
assert response.status_code == status.HTTP_201_CREATED
|
||||
assert response.json()["type"] == "nio_udp"
|
||||
|
||||
async def test_docker_nio_batch_create(self, app: FastAPI, compute_client: AsyncClient, vm: dict) -> None:
|
||||
"""
|
||||
Exercise the project-wide batch NIO endpoint: bind two NIOs on the same
|
||||
docker node in a single request (the path used during project open).
|
||||
"""
|
||||
|
||||
params = {
|
||||
"nios": [
|
||||
{
|
||||
"node_id": vm["node_id"],
|
||||
"adapter_number": 0,
|
||||
"port_number": 0,
|
||||
"nio": {"type": "nio_udp", "lport": 4242, "rport": 4343, "rhost": "127.0.0.1"},
|
||||
},
|
||||
{
|
||||
"node_id": vm["node_id"],
|
||||
"adapter_number": 1,
|
||||
"port_number": 0,
|
||||
"nio": {"type": "nio_udp", "lport": 4243, "rport": 4344, "rhost": "127.0.0.1"},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
url = app.url_path_for("compute:create_batch_nios", project_id=vm["project_id"])
|
||||
response = await compute_client.post(url, json=params)
|
||||
assert response.status_code == status.HTTP_201_CREATED
|
||||
assert response.json()["added"] == 2
|
||||
|
||||
|
||||
async def test_docker_update_nio(self, app: FastAPI, compute_client: AsyncClient, vm: dict) -> None:
|
||||
|
||||
|
||||
Reference in new issue
Block a user