Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async support #43

Open
Llandy3d opened this issue Jun 28, 2023 · 0 comments
Open

Async support #43

Llandy3d opened this issue Jun 28, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Llandy3d
Copy link
Owner

For supporting async python initial changes where merged for decorators & context managers:

This works fine for single process but for multiprocess support the current offered solution makes use of redis & the MultiProcessRedisBackend implementation makes use of the synchronous redis library.

So for supporting multiprocess in an async environment we could offer an async interface of the library like an async def generate_metrics & also an async redis backend implementation AsyncMultiProcessRedisBackend that would require another dependency on an async redis library.

I feel like all that work is not worth it, having to support duplicated behaviour means duplicated effort and might cause confusion. It also adds the number of dependencies required.

I had an idea on implementing a backend in Rust that could work in both sync & async python so that the interface could stay the same. This also can remove the dependency on the redis library if it becomes the defacto standard for multiprocessing.

Not everything is perfect, in an async framework like FastAPI the /metrics endpoint needs to be run in a ThreadPool ideally (a def endpoint would do that automatically) but it's a great start. On the plus side that part can release the GIL so that other threads can work while the metrics get generated!

The implementation can be followed in here:

@Llandy3d Llandy3d added the enhancement New feature or request label Jun 28, 2023
@Llandy3d Llandy3d self-assigned this Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant