HTTP.jl
HTTP.jl copied to clipboard
Performance degradation vs curl in Julia API
Hi everyone, thanks for your effort in developing this package
Exploring the Oxygen package to build APIs, it is based on your package, I found this:
I run this API locally and I reach about 560 RPS (ab -n1000 -c100 'http://localhost:8001/model')
using Oxygen
@get "/model" function()
sleep(0.15)
return json("ok")
end
serve(port = 8001)
When I build another API consuming the previous one, I reach only around 100 RPS even with multithreading (ab -n1000 -c100 'http://localhost:8002/test')
using Oxygen
using HTTP
@get "/test" function()
response = HTTP.get("http://localhost:8001/model") # sleep(0.15) - Just this line is different
return json("ok")
end
serve(port = 8002)
Changing this API to use curl instead of HTTP.jl I got a huge improvement, I go from 100 RPS to about 440 RPS
using Oxygen
@get "/test" function()
response = run(`curl http://localhost:8001/model`) # instead of HTTP.request("GET", "http://localhost:8001/model")
return json("ok")
end
serve(port = 8002)
Do you have any idea why this is happening?
Thank you for your help,
Abraham
- Julia 1.10.1
- HTTP.jl 1.10.2
- MbedTLS.jl 1.1.9