HTTP.jl async is slow compared to python+aiohttp

Most of the literature on async vs multithreading isn’t applicable to Julia (or Go or the most recent version of Java). These languages have a feature called tasks (also known as green-threads in some of the research) which allow the language to use dramatically more threads than you have cores. For example,

function fib(n)
    n<1 && return 1
    t1 = Threads.@spawn fib(n-1)
    t2 = Threads.@spawn fib(n-2)
    return fetch(t1)+fetch(t2)
end
fib(30)

will spawn 2 million tasks and finish in 3 seconds.

2 Likes