PageSourceSearch

https://tokio.rs/tokio/tutorial

html tokio.rs collected 2026-10-02 02:14:44 UTC 26,886 bytes, 83 lines download raw bytes

1<!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width, initial-scale=1" data-next-head=""/><title data-next-head="">Tutorial | Tokio - An asynchronous Rust runtime</title><meta name="description" content="Tokio is a runtime for writing reliable asynchronous applications with Rust. It provides async I/O, networking, scheduling, timers, and more." data-next-head=""/><link rel="alternate icon" type="image/png" href="/favicon-32x32.png" data-next-head=""/><link rel="icon" type="image/svg+xml" href="/favicon.svg" data-next-head=""/><link rel="alternate" type="application/rss+xml" href="/blog/index.xml" data-next-head=""/><link rel="preload" href="/_next/static/css/590bbafc9488a949.css" as="style"/><link rel="preload" href="/_next/static/css/de41d0a3c2328efe.css" as="style"/><link rel="stylesheet" href="/_next/static/css/590bbafc9488a949.css" data-n-g=""/><link rel="stylesheet" href="/_next/static/css/de41d0a3c2328efe.css" data-n-p=""/><noscript data-n-css=""></noscript>
1<script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script>
1<script src="/_next/static/chunks/webpack-f8185607c88ffb0b.js" defer=""></script>
1<script src="/_next/static/chunks/framework-516982be4eea35ea.js" defer=""></script>
1<script src="/_next/static/chunks/main-11f62a962ab540a8.js" defer=""></script>
1<script src="/_next/static/chunks/pages/_app-7e9c39878777ce10.js" defer=""></script>
1<script src="/_next/static/chunks/53-04c46f2e17895053.js" defer=""></script>
1<script src="/_next/static/chunks/547-573b033aa0b73315.js" defer=""></script>
1<script src="/_next/static/chunks/pages/%5B...slug%5D-0bd34730781e0ad8.js" defer=""></script>
1<script src="/_next/static/Sbzh4LmpQAwZi0cg4N5YE/_buildManifest.js" defer=""></script>
1<script src="/_next/static/Sbzh4LmpQAwZi0cg4N5YE/_ssgManifest.js" defer=""></script>
1</head><body><link rel="preload" as="image" href="/img/tokio-horizontal.svg"/><link rel="preload" as="image" href="/img/arrow-right.svg"/><div id="__next"><main class="__className_a1d03f"><nav class="navbar is-spaced" role="navigation" aria-label="main navigation"><div class="container"><div class="navbar-brand"><a href="/" class="navbar-item"><img src="/img/tokio-horizontal.svg" alt="tokio-logo" width="133" height="56"/></a><a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false"><span aria-hidden="true"></span><span aria-hidden="true"></span><span aria-hidden="true"></span></a></div><div class="navbar-menu"><div class="navbar-end"><a href="/tokio/tutorial" class="navbar-item navbar-text">Learn</a><a href="https://docs.rs/tokio" class="navbar-item navbar-text">API Docs</a><a href="/blog/2026-09-24-topcoat-server-applications" class="navbar-item navbar-text">Blog</a><hr class="is-hidden-mobile"/><a target="_blank" class="navbar-item navbar-icon tk-social" href="https://twitter.com/tokio_rs"><span class="icon "><svg width="45" height="45" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path class="tk-svg-path" d="m 1033.0757,785.67723 536.386,-610.09838 H 1442.3554 L 976.61152,705.31871 604.62327,175.57885 H 175.57884 L 738.0981,976.63931 175.57884,1616.4212 h 127.11352 l 491.83748,-559.4233 392.84686,559.4233 h 429.0444 L 1033.0445,785.67723 Z M 858.97635,983.69686 801.9814,903.9293 348.49316,269.21053 h 195.2389 l 365.97034,512.23831 56.9949,79.76754 475.7181,665.83142 H 1247.1765 L 858.97635,983.72736 Z" fill="#fff"></path></svg></span></a><a target="_blank" class="navbar-item navbar-icon tk-social" href="https://github.com/tokio-rs/tokio"><span class="icon "><svg width="45" height="45" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path class="tk-svg-path" d="M896 128q209 0 385.5 103t279.5 279.5 103 385.5q0 251-146.5 451.5t-378.5 277.5q-27 5-40-7t-13-30q0-3 .5-76.5t.5-134.5q0-97-52-142 57-6 102.5-18t94-39 81-66.5 53-105 20.5-150.5q0-119-79-206 37-91-8-204-28-9-81 11t-92 44l-38 24q-93-26-192-26t-192 26q-16-11-42.5-27t-83.5-38.5-85-13.5q-45 113-8 204-79 87-79 206 0 85 20.5 150t52.5 105 80.5 67 94 39 102.5 18q-39 36-49 103-21 10-45 15t-57 5-65.5-21.5-55.5-62.5q-19-32-48.5-52t-49.5-24l-20-3q-21 0-29 4.5t-5 11.5 9 14 13 12l7 5q22 10 43.5 38t31.5 51l10 23q13 38 44 61.5t67 30 69.5 7 55.5-3.5l23-4q0 38 .5 88.5t.5 54.5q0 18-13 30t-40 7q-232-77-378.5-277.5t-146.5-451.5q0-209 103-385.5t279.5-279.5 385.5-103zm-477 1103q3-7-7-12-10-3-13 2-3 7 7 12 9 6 13-2zm31 34q7-5-2-16-10-9-16-3-7 5 2 16 10 10 16 3zm30 45q9-7 0-19-8-13-17-6-9 5 0 18t17 7zm42 42q8-8-4-19-12-12-20-3-9 8 4 19 12 12 20 3zm57 25q3-11-13-16-15-4-19 7t13 15q15 6 19-6zm63 5q0-13-17-11-16 0-16 11 0 13 17 11 16 0 16-11zm58-10q-2-11-18-9-16 3-14 15t18 8 14-14z" fill="#fff"></path></svg></span></a><a target="_blank" class="navbar-item navbar-icon tk-social" href="https://discord.gg/tokio"><span class="icon "><svg width="45" height="45" viewBox="0 0 245 240" xmlns="http://www.w3.org/2000/svg"><path class="tk-svg-path" fill="#FFF" d="M104.4 103.9c-5.7 0-10.2 5-10.2 11.1s4.6 11.1 10.2 11.1c5.7 0 10.2-5 10.2-11.1.1-6.1-4.5-11.1-10.2-11.1zM140.9 103.9c-5.7 0-10.2 5-10.2 11.1s4.6 11.1 10.2 11.1c5.7 0 10.2-5 10.2-11.1s-4.5-11.1-10.2-11.1z"></path><path class="tk-svg-path" fill="#FFF" d="M189.5 20h-134C44.2 20 35 29.2 35 40.6v135.2c0 11.4 9.2 20.6 20.5 20.6h113.4l-5.3-18.5 12.8 11.9 12.1 11.2 21.5 19V40.6c0-11.4-9.2-20.6-20.5-20.6zm-38.6 130.6s-3.6-4.3-6.6-8.1c13.1-3.7 18.1-11.9 18.1-11.9-4.1 2.7-8 4.6-11.5 5.9-5 2.1-9.8 3.5-14.5 4.3-9.6 1.8-18.4 1.3-25.9-.1-5.7-1.1-10.6-2.7-14.7-4.3-2.3-.9-4.8-2-7.3-3.4-.3-.2-.6-.3-.9-.5-.2-.1-.3-.2-.4-.3-1.8-1-2.8-1.7-2.8-1.7s4.8 8 17.5 11.8c-3 3.8-6.7 8.3-6.7 8.3-22.1-.7-30.5-15.2-30.5-15.2 0-32.2 14.4-58.3 14.4-58.3 14.4-10.8 28.1-10.5 28.1-10.5l1 1.2c-18 5.2-26.3 13.1-26.3 13.1s2.2-1.2 5.9-2.9c10.7-4.7 19.2-6 22.7-6.3.6-.1 1.1-.2 1.7-.2 6.1-.8 13-1 20.2-.2 9.5 1.1 19.7 3.9 30.1 9.6 0 0-7.9-7.5-24.9-12.7l1.4-1.6s13.7-.3 28.1 10.5c0 0 14.4 26.1 14.4 58.3 0 0-8.5 14.5-30.6 15.2z"></path></svg></span></a></div></div></div></nav><div class="columns is-marginless tk-docs"><div class="column is-one-quarter tk-docs-nav"><aside class="menu"><div class="tk-toc is-hidden-tablet"><a href="#">TABLE OF CONTENTS<span class="icon"><span class="tk-arrow"></span></span></a></div><div class="tk-menu-body"><p class="menu-label">Tokio</p><ul class="menu-list"><li class="is-active"><a href="/tokio/tutorial">
1Tutorial</a><ul><ul><li class="is-active"><a href="/tokio/tutorial">Overview</a></li><li class=""><a href="/tokio/tutorial/setup">Setup</a></li><li class=""><a href="/tokio/tutorial/hello-tokio">Hello Tokio</a></li><li class=""><a href="/tokio/tutorial/spawning">Spawning</a></li><li class=""><a href="/tokio/tutorial/shared-state">Shared state</a></li><li class=""><a href="/tokio/tutorial/channels">Channels</a></li><li class=""><a href="/tokio/tutorial/io">I/O</a></li><li class=""><a href="/tokio/tutorial/framing">Framing</a></li><li class=""><a href="/tokio/tutorial/async">Async in depth</a></li><li class=""><a href="/tokio/tutorial/select">Select</a></li><li class=""><a href="/tokio/tutorial/streams">Streams</a></li></ul></ul></li><li class=""><a href="/tokio/topics">Topics</a><ul><ul><li class=""><a href="/tokio/topics/bridging">Bridging with sync code</a></li><li class=""><a href="/tokio/topics/shutdown">Graceful Shutdown</a></li><li class=""><a href="/tokio/topics/tracing">Getting started with Tracing</a></li><li class=""><a href="/tokio/topics/tracing-next-steps">Next steps with Tracing</a></li><li class=""><a href="/tokio/topics/testing">Unit Testing</a></li></ul></ul></li><li class=""><a href="/tokio/glossary">Glossary</a></li><li class=""><a href="https://docs.rs/tokio">API documentation</a></li></ul></div><div class="is-hidden-mobile"></div></aside></div><div class="column is-three-quarters tk-content"><section class="section content"><div class="columns"><div class="column is-two-thirds tk-markdown"><h1 class="title " id="">Tutorial</h1><div><p>Tokio is an asynchronous runtime for the Rust programming language. It provides
2the building blocks needed for writing networking applications. It gives the
3flexibility to target a wide range of systems, from large servers with dozens of
4cores to small embedded devices.</p>
5<p>At a high level, Tokio provides a few major components:</p>
6<ul>
7<li>A multi-threaded runtime for executing asynchronous code.</li>
8<li>An asynchronous version of the standard library.</li>
9<li>A large ecosystem of libraries.</li>
10</ul>
11<h1 id="tokios-role-in-your-project">Tokio's role in your project</h1>
12<p>When you write your application in an asynchronous manner, you enable it to
13scale much better by reducing the cost of doing many things at the same time.
14However, asynchronous Rust code does not run on its own, so you must choose a
15runtime to execute it. The Tokio library is the most widely used runtime,
16surpassing all other runtimes in usage combined.</p>
17<p>Additionally, Tokio provides many useful utilities. When writing asynchronous
18code, you cannot use the ordinary blocking APIs provided by the Rust standard
19library, and must instead use asynchronous versions of them. These alternate
20versions are provided by Tokio, mirroring the API of the Rust standard library
21where it makes sense.</p>
22<h1 id="advantages-of-tokio">Advantages of Tokio</h1>
23<p>This section will outline some advantages of Tokio.</p>
24<h2 id="fast">Fast</h2>
25<p>Tokio is <em>fast</em>, built on top of the Rust programming language, which itself is
26fast. This is done in the spirit of Rust with the goal that you should not be
27able to improve the performance by writing equivalent code by hand.</p>
28<p>Tokio is <em>scalable</em>, built on top of the async/await language feature, which
29itself is scalable. When dealing with networking, there's a limit to how fast
30you can handle a connection due to latency, so the only way to scale is to
31handle many connections at once. With the async/await language feature,
32increasing the number of concurrent operations becomes incredibly cheap,
33allowing you to scale to a large number of concurrent tasks.</p>
34<h2 id="reliable">Reliable</h2>
35<p>Tokio is built using Rust, which is a language that empowers everyone
36to build reliable and efficient software. A <a href="https://www.zdnet.com/article/microsoft-70-percent-of-all-security-bugs-are-memory-safety-issues/">number</a> of
37<a href="https://www.chromium.org/Home/chromium-security/memory-safety">studies</a> have found that roughly ~70% of high severity security bugs
38are the result of memory unsafety. Using Rust eliminates this entire class of
39bugs in your applications.</p>
40<p>Tokio also focuses heavily on providing consistent behaviour with no surprises.
41Tokio's major goal is to allow users to deploy predictable software that will
42perform the same day in and day out with reliable response times and no
43unpredictable latency spikes.</p>
44<h2 id="easy">Easy</h2>
45<p>With Rust's async/await feature, the complexity of writing asynchronous
46applications has been lowered substantially. Paired with Tokio's utilities and
47vibrant ecosystem, writing applications is a breeze.</p>
48<p>Tokio follows the standard library's naming convention when it makes sense. This
49allows easily converting code written with only the standard library to code
50written with Tokio. With the strong type system of Rust, the ability to deliver
51correct code easily is unparalleled.</p>
52<h2 id="flexible">Flexible</h2>
53<p>Tokio provides multiple variations of the runtime. Everything from a
54multi-threaded, <a href="https://en.wikipedia.org/wiki/Work_stealing">work-stealing</a> runtime to a light-weight, single-threaded
55runtime. Each of these runtimes come with many knobs to allow users to tune them
56to their needs.</p>
57<h1 id="when-not-to-use-tokio">When not to use Tokio</h1>
58<p>Although Tokio is useful for many projects that need to do a lot of things
59simultaneously, there are also some use-cases where Tokio is not a good fit.</p>
60<ul>
61<li>Speeding up CPU-bound computations by running them in parallel on several
62threads. Tokio is designed for IO-bound applications where each individual
63task spends most of its time waiting for IO. If the only thing your
64application does is run computations in parallel, you should be using
65<a href="https://docs.rs/rayon/">rayon</a>. That said, it is still possible to "mix &#x26; match"
66if you need to do both. See <a href="https://ryhl.io/blog/async-what-is-blocking/#the-rayon-crate">this blog post for a practical example</a>.</li>
67<li>Reading a lot of files. Although it seems like Tokio would be useful for
68projects that simply need to read a lot of files, Tokio provides no advantage
69here compared to an ordinary threadpool. This is because operating systems
70generally do not provide asynchronous file APIs.</li>
71<li>Sending a single web request. The place where Tokio gives you an advantage is
72when you need to do many things at the same time. If you need to use a
73library intended for asynchronous Rust such as <a href="https://docs.rs/reqwest/">reqwest</a>, but you don't need
74to do a lot of things at once, you should prefer the blocking version of that
75library, as it will make your project simpler. Using Tokio will still work,
76of course, but provides no real advantage over the blocking API. If the
77library doesn't provide a blocking API, see <a href="/tokio/topics/bridging">the chapter on
78bridging with sync code</a>.</li>
79</ul>
80<h1 id="getting-help">Getting Help</h1>
81<p>At any point, if you get stuck, you can always get help on <a href="https://discord.gg/tokio">Discord</a> or <a href="https://github.com/tokio-rs/tokio/discussions">GitHub
82discussions</a>. Don't worry about asking "beginner" questions. We all start
83somewhere and are happy to help.</p></div><div class="tk-doc-footer"><div class="level"><div class="level-left"><div class="level-item tk-prev"></div></div><div class="level-right"><div class="level-item tk-next"><a href="/tokio/tutorial/setup" rel="next">Setup<span class="tk-arrow" style="margin-left:0.5rem"><img src="/img/arrow-right.svg"/></span></a></div></div></div><div class="level"><div class="level-left"><div class="level-item tk-help-links"><p>Get Help:<a href="https://github.com/tokio-rs/tokio/discussions"><span class="icon is-medium"><svg width="45" height="45" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path class="tk-svg-path" d="M896 128q209 0 385.5 103t279.5 279.5 103 385.5q0 251-146.5 451.5t-378.5 277.5q-27 5-40-7t-13-30q0-3 .5-76.5t.5-134.5q0-97-52-142 57-6 102.5-18t94-39 81-66.5 53-105 20.5-150.5q0-119-79-206 37-91-8-204-28-9-81 11t-92 44l-38 24q-93-26-192-26t-192 26q-16-11-42.5-27t-83.5-38.5-85-13.5q-45 113-8 204-79 87-79 206 0 85 20.5 150t52.5 105 80.5 67 94 39 102.5 18q-39 36-49 103-21 10-45 15t-57 5-65.5-21.5-55.5-62.5q-19-32-48.5-52t-49.5-24l-20-3q-21 0-29 4.5t-5 11.5 9 14 13 12l7 5q22 10 43.5 38t31.5 51l10 23q13 38 44 61.5t67 30 69.5 7 55.5-3.5l23-4q0 38 .5 88.5t.5 54.5q0 18-13 30t-40 7q-232-77-378.5-277.5t-146.5-451.5q0-209 103-385.5t279.5-279.5 385.5-103zm-477 1103q3-7-7-12-10-3-13 2-3 7 7 12 9 6 13-2zm31 34q7-5-2-16-10-9-16-3-7 5 2 16 10 10 16 3zm30 45q9-7 0-19-8-13-17-6-9 5 0 18t17 7zm42 42q8-8-4-19-12-12-20-3-9 8 4 19 12 12 20 3zm57 25q3-11-13-16-15-4-19 7t13 15q15 6 19-6zm63 5q0-13-17-11-16 0-16 11 0 13 17 11 16 0 16-11zm58-10q-2-11-18-9-16 3-14 15t18 8 14-14z" fill="#fff"></path></svg></span></a><a href="https://discord.gg/tokio"><span class="icon is-medium">
83<svg width="45" height="45" viewBox="0 0 245 240" xmlns="http://www.w3.org/2000/svg"><path class="tk-svg-path" fill="#FFF" d="M104.4 103.9c-5.7 0-10.2 5-10.2 11.1s4.6 11.1 10.2 11.1c5.7 0 10.2-5 10.2-11.1.1-6.1-4.5-11.1-10.2-11.1zM140.9 103.9c-5.7 0-10.2 5-10.2 11.1s4.6 11.1 10.2 11.1c5.7 0 10.2-5 10.2-11.1s-4.5-11.1-10.2-11.1z"></path><path class="tk-svg-path" fill="#FFF" d="M189.5 20h-134C44.2 20 35 29.2 35 40.6v135.2c0 11.4 9.2 20.6 20.5 20.6h113.4l-5.3-18.5 12.8 11.9 12.1 11.2 21.5 19V40.6c0-11.4-9.2-20.6-20.5-20.6zm-38.6 130.6s-3.6-4.3-6.6-8.1c13.1-3.7 18.1-11.9 18.1-11.9-4.1 2.7-8 4.6-11.5 5.9-5 2.1-9.8 3.5-14.5 4.3-9.6 1.8-18.4 1.3-25.9-.1-5.7-1.1-10.6-2.7-14.7-4.3-2.3-.9-4.8-2-7.3-3.4-.3-.2-.6-.3-.9-.5-.2-.1-.3-.2-.4-.3-1.8-1-2.8-1.7-2.8-1.7s4.8 8 17.5 11.8c-3 3.8-6.7 8.3-6.7 8.3-22.1-.7-30.5-15.2-30.5-15.2 0-32.2 14.4-58.3 14.4-58.3 14.4-10.8 28.1-10.5 28.1-10.5l1 1.2c-18 5.2-26.3 13.1-26.3 13.1s2.2-1.2 5.9-2.9c10.7-4.7 19.2-6 22.7-6.3.6-.1 1.1-.2 1.7-.2 6.1-.8 13-1 20.2-.2 9.5 1.1 19.7 3.9 30.1 9.6 0 0-7.9-7.5-24.9-12.7l1.4-1.6s13.7-.3 28.1 10.5c0 0 14.4 26.1 14.4 58.3 0 0-8.5 14.5-30.6 15.2z"></path></svg></span></a></p></div></div><div class="level-right"><div class="level-item tk-edit-this-page"><a href="https://github.com/tokio-rs/website/edit/master/content/tokio/tutorial/index.md">Edit this page</a></div></div></div></div></div><aside class="column is-one-third tk-content-summary"><ul class="tk-content-summary-menu"></ul></aside></div></section></div></div></main></div>
83<script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"page":{"key":"tutorial","href":"/tokio/tutorial","title":"Tutorial","menuTitle":"Tutorial","mdPath":"tokio/tutorial/index.md","data":{"title":"Tutorial","subtitle":"Overview"},"body":"\u003cp\u003eTokio is an asynchronous runtime for the Rust programming language. It provides\nthe building blocks needed for writing networking applications. It gives the\nflexibility to target a wide range of systems, from large servers with dozens of\ncores to small embedded devices.\u003c/p\u003e\n\u003cp\u003eAt a high level, Tokio provides a few major components:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eA multi-threaded runtime for executing asynchronous code.\u003c/li\u003e\n\u003cli\u003eAn asynchronous version of the standard library.\u003c/li\u003e\n\u003cli\u003eA large ecosystem of libraries.\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch1 id=\"tokios-role-in-your-project\"\u003eTokio's role in your project\u003c/h1\u003e\n\u003cp\u003eWhen you write your application in an asynchronous manner, you enable it to\nscale much better by reducing the cost of doing many things at the same time.\nHowever, asynchronous Rust code does not run on its own, so you must choose a\nruntime to execute it. The Tokio library is the most widely used runtime,\nsurpassing all other runtimes in usage combined.\u003c/p\u003e\n\u003cp\u003eAdditionally, Tokio provides many useful utilities. When writing asynchronous\ncode, you cannot use the ordinary blocking APIs provided by the Rust standard\nlibrary, and must instead use asynchronous versions of them. These alternate\nversions are provided by Tokio, mirroring the API of the Rust standard library\nwhere it makes sense.\u003c/p\u003e\n\u003ch1 id=\"advantages-of-tokio\"\u003eAdvantages of Tokio\u003c/h1\u003e\n\u003cp\u003eThis section will outline some advantages of Tokio.\u003c/p\u003e\n\u003ch2 id=\"fast\"\u003eFast\u003c/h2\u003e\n\u003cp\u003eTokio is \u003cem\u003efast\u003c/em\u003e, built on top of the Rust programming language, which itself is\nfast. This is done in the spirit of Rust with the goal that you should not be\nable to improve the performance by writing equivalent code by hand.\u003c/p\u003e\n\u003cp\u003eTokio is \u003cem\u003escalable\u003c/em\u003e, built on top of the async/await language feature, which\nitself is scalable. When dealing with networking, there's a limit to how fast\nyou can handle a connection due to latency, so the only way to scale is to\nhandle many connections at once. With the async/await language feature,\nincreasing the number of concurrent operations becomes incredibly cheap,\nallowing you to scale to a large number of concurrent tasks.\u003c/p\u003e\n\u003ch2 id=\"reliable\"\u003eReliable\u003c/h2\u003e\n\u003cp\u003eTokio is built using Rust, which is a language that empowers everyone\nto build reliable and efficient software. A \u003ca href=\"https://www.zdnet.com/article/microsoft-70-percent-of-all-security-bugs-are-memory-safety-issues/\"\u003enumber\u003c/a\u003e of\n\u003ca href=\"https://www.chromium.org/Home/chromium-security/memory-safety\"\u003estudies\u003c/a\u003e have found that roughly ~70% of high severity security bugs\nare the result of memory unsafety. Using Rust eliminates this entire class of\nbugs in your applications.\u003c/p\u003e\n\u003cp\u003eTokio also focuses heavily on providing consistent behaviour with no surprises.\nTokio's major goal is to allow users to deploy predictable software that will\nperform the same day in and day out with reliable response times and no\nunpredictable latency spikes.\u003c/p\u003e\n\u003ch2 id=\"easy\"\u003eEasy\u003c/h2\u003e\n\u003cp\u003eWith Rust's async/await feature, the complexity of writing asynchronous\napplications has been lowered substantially. Paired with Tokio's utilities and\nvibrant ecosystem, writing applications is a breeze.\u003c/p\u003e\n\u003cp\u003eTokio follows the standard library's naming convention when it makes sense. This\nallows easily converting code written with only the standard library to code\nwritten with Tokio. With the strong type system of Rust, the ability to deliver\ncorrect code easily is unparalleled.\u003c/p\u003e\n\u003ch2 id=\"flexible\"\u003eFlexible\u003c/h2\u003e\n\u003cp\u003eTokio provides multiple variations of the runtime. Everything from a\nmulti-threaded, \u003ca href=\"https://en.wikipedia.org/wiki/Work_stealing\"\u003ework-stealing\u003c/a\u003e runtime to a light-weight, single-threaded\nruntime. Eac
83h of these runtimes come with many knobs to allow users to tune them\nto their needs.\u003c/p\u003e\n\u003ch1 id=\"when-not-to-use-tokio\"\u003eWhen not to use Tokio\u003c/h1\u003e\n\u003cp\u003eAlthough Tokio is useful for many projects that need to do a lot of things\nsimultaneously, there are also some use-cases where Tokio is not a good fit.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eSpeeding up CPU-bound computations by running them in parallel on several\nthreads. Tokio is designed for IO-bound applications where each individual\ntask spends most of its time waiting for IO. If the only thing your\napplication does is run computations in parallel, you should be using\n\u003ca href=\"https://docs.rs/rayon/\"\u003erayon\u003c/a\u003e. That said, it is still possible to \"mix \u0026#x26; match\"\nif you need to do both. See \u003ca href=\"https://ryhl.io/blog/async-what-is-blocking/#the-rayon-crate\"\u003ethis blog post for a practical example\u003c/a\u003e.\u003c/li\u003e\n\u003cli\u003eReading a lot of files. Although it seems like Tokio would be useful for\nprojects that simply need to read a lot of files, Tokio provides no advantage\nhere compared to an ordinary threadpool. This is because operating systems\ngenerally do not provide asynchronous file APIs.\u003c/li\u003e\n\u003cli\u003eSending a single web request. The place where Tokio gives you an advantage is\nwhen you need to do many things at the same time. If you need to use a\nlibrary intended for asynchronous Rust such as \u003ca href=\"https://docs.rs/reqwest/\"\u003ereqwest\u003c/a\u003e, but you don't need\nto do a lot of things at once, you should prefer the blocking version of that\nlibrary, as it will make your project simpler. Using Tokio will still work,\nof course, but provides no real advantage over the blocking API. If the\nlibrary doesn't provide a blocking API, see \u003ca href=\"/tokio/topics/bridging\"\u003ethe chapter on\nbridging with sync code\u003c/a\u003e.\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch1 id=\"getting-help\"\u003eGetting Help\u003c/h1\u003e\n\u003cp\u003eAt any point, if you get stuck, you can always get help on \u003ca href=\"https://discord.gg/tokio\"\u003eDiscord\u003c/a\u003e or \u003ca href=\"https://github.com/tokio-rs/tokio/discussions\"\u003eGitHub\ndiscussions\u003c/a\u003e. Don't worry about asking \"beginner\" questions. We all start\nsomewhere and are happy to help.\u003c/p\u003e","description":null,"next":{"title":"Setup","href":"/tokio/tutorial/setup"}},"menu":[{"key":"tokio","title":"Tokio","nested":[{"page":{"key":"tutorial","href":"/tokio/tutorial","title":"Tutorial","data":{"title":"Tutorial","subtitle":"Overview"}},"nested":[{"page":{"key":"setup","href":"/tokio/tutorial/setup","title":"Setup","data":{"title":"Setup"}}},{"page":{"key":"hello-tokio","href":"/tokio/tutorial/hello-tokio","title":"Hello Tokio","data":{"title":"Hello Tokio"}}},{"page":{"key":"spawning","href":"/tokio/tutorial/spawning","title":"Spawning","data":{"title":"Spawning"}}},{"page":{"key":"shared-state","href":"/tokio/tutorial/shared-state","title":"Shared state","data":{"title":"Shared state"}}},{"page":{"key":"channels","href":"/tokio/tutorial/channels","title":"Channels","data":{"title":"Channels"}}},{"page":{"key":"io","href":"/tokio/tutorial/io","title":"I/O","data":{"title":"I/O"}}},{"page":{"key":"framing","href":"/tokio/tutorial/framing","title":"Framing","data":{"title":"Framing"}}},{"page":{"key":"async","href":"/tokio/tutorial/async","title":"Async in depth","data":{"title":"Async in depth"}}},{"page":{"key":"select","href":"/tokio/tutorial/select","title":"Select","data":{"title":"Select"}}},{"page":{"key":"streams","href":"/tokio/tutorial/streams","title":"Streams","data":{"title":"Streams"}}}]},{"page":{"key":"topics","href":"/tokio/topics","title":"Topics","data":{"title":"Topics"}},"nested":[{"page":{"key":"bridging","href":"/tokio/topics/bridging","title":"Bridging with sync code","data":{"title":"Bridging with sync code"}}},{"page":{"key":"shutdown","href":"/tokio/topics/shutdown","title":"Graceful Shutdown","data":{"title":"Graceful Shutdown"}}}
83,{"page":{"key":"tracing","href":"/tokio/topics/tracing","title":"Getting started with Tracing","data":{"title":"Getting started with Tracing"}}},{"page":{"key":"tracing-next-steps","href":"/tokio/topics/tracing-next-steps","title":"Next steps with Tracing","data":{"title":"Next steps with Tracing"}}},{"page":{"key":"testing","href":"/tokio/topics/testing","title":"Unit Testing","data":{"title":"Unit Testing"}}}]},{"page":{"key":"glossary","href":"/tokio/glossary","title":"Glossary","data":{"title":"Glossary"}}},{"page":{"key":"api","title":"API documentation","href":"https://docs.rs/tokio"}}]}],"app":{"blog":{"date":1790208000000,"key":"2026-09-24-topcoat-server-applications","href":"/blog/2026-09-24-topcoat-server-applications","title":"Topcoat is pushing the boundary of server applications with Rust","menuTitle":"Topcoat is pushing the boundary of server applications with Rust","mdPath":"blog/2026-09-24-topcoat-server-applications.md","data":{"date":"2026-09-24","title":"Topcoat is pushing the boundary of server applications with Rust","description":"September 24, 2026"},"description":"September 24, 2026"}}},"__N_SSG":true},"page":"/[...slug]","query":{"slug":["tokio","tutorial"]},"buildId":"Sbzh4LmpQAwZi0cg4N5YE","isFallback":false,"gsp":true,"scriptLoader":[]}</script>
83</body></html>

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.