Python vs. Go Subdomain Enumeration & DNS

Concurrency plays a pivotal role in the performance of subdomain enumeration, particularly when dealing with a large number of DNS resolutions. In this article, we will explore the concurrency models of Python and Go and delve into the theoretical limits on the maximum number of DNS resolvers that could be queried simultaneously in each language.

Concurrency Models

Python and Go approach concurrency differently, and understanding their respective models is crucial when evaluating their effectiveness in subdomain enumeration tasks.

Python’s Concurrency Model:

Python‘s Global Interpreter Lock (GIL) can pose challenges for true parallelism. While Python supports asynchronous programming through libraries like asyncio, achieving true parallelism may require multiprocessing. Let’s examine a simplified example using asynchronous programming:

import asyncio
import aiohttp

async def resolve_subdomain(subdomain):
    async with aiohttp.ClientSession() as session:
        async with session.get(f'https://{subdomain}') as response:
            return await response.text()

async def enumerate_subdomains(subdomains):
    tasks = [resolve_subdomain(subdomain) for subdomain in subdomains]
    return await asyncio.gather(*tasks)

if __name__ == "__main__":
    target_subdomains = ["", "", ...]
    results =

Go’s Concurrency Model:

Go’s concurrency model, built around goroutines and channels, allows for efficient parallelism. Goroutines are lightweight threads, and channels facilitate communication between them. Below is a simplified example in Go:

package main

import (

func resolveSubdomain(subdomain string, wg *sync.WaitGroup, results chan string) {
    defer wg.Done()

    resp, err := http.Get("https://" + subdomain)
    if err == nil {
        results <- subdomain

func enumerateSubdomains(subdomains []string) {
    var wg sync.WaitGroup
    results := make(chan string, len(subdomains))

    for _, subdomain := range subdomains {
        go resolveSubdomain(subdomain, &wg, results)


    for result := range results {

func main() {
    targetSubdomains := []string{"", "", ...}

Theoretical Limits on DNS Resolvers

In the context of subdomain enumeration, the theoretical limit on the number of DNS resolvers that could be queried simultaneously depends on factors such as network bandwidth, DNS server responsiveness, and the underlying infrastructure. However, we can discuss the concurrent capabilities of each language.

Python’s Theoretical Limits:

  1. Asynchronous Programming: Python’s asyncio allows for asynchronous programming, enabling concurrent DNS resolution. However, the Global Interpreter Lock (GIL) may limit true parallelism, and performance gains may be more noticeable in I/O-bound tasks than CPU-bound tasks.
  2. Multiprocessing: Python can leverage multiprocessing for parallelism, but the overhead of creating multiple processes and inter-process communication may limit the maximum number of simultaneous DNS resolvers.

Go’s Theoretical Limits:

  1. Goroutines and Channels: Go’s goroutines and channels facilitate efficient concurrent DNS resolution. The lightweight nature of goroutines allows for the creation of a large number of concurrent resolvers without significant overhead.
  2. Concurrency Control: Go’s native support for concurrency control allows for fine-grained management of simultaneous DNS resolvers. The language’s efficiency in handling concurrent tasks makes it well-suited for scenarios with a high number of parallel DNS resolution requests.


In subdomain enumeration, the choice between Python and Go should consider their concurrency models and theoretical limits on the number of DNS resolvers that could be queried simultaneously.

  • For Python:
  • Asynchronous programming with asyncio is suitable for I/O-bound tasks.
  • Multiprocessing can be employed for parallelism but with potential overhead.
  • For Go:
  • Goroutines and channels provide efficient and scalable parallelism.
  • Go’s concurrency control allows for the management of a large number of simultaneous DNS resolvers.

When scalability and concurrency are paramount, Go’s native support for concurrent programming makes it a strong candidate for subdomain enumeration tasks, especially those involving a substantial number of DNS resolutions. Python’s strengths lie in its readability and extensive ecosystem, but for scenarios requiring intensive parallelism, Go’s concurrency model shines. Theoretical limits aside, real-world testing on specific infrastructures is recommended to determine the optimal choice based on the unique requirements of each subdomain enumeration task.


Leave a Reply

Your email address will not be published. Required fields are marked *