Asynchronous programming
Synchronous execution

Parallel and concurrent computing
Parallel data processing

Task parallelism


How we run our server
> poetry run daphne -b 0.0.0.0 -p $PORT boshi.asgi:application
In short
We use parallel task execution as horizontal scaling in order to serve more requests
at the same time
Problem
More running dynos
mean more money.
What else we can do?
Concurrency!



In short
With the help of asynchronous programming, we can utilise the idle time because of IO operations to process more requests at the same time in a concurrent fashion
This is why NodeJS is good at non-blocking I/O, but bad at CPU intensive operations
It is also possible
in Python!
Daphne is ASGI
> poetry run daphne -b 0.0.0.0 -p $PORT boshi.asgi:applicationDjango supports
async for author in Author.objects.filter(name__startswith="A"):
book = await author.books.afirst()
async def make_book_with_tags(tags, *args, **kwargs):
book = await Book.objects.acreate(...)
await book.tags.aset(tags)Even faster
> poetry run uvicorn --loop uvloop --port $PORT boshi.asgi:application The combination of horizontal scaling (parallel task processing) and asynchronous programming (concurrency) is the best for higher request numbers.
Thanks!
Asyncrhonous programming
By Róbert Beretka
Asyncrhonous programming
- 141