Robyn

Robyn is a Super Fast Async Python Web Framework with a Rust runtime.

BSD-2-CLAUSE License

Downloads
114.2K
Stars
3.5K
Committers
69

Bot releases are hidden (Show)

What's Changed

Special thanks to @JackThomson2 for the

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.17.4...v0.17.5

Example comparison for 100000 requests

➜  ~ oha http://127.0.0.1:5000 -n 100000 --no-tui
Summary:
  Success rate:	1.0000
  Total:	0.5484 secs
  Slowest:	0.0319 secs
  Fastest:	0.0000 secs
  Average:	0.0003 secs
  Requests/sec:	182345.5041

  Total data:	1.14 MiB
  Size/request:	11 B
  Size/sec:	2.08 MiB

Response time histogram:
  0.000 [1]     |
  0.003 [99147] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  0.006 [14]    |
  0.010 [9]     |
  0.013 [3]     |
  0.016 [180]   |
  0.019 [577]   |
  0.022 [56]    |
  0.026 [8]     |
  0.029 [4]     |
  0.032 [1]     |

Latency distribution:
  10% in 0.0001 secs
  25% in 0.0001 secs
  50% in 0.0001 secs
  75% in 0.0001 secs
  90% in 0.0002 secs
  95% in 0.0003 secs
  99% in 0.0004 secs

Details (average, fastest, slowest):
  DNS+dialup:	0.0003 secs, 0.0001 secs, 0.0006 secs
  DNS-lookup:	0.0000 secs, 0.0000 secs, 0.0000 secs

Status code distribution:
  [200] 100000 responses
➜  ~ oha http://127.0.0.1:5000 -n 100000 --no-tui
Summary:
  Success rate:	1.0000
  Total:	0.4062 secs
  Slowest:	0.0326 secs
  Fastest:	0.0000 secs
  Average:	0.0002 secs
  Requests/sec:	246178.0064

  Total data:	1.14 MiB
  Size/request:	11 B
  Size/sec:	2.81 MiB

Response time histogram:
  0.000 [1]     |
  0.003 [99339] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  0.007 [25]    |
  0.010 [10]    |
  0.013 [5]     |
  0.016 [254]   |
  0.020 [232]   |
  0.023 [117]   |
  0.026 [2]     |
  0.029 [14]    |
  0.033 [1]     |

Latency distribution:
  10% in 0.0000 secs
  25% in 0.0001 secs
  50% in 0.0001 secs
  75% in 0.0001 secs
  90% in 0.0002 secs
  95% in 0.0002 secs
  99% in 0.0003 secs

Details (average, fastest, slowest):
  DNS+dialup:	0.0002 secs, 0.0001 secs, 0.0005 secs
  DNS-lookup:	0.0000 secs, 0.0000 secs, 0.0002 secs

Status code distribution:
  [200] 100000 responses

Robyn - v0.17.4: Add better type definition

Published by sansyrox about 2 years ago

What's Changed

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.17.3...v0.17.4

Robyn - v0.17.3: Add "int" status codes in Robyn!

Published by sansyrox about 2 years ago

What's Changed

New Contributors

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.17.2...v0.17.3

Usage

@app.get('/int_status_code')
def return_int_status_code():
    return {"status_code": 202, "body": "hello", "type": "text"}
Robyn - Robyn works on windows! 🥳

Published by sansyrox about 2 years ago

This release removes multiprocessing from windows. This was a hard decision to take but since TCP sockets are not serialisable on non Unix machines, it only made sense.

Since slow Robyn is better than a defunkt Robyn :)

What's Changed

New Contributors

Special thanks to all the contributors :D

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.17.1...v0.17.2

Robyn - v0.17.1 - Fix request header propagation and welcome new contributors

Published by sansyrox over 2 years ago

What's Changed

New Contributors

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.17.0...v0.17.1

Robyn - v0.17.0 - Const Requests

Published by sansyrox over 2 years ago

This feature improves the performance substantially when you want to serve constant responses like simple strings, simple JSON payloads, etc.

Benchmark Source: https://github.com/sansyrox/robyn-comparrison-benchmarks

What's Changed

New Syntax

@app.get("/", const=True) # see the 'const' flag here
async def h(_):
    return "Hello, world!"

Performance upgrade

Robyn (6 workers)

➜  ~ oha --no-tui --insecure -c 100 -n 1000000 http://127.0.0.1:5000
Summary:
  Success rate:	1.0000
  Total:	1.9902 secs
  Slowest:	0.0477 secs
  Fastest:	0.0000 secs
  Average:	0.0002 secs
  Requests/sec:	502470.8499

  Total data:	12.40 MiB
  Size/request:	13 B
  Size/sec:	6.23 MiB

Response time histogram:
  0.000 [2608]   |
  0.000 [85802]  |■■■■■■
  0.000 [320394] |■■■■■■■■■■■■■■■■■■■■■■
  0.000 [456025] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  0.000 [88243]  |■■■■■■
  0.000 [13397]  |
  0.000 [6279]   |
  0.000 [4146]   |
  0.000 [2887]   |
  0.001 [2356]   |
  0.001 [17863]  |■

Latency distribution:
  10% in 0.0001 secs
  25% in 0.0002 secs
  50% in 0.0002 secs
  75% in 0.0002 secs
  90% in 0.0002 secs
  95% in 0.0003 secs
  99% in 0.0008 secs

Details (average, fastest, slowest):
  DNS+dialup:	0.0052 secs, 0.0001 secs, 0.0196 secs
  DNS-lookup:	0.0000 secs, 0.0000 secs, 0.0000 secs

Status code distribution:
  [200] 1000000 responses

FastAPI

➜  ~ oha --no-tui --insecure -c 100 -n 1000000 http://127.0.0.1:5001
Summary:
  Success rate:	1.0000
  Total:	12.2921 secs
  Slowest:	0.0471 secs
  Fastest:	0.0001 secs
  Average:	0.0012 secs
  Requests/sec:	81353.0018

  Total data:	12.40 MiB
  Size/request:	13 B
  Size/sec:	1.01 MiB

Response time histogram:
  0.000 [127872] |■■■■■■■■■■■■■■■■■■■■
  0.001 [178274] |■■■■■■■■■■■■■■■■■■■■■■■■■■■
  0.001 [199031] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  0.001 [204123] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  0.002 [126955] |■■■■■■■■■■■■■■■■■■■
  0.002 [80915]  |■■■■■■■■■■■■
  0.002 [33556]  |■■■■■
  0.003 [11592]  |■
  0.003 [5180]   |
  0.003 [3270]   |
  0.004 [29232]  |■■■■

Latency distribution:
  10% in 0.0004 secs
  25% in 0.0007 secs
  50% in 0.0011 secs
  75% in 0.0015 secs
  90% in 0.0020 secs
  95% in 0.0024 secs
  99% in 0.0058 secs

Details (average, fastest, slowest):
  DNS+dialup:	0.0113 secs, 0.0001 secs, 0.0451 secs
  DNS-lookup:	0.0000 secs, 0.0000 secs, 0.0001 secs

Status code distribution:
  [200] 1000000 responses

Starlette (24 workers)

➜  ~ oha --no-tui --insecure -c 100 -n 1000000 http://127.0.0.1:5003
Summary:
  Success rate:	1.0000
  Total:	9.8807 secs
  Slowest:	0.0534 secs
  Fastest:	0.0001 secs
  Average:	0.0010 secs
  Requests/sec:	101207.5486

  Total data:	12.40 MiB
  Size/request:	13 B
  Size/sec:	1.25 MiB

Response time histogram:
  0.000 [128086] |■■■■■■■■■■■■■■■■■■■
  0.001 [206731] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  0.001 [211417] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  0.001 [174363] |■■■■■■■■■■■■■■■■■■■■■■■■■■
  0.001 [120210] |■■■■■■■■■■■■■■■■■■
  0.002 [69490]  |■■■■■■■■■■
  0.002 [32373]  |■■■■
  0.002 [13678]  |■■
  0.002 [6528]   |
  0.003 [4052]   |
  0.003 [33072]  |■■■■■

Latency distribution:
  10% in 0.0003 secs
  25% in 0.0005 secs
  50% in 0.0008 secs
  75% in 0.0012 secs
  90% in 0.0016 secs
  95% in 0.0020 secs
  99% in 0.0053 secs

Details (average, fastest, slowest):
  DNS+dialup:	0.0368 secs, 0.0077 secs, 0.0520 secs
  DNS-lookup:	0.0000 secs, 0.0000 secs, 0.0001 secs

Status code distribution:
  [200] 1000000 responses

Flask (Bjoern)

➜  ~ oha --no-tui --insecure -c 100 -n 1000000 http://127.0.0.1:5000
Summary:
  Success rate:	1.0000
  Total:	113.6806 secs
  Slowest:	0.1515 secs
  Fastest:	0.0021 secs
  Average:	0.0114 secs
  Requests/sec:	8796.5722

  Total data:	12.40 MiB
  Size/request:	13 B
  Size/sec:	111.67 KiB

Response time histogram:
  0.005 [68]     |
  0.008 [246]    |
  0.011 [417517] |■■■■■■■■■■■■■■■■■■■■■■■
  0.014 [558015] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  0.017 [16685]  |
  0.020 [2962]   |
  0.022 [2796]   |
  0.025 [1357]   |
  0.028 [86]     |
  0.031 [187]    |
  0.034 [81]     |

Latency distribution:
  10% in 0.0099 secs
  25% in 0.0102 secs
  50% in 0.0112 secs
  75% in 0.0123 secs
  90% in 0.0129 secs
  95% in 0.0133 secs
  99% in 0.0157 secs

Details (average, fastest, slowest):
  DNS+dialup:	0.0352 secs, 0.0001 secs, 0.0509 secs
  DNS-lookup:	0.0000 secs, 0.0000 secs, 0.0000 secs

Status code distribution:
  [200] 1000000 responses

System Config

    eeeee  eeeeeeeeeeee   eeeee       OS: elementary OS 6.1 Jólnir x86_64
  eeee   eeeee       eee     eeee     Kernel: 5.13.0-51-generic
 eeee   eeee          eee     eeee    Uptime: 12 hours, 28 mins
eee    eee            eee       eee   Packages: 2369 (dpkg), 11 (flatpak), 12 (snap)
eee   eee            eee        eee   Shell: zsh 5.8
ee    eee           eeee       eeee   Resolution: 3840x2160, 2160x3840
ee    eee         eeeee      eeeeee   DE: Pantheon
ee    eee       eeeee      eeeee ee   WM: Mutter(Gala)
eee   eeee   eeeeee      eeeee  eee   Theme: io.elementary.stylesheet.blueberry [GTK3]
eee    eeeeeeeeee     eeeeee    eee   Icons: elementary [GTK3]
 eeeeeeeeeeeeeeeeeeeeeeee    eeeee    Terminal: alacritty
  eeeeeeee eeeeeeeeeeee      eeee     Terminal Font: DankMono Nerd Font
    eeeee                 eeeee       CPU: AMD Ryzen 9 5900X (24) @ 4.000GHz
      eeeeeee         eeeeeee         GPU: NVIDIA 09:00.0 NVIDIA Corporation Device 2489
         eeeeeeeeeeeeeeeee            Memory: 6090MiB / 64214MiB



Full Changelog: https://github.com/sansyrox/robyn/compare/v0.16.6...v0.17.0

Robyn - v0.16.6 - Fix the `--dev` flag crashing the app

Published by sansyrox over 2 years ago

What's Changed

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.16.4...v0.16.6

What's Changed

New Contributors

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.16.3...v0.16.4

Robyn - No more dangling process and updated type stubs

Published by sansyrox over 2 years ago

What's Changed

New Contributors

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.16.2...v0.16.3

Now you can easily turn off Robyn by pressing Ctrl+C without having dangling processes.

Robyn - Robyn Supports Types Now! ✨

Published by sansyrox over 2 years ago

If types is what the community shall ask for. Then types is what the community shall get! ✨

What's Changed

Special Thanks

  • @Kludex @RobertCraigie for reviewing the PRs.
  • @RobertCraigie for suggesting the prisma integration.

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.16.0...v0.16.2

Robyn - v0.16.0 Add Response Headers and Improve performance

Published by sansyrox over 2 years ago

What's Changed

New Contributors

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.15.1...v0.16.0

You can now have the response headers:

@app.get("/redirect")
async def redirect(request):
    return {"status_code": "307", "body": "", "type": "text", "headers": jsonify({"Location": "redirect_route"})}

Robyn - Websocket ids now accessible in websocket functions

Published by sansyrox over 2 years ago

What's Changed

New Contributors

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.15.0...v0.15.1

Now, you can access web socket uuids from the functional calls

@websocket.on("message")
async def connect(websocket_id):
    print(websocket_id)
    global i
    i += 1
    if i == 0:
        return "Whaaat??"
    elif i == 1:
        return "Whooo??"
    elif i == 2:
        i = -1
        return "*chika* *chika* Slim Shady."

Robyn - Mutable request objects

Published by sansyrox over 2 years ago

Now you can mutate the request object through the request callback.

Example below


@app.get("/redirect")
async def redirect(request):
    return {"status_code": "307", "body": "", "type": "text"}


@app.get("/redirect_route")
async def redirect_route(request):
    return "This is the redirected route"


@app.before_request("/redirect")
async def redirect_before_request(request):
    request["headers"]["Location"] = "redirect_route"
    return ""


@app.after_request("/redirect")
async def redirect_after_request(request):
    request["headers"]["Location"] = "redirect_route"
    return ""


Robyn - v0.14.0 - Added custom response objects

Published by sansyrox over 2 years ago

Robyn supports custom response objects now! 🥳

What's Changed

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.13.1...v0.14.0

Example

@app.get("/")
async def hello(request):
    global callCount
    callCount += 1
    message = "Called " + str(callCount) + " times"
    print(message, request)
    return {"status_code": "200", "body": "hello", "type": "text"}


@app.get('/404')
def return_404():
    return {"status_code": "404", "body": "hello", "type": "text"}
Robyn - v0.13.1 | Robyn installation fixed via conda-forge

Published by sansyrox over 2 years ago

No major functional changes. Only support changes.

You can use conda for installations:

conda install -c conda-forge robyn

What's Changed

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.13.0...v0.13.1

Robyn - v0.13.0 - Middlewares!

Published by sansyrox over 2 years ago

Robyn now supports middlewares!!

Sample Usage

You can use both sync and async functions for middlewares!

@app.before_request("/")
async def hello_before_request(request):
    print(request)


@app.after_request("/")
def hello_after_request(request):
    print(request)

What's Changed

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.12.1...v0.13.0

Robyn - v0.12.1 - Default url bug fix

Published by sansyrox over 2 years ago

What's Changed

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.12.0...v0.12.1

There was an error in the previous release that the app.start() function was defaulting to 128.0.0.1 instead of 127.0.0.1. This PR fixes it.

This release fixes it.

Robyn - v0.12.0 - Events added

Published by sansyrox over 2 years ago

Robyn now supports startup and shutdown events and is now backed with a more stable build backend.

Sample Usage

You can either use the decorator syntax or the functional call syntax to organise your code.

async def startup_handler():
    logger.log(logging.INFO, "Starting up")
app.startup_handler(startup_handler)

@app.shutdown_handler
def shutdown_handler():
    logger.log(logging.INFO, "Shutting down")

What's Changed

Special Thanks

  • @klaa97 for making robyn's PR at TechEmpoweredBenchmark's repo!

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.11.1...v0.12.0

Robyn - v0.11.1 - Make Robyn work with docker containers

Published by sansyrox almost 3 years ago

This is a minor release. An input statement was being used instead of a print statement. This will help with docker containers and also Tech-Empowered benchmarking.

What's Changed

New Contributors

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.11.0...v0.11.1

Special thanks to @klaa97 for identifying the bug and fixing it! 🥳

What's Changed

New Contributors

Full Changelog: https://github.com/sansyrox/robyn/compare/v0.10.0...v0.11.0

Summary

You can make a request to http://localhost:5000/query?a=b and can access the params in the following way:

@app.get("/query")
async def query_get(request):
    query_data = request["queries"]
    return jsonify(query_data)

The hot reloading server is now fixed and works on Linux and OSX(i.e. on all important operating systems). Windows support for dev server is still WIP.

Special thanks to @patchgamestudio for their contribution with the query params 🥳