Anatomy Twitter "4" floods need quarantine

Source: Internet
Author: User
Keywords HTTP Anatomy 2009
Tags apache cache connections data structure how can how to how to use http
"4" Floods need isolation





if the use of cache is one of Twitter's big points, the other aspect is its message queue. Why use Message Queuing? [14] The explanation is "isolate user requests and related operations so that the peak flow (move operations out of the synchronous request cycle, amortize load over time)".





in order to understand the meaning of this passage, may wish to look at an example. January 20, 2009 Tuesday, President Barack Obama took office and delivered his speech. As the first black president in American history, Obama's inauguration sparked a backlash that led to a surge in Twitter traffic, as shown in Figure 4.








Figure 4. Twitter burst during the inauguration of Barack Obama, 1/20/2009, Tuesday


courtesy Http://farm3.static.flickr.com/2615/4071879010_19fb519124_o.png




At the peak of the
, Twitter received 350 new messages per second, a peak of about 5 minutes. According to statistics, the average Twitter user is "chased" by 120 people, that is to say, the average of 350 messages is sent 120 times [16]. This means that at this 5-minute peak, the Twitter site needs to send 120 = 42,000 messages per second.





face Flood Peak, how can we ensure that the site does not crash? The approach is to quickly accept, but postpone the service. For example, during the dinner rush, restaurants are often full. For new customers, the restaurant attendants are not shut out but let the customers wait in the lounge. This is what [14] says, "Isolating user requests and related operations in order to flatten traffic peaks".





How can quarantine be implemented? When a user visits the Twitter site, it is the Apache web Server that receives him. Apache does a very simple thing, it will be the user's request resolution, forward to mongrel Rails Sever, mongrel is responsible for the actual processing. and Apache Teng shot to meet the next user. This avoids the embarrassment of users not being connected to the Twitter site during the flood peak.





Although Apache's work is simple, it does not mean that Apache can host an unlimited number of users. The reason is that Apache resolves the user request, and after forwarding to the Mongrel server, the process that resolves the user request is not immediately released, but instead goes into an empty loop, waiting for the Mongrel server to return the results. In this way, the number of users that Apache can host at the same time, or more accurately, the number of concurrent connections that Apache can hold (concurrent 50x15), is actually subject to the number of processes that Apache can hold. Process mechanisms within the Apache system see Figure 5, where each worker represents a process.




How many concurrent connections can
Apache hold? [22] The experimental results are 4,000, see Figure 6. How can you improve the concurrent user capacity of Apache? One idea is to not let the connection be subject to the process. You might want to put the connection as a data structure, store it in memory, and release the process until the Mongrel server returns the result, then reload the data structure into the process.





in fact Yaws Web server[24], that's what it does [23]. So it's not surprising that Yaws can hold more than 80,000 concurrent connections. But why does Twitter use Apache instead of yaws? Perhaps because the Yaws is written in Erlang, and the Twitter engineer is unfamiliar with the new language (But you need into house Erlang experience [17]).





Source: (http://blog.sina.com.cn/s/blog_46d0a3930100fd5c.html)-Anatomy of Twitter "4" Floods need isolation _ Deng kan _ Sina blog


Figure 5. Apache Web Server System architecture [21]


courtesy Http://farm3.static.flickr.com/2699/4071355801_db6c8cd6c0_o.png











Figure 6. Apache vs. Yaws. The horizonal axis shows the parallel requests, the vertical one shows the throughput (Kbytes/second). The red curve is yaws and running on NFS. The blue one is Apache, running on NFS while the "green one is" also Apache but on a local file system. Apache dies at the 4,000 parallel sessions, while the yaws is e.g. functioning in over 80,000 parallel. [22]


courtesy Http://farm3.static.flickr.com/2709/4072077210_3c3a507a8a_o.jpg








Reference,





[] Improving running component of Twitter. (http://qconlondon.com/london-2009/file?path=/qcon-london-2009/slides/EvanWeaver_ImprovingRunningComponentsAtTwitter.pdf)


[] Updating Twitter without service disruptions. (http://gojko.net/2009/03/16/qcon-london-2009-upgrading-twitter-without-service-disruptions/)


[] fixing Twitter. (Http://assets.en.oreilly.com/1/event/29/Fixing_Twitter_Improving_the_Performance_and_Scalability_of_the_World _s_most_popular_micro-blogging_site_presentation%20presentation.pdf)


Apache system Architecture. (http://www.fmc-modeling.org/download/publications/groene_et_al_2002-architecture_recovery_of_apache.pdf)


[to] Apache vs Yaws. (http://www.sics.se/~joe/apachevsyaws.html)


[23] queries the performance comparisons of Apache and Yaws. (http://www.javaeye.com/topic/107476)


[] yaws Web Server. (http://yaws.hyber.org/)


[] Erlang programming Language. (http://www.erlang.org/)


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.