Oxygen.jl is faster than FastAPI, Flask and Rocket

Running some benchmarks

---- 1000 HTTP Requests ----
Flask Server
--- 1.7611534595489502 seconds in total ---
--- 0.0017611534595489502 seconds per iteration ---
FastAPI Server
--- 1.5010621547698975 seconds in total ---
--- 0.0015010621547698975 seconds per iteration ---
Rocket Server
--- 1.741997241973877 seconds in total ---
--- 0.001741997241973877 seconds per iteration ---
Oxygen.jl Server
--- 1.1278553009033203 seconds in total ---
--- 0.0011278553009033204 seconds per iteration ---

Please consider adding some context to your post, what have you benchmarked? Are then benchmarks open source? What are the benchmarks representative of?

More context:

All servers are minimal and just return “hello world”
Running HTTP Request to each server in Julia:

n_iterations::Int64 = 1000
function test_server(server::String, iterations::Int64)
    for i in 1:iterations
        HTTP.get(server)
    end
end

## remove cold start
test_server(oxygen_server,1000)

println("---- "*string(n_iterations)*" HTTP Requests ----")
println("Flask")
@time test_server(flask_server,n_iterations)
println("Fast API")
@time test_server(fastapi_server,n_iterations)
println("Rocket")
@time test_server(rocket_server,n_iterations)
println("Oxygen.jl")
@time test_server(oxygen_server,n_iterations)

We get:

---- 1000 HTTP Requests ----
Flask
  1.010097 seconds (252.42 k allocations: 106.758 MiB, 1.55% gc time, 1.50% compilation time)
Fast API
  0.468368 seconds (183.19 k allocations: 10.974 MiB)
Rocket
  0.946827 seconds (247.34 k allocations: 77.325 MiB, 1.29% gc time)
Oxygen.jl
  0.297005 seconds (200.03 k allocations: 11.234 MiB)

My original comment did the requests in Python, so Julia is also faster in making HTTP requests.

So, this represents that you can get faster sequential responses in an oxygen based server than in any of the other alternatives.

Hope someone can finish this Add Oxygen to Techempower · Issue #63 · ndortega/Oxygen.jl · GitHub , which I don’ t have time in near future.

And someone did benchmark with GitHub - JuliaOnWeb/c_http_jl: wrapping c lib and benchmarking with http.jl and node . Don’ t know how easy to use that with Oxygen.

Oxygen is fast, simple, is a great packcage!

Hi

Thanks for this link - the C wrapper looks very fast - what is the actual C library that has been used for the test ?

Would the results not suggest that to be a good way to implement http in Julia?

Regards

Is any simple examples with authentication without 3rd party resources (Umbrella ets.)?

Any example with JWTs will be very helpful!

Hi @PharmCat,

At the moment there’s no explicit JWT demo, but there are some relevant examples to help you get where you want to go.

Oxygen.jl includes BearerAuth middleware function which will automatically extract out the bearer auth token from the Authorization header.

It expects you to write your own validation token function to determine if the user is authorized and return their corresponding user info / auth details. From there you could use a library like JWTs.jl to parse and validate the actual token.

# Your function will need to perform actual token validation 
function validate_token(token::String)
    # return the user object 
    return Dict("name" => "joe")
end

# Only let requests with a valid token through
serve(middleware=[BearerAuth(validate_token)])

Then the data is then assigned to the req.context[:user] property of the incoming request.

# pull the name from the user context property
@get "/greet" function(req)
    first_name = req.context[:user]["name"]
    return "hello: $first_name"
end

If you’re curious I recommend checking out my unit tests to see a simple test case in action: Oxygen.jl/test/middleware/authmiddleware_tests.jl at v1.10.2 · OxygenFramework/Oxygen.jl · GitHub

I’ve had some good experiences with Oxygen.jl on the backend and React/Vite on the frontend, with either REST or Websockets. This has turned out to be a really productive environment for rapid development using agentic coding assistants.

It would be nice in the readme or the doc of Oxygen to point users to real world cases that use it…