You've already forked request-coalescing-py
mirror of
https://github.com/hexolan/request-coalescing-py.git
synced 2026-03-26 10:11:16 +00:00
docs: improved write-up
added code documentation clarified language in `README.md` updated details in `pyproject.toml`
This commit is contained in:
15
README.md
15
README.md
@@ -1,14 +1,12 @@
|
||||
# Request Coalescing in Async Python
|
||||
|
||||
## About
|
||||
|
||||
This repository is a simple experiment revolved around implementing request coalescing in Python using Asyncio and FastAPI, inspired by the Discord Engineering team's blog post on [How Discord Stores Trillions of Messages.](https://discord.com/blog/how-discord-stores-trillions-of-messages)
|
||||
A simple experiment revolved around implementing request coalescing in Python, using Asyncio and FastAPI, inspired by the Discord Engineering team's blog post on [How Discord Stores Trillions of Messages.](https://discord.com/blog/how-discord-stores-trillions-of-messages)
|
||||
|
||||
## How does it work?
|
||||
|
||||
When a client makes a request for an item of a specific id, it adds a task to the coalescer queue and waits for the result of that task.
|
||||
When a client makes a request for an item of a specific id, it will add a task to the coalescer queue and await the result of that task.
|
||||
|
||||
Any subsequent requests, recieved in the meantime, for items of the same ID will subscribe to the future result of that first pending task instead of performing their own read query.
|
||||
Any subsequent requests recieved in the meantime, for items of the same id, will subscribe to the future result of that first pending task instead of performing their own expensive read query.
|
||||
|
||||

|
||||
|
||||
@@ -16,7 +14,6 @@ Any subsequent requests, recieved in the meantime, for items of the same ID will
|
||||
|
||||
```bash
|
||||
> poetry run pytest
|
||||
|
||||
tests\test_standard.py Making 5x100 concurrent requests (500 total)...
|
||||
Standard Requests: Took 457.228ms
|
||||
Standard Metrics: {'requests': 500, 'db_calls': 500}
|
||||
@@ -26,10 +23,10 @@ Coalesced Requests: Took 49.328ms
|
||||
Coalesced Metrics: {'requests': 500, 'db_calls': 100}
|
||||
```
|
||||
|
||||
The number of database queries has fallen from 1:1 with requests to 1 database call per 5 requests (lining up with there being 5 requests being made concurrently in the tests).
|
||||
The number of database queries has fallen from 1:1 with requests to 1 database call per 5 requests (when coalescing and performing 5 requests concurrently).
|
||||
|
||||
## License and Contributing
|
||||
|
||||
Please feel free to make pull requests containing any suggestions for improvements.
|
||||
Please feel free to open an issue or a pull request to discuss suggestions for improvements.
|
||||
|
||||
This repository is open sourced under the [MIT License.](/LICENSE)
|
||||
This repository is open source under the [MIT License.](/LICENSE)
|
||||
|
||||
Reference in New Issue
Block a user