How does Facebook handle billions of async requests?

<p>It&rsquo;s not fair to ask that type of question, as there is so much going on at Facebook, and handling billions of parallel requests relies on many things. And there is no diagram that can illustrate that. So instead let&rsquo;s focus on a system that Facebook developers built known as Async.</p> <p><em>Some of&nbsp;</em><strong><em>async requests</em></strong><em>&nbsp;can be executed at different times, for instance, notifications about a new message, a post from a friend, or a Facebook Live stream starting. Some of these may be more time-sensitive than others.&nbsp;</em><strong><em>To manage the different levels of urgency for different types of async requests, we built a system called Async.</em></strong><em>&nbsp;The original Async was a simple system, but as our apps and services have grown, we needed to scale to manage a greater volume of requests.</em></p> <h1><strong>Before re-architecting Async</strong></h1> <p>In the original version of Async, all the asynchronous requests were processed and stored in a centralized database. Dispatchers would then query and sort the requests stored in those databases. Later, when the dispatcher pulled jobs from the database and sent them to the worker servers, the sorting operation would provide some basic prioritization based on the request&rsquo;s desired execution time.</p> <p><img alt="" src="https://miro.medium.com/v2/resize:fit:700/0*d4-D8rEs_gSdbXYE" style="height:253px; width:700px" /></p> <p>At that time, Facebook had three priorities, and inside each priority queue, it was first come, first served. When new use cases were introduced, they just added more workers. This is not a great solution at scale, because smaller use cases would have to wait in the queue for a chance to run. This was not a big problem if we speak about small system. But when dealing with billions of requests this is not a good design at all.</p> <h1><strong>Main challenges were:</strong></h1> <ol> <li>Prioritization<br /> <strong>Which request to run first</strong>. There are bunch of features: user sends a message, posts a picture, Safety Check during natural disasters, someone liked a post, etc. How does the system determine which action to complete first? To help the system understand what to prioritize, developers introduced the concept of delay tolerance, or how long each request can be delayed.</li> </ol> <p><a href="https://medium.com/@dmosyan/how-does-facebook-handle-billions-of-async-requests-8b00abf32b69">Visit Now</a>&nbsp;</p>
Tags: Facebook Async