Question about tokio support in async-std

Hello,

I'm starting a new project using async-graphql. I'd very much like to use it with tide since it's the leanest option for a graphql server that, by its very nature, won't need any routing or a web server with loads of bells and whistles

My only concern is that tide has a strong dependency with async-std while IMHO the majority of async crates seem to depend on tokio. I can also see that async-std's latest version includes support for all versions of tokio.

How does this support work? More precisely,

  1. Does this support have any impact on performance? For example, does async-std spawn tasks in two runtimes? Or is the support more like a patch so that dependencies that need tokio can run inside async-std's default runtime?
  2. Will I be able to use any library that depend on tokio v1.x.x without problem?

The Tokio compatibility in async-std works by spawning an extra Tokio runtime in the background. So yes, it does have some sort of impact on your performance as you now have two IO drivers and two timer threads and such.

As for whether you can use any Tokio library, I'm pretty sure that you would not be able to use things that depend on Tokio's block_in_place, but besides that, you should be able to use anything else.

1 Like

thanks for that! It confirms my suspicions then. Maybe I'm wrong, but having two runtimes sounds more like a last resort option rather than a good basis for a new project

Yeah, I agree.

If you are looking for a Tokio-based web server library without routing or bells and whistles, you may want to try out hyper.

Unfortunately hyper is not supported by async-graphql Integrations - Async-graphql Book

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.