# CD is slow The pages are slow and some are broken. We found out that there are quite a full network calls using DNS - and DNS was slow. The configured DNS server was not responding. Using Google's DNS made things go fast again. We will probably introduce dnsmasq in the container to make things even faster. # Tags * type: bug * status: in progress * priority: high * assigned: pjotrp * interested: pjotrp, bonfacem * keywords: deployment, server # Tasks * [ ] Use dnsmasq caching - it is a guix system service * [ ] Run less gunicorn processes on CD (2 should do) * [ ] Increase debugging output for GN2 * [ ] Fix GN3 hook for github (it is not working) * [X] gn-guile lacks certificates it can use for sparql # Measuring bonfacekilz: I'm currently instrumenting the requests. See what hogs up time. Loading the landing page takes up 32 seconds! Something's off. From outside the container: ``` 123bonfacem@tux02 ~ $ guix shell python-wrapper python-requests -- python time.py Status: 200 Time taken: 32.989222288131714 seconds ``` From inside the container: ``` 12025-07-18 14:46:36 INFO:gn2.wqflask:Landing page rendered in 8.12 seconds ``` And I see: ## CD ``` > curl -w @- -o /dev/null -s https://cd.genenetwork.org < curl -w @- -o /dev/null -s https://genenetwork.org < curl -w @- -o /dev/null -s http://localhost:9092 < /issues/CI-CD/profiling-flask ## Results/Interpretation * By fixing gn-guile and gene-alias resolution, times dropped by ~10s. However, the page takes 37.9s to run. * Resolving a DNS takes around 4.585s. We make 7 requests. Totalling to 32.09. Typically, a traits page should take 8.79s. The difference: (- 37.9 32.09) = 5.8s; which explains the slowness: ``` ncall tottime percall cumtime percall filename:lineno(function) ---------------------------------------------------------------------------- 7 0.00002618 3.741e-05 32.09 4.585 socket.py:938(getaddrinfo) ``` * The above is consistent all the analysis I've done across all the profile dumps. * Testing my theory out: ``` @app.route("/test-network") def test_network(): start = time.time() http_url = urljoin( current_app.config["GN_SERVER_URL"], "version" ) result = requests.get(http_url) duration = time.time() - start app.logger.error(f"{http_url}: {duration:.4f}s") start = time.time() local_url = "http://localhost:9093/api/version" result = requests.get(local_url) duration = time.time() - start app.logger.error(f"{local_url}: {duration:.4f}s") return result.json() ``` * Results: ``` 2025-07-24 10:20:43 [2025-07-24 10:20:43 +0000] [101] [ERROR] https://cd.genenetwork.org/api3/version: 8.1647s 2025-07-24 10:20:43 ERROR:gn2.wqflask:https://cd.genenetwork.org/api3/version: 8.1647s 2025-07-24 10:20:43 [2025-07-24 10:20:43 +0000] [101] [ERROR] result: 1.0 2025-07-24 10:20:43 ERROR:gn2.wqflask:result: 1.0 2025-07-24 10:20:43 [2025-07-24 10:20:43 +0000] [101] [ERROR] http://localhost:9093/api/version: 0.0088s 2025-07-24 10:20:43 ERROR:gn2.wqflask:http://localhost:9093/api/version: 0.0088s 2025-07-24 10:20:43 [2025-07-24 10:20:43 +0000] [101] [ERROR] result: 1.0 ``` ## Possible Mitigations * Switch over gn-auth.genenetwork.org to localhost.