基于Node.js高并發(fā)web系統(tǒng)的研究與應(yīng)用
發(fā)布時(shí)間:2018-01-26 20:31
本文關(guān)鍵詞: Node.js 高并發(fā) 事件驅(qū)動(dòng) 異步I/O 出處:《電子科技大學(xué)》2014年碩士論文 論文類型:學(xué)位論文
【摘要】:隨著互聯(lián)網(wǎng)技術(shù)的深入發(fā)展和廣泛應(yīng)用,越來越多的網(wǎng)站面臨高并發(fā)訪問的壓力。保證高并發(fā)Web系統(tǒng)的高效性和穩(wěn)定性是當(dāng)今Web技術(shù)中的重要課題。傳統(tǒng)的方法主要通過負(fù)載均衡、緩存、集群等后端架構(gòu)來提升其并發(fā)處理能力,而對(duì)于HTTP服務(wù)器本身性能并沒有太大的提升。Node.js技術(shù)是當(dāng)今最熱門的服務(wù)器端技術(shù)。它在保持與傳統(tǒng)技術(shù)兼容的情況下,采用基于事件驅(qū)動(dòng)的異步I/O模型,極大地提高了HTTP服務(wù)器的并發(fā)性能。因此,研究基于Node.js的高并發(fā)Web系統(tǒng)有著重要的現(xiàn)實(shí)意義。本文分析了高并發(fā)Web系統(tǒng)面臨的挑戰(zhàn),從一些大型高并發(fā)網(wǎng)站架構(gòu)入手,總結(jié)現(xiàn)有的高并發(fā)解決方案。接著,研究了Node.js的組織架構(gòu)和工作原理,將Node.js的I/O模型與傳統(tǒng)I/O模型進(jìn)行對(duì)比,詳述了多線程多進(jìn)程模型的弊端以及Node.js的核心技術(shù)——基于事件驅(qū)動(dòng)的異步I/O模型,并分析該模型在高并發(fā)、高負(fù)載環(huán)境下的性能優(yōu)勢(shì)。由于Node.js原生是單線程的工作模式,為了利用服務(wù)器多核的優(yōu)勢(shì),本文在深入研究各種Node.js多核方案的基礎(chǔ)上,設(shè)計(jì)了一種簡單、高效的Node.js多核并行框架,并基于該框架實(shí)現(xiàn)了Node.js多核HTTP服務(wù)器。該服務(wù)器不僅發(fā)揮了Node.js模型在高并發(fā)以及I/O性能方面的優(yōu)勢(shì),而且解決了由于Node.js單線程導(dǎo)致的多核CPU利用率的問題,使得HTTP服務(wù)器的并發(fā)性能得到極大地提升。為了與實(shí)際應(yīng)用相結(jié)合,本文設(shè)計(jì)并實(shí)現(xiàn)了一個(gè)基于Node.js的微博系統(tǒng)。首先,提出該系統(tǒng)的總體架構(gòu)。然后,基于MongoDB設(shè)計(jì)了數(shù)據(jù)模式,實(shí)現(xiàn)了數(shù)據(jù)的持久化存儲(chǔ)。接著,利用Redis設(shè)計(jì)了分層的緩存層,實(shí)現(xiàn)數(shù)據(jù)在內(nèi)存級(jí)存儲(chǔ)。還引入并實(shí)現(xiàn)了RabbitMQ消息隊(duì)列,降低了HTTP服務(wù)器的壓力,提高吞吐量。最后,本文在真實(shí)環(huán)境中對(duì)該系統(tǒng)進(jìn)行了測(cè)試,并與傳統(tǒng)實(shí)現(xiàn)進(jìn)行對(duì)比,證明了Node.js更為適合高并發(fā)Web系統(tǒng)。
[Abstract]:With the deep development and wide application of Internet technology. More and more websites are facing the pressure of high concurrent access. To ensure the high efficiency and stability of high concurrent Web system is an important issue in the current Web technology. Traditional methods are mainly through load balancing, caching. A back-end architecture such as a cluster improves its concurrency processing capabilities. However, there is not much improvement in the performance of the HTTP server itself. Node.js technology is the most popular server-side technology today. It remains compatible with traditional technologies. The use of event-based asynchronous I / O model greatly improves the concurrency performance of HTTP servers. It is of great practical significance to study the high concurrent Web system based on Node.js. This paper analyzes the challenges faced by the high concurrent Web system and starts with the architecture of some large and high concurrent web sites. Summarize the existing solutions of high concurrency. Then, study the organization structure and working principle of Node.js, compare the I / O model of Node.js with the traditional I / O model. In this paper, the disadvantages of multithreading and multi-process model and the core technology of Node.js, the event-driven asynchronous I / O model, are described in detail, and the high concurrency of this model is analyzed. Performance advantages in high-load environments. Because Node.js native is a single-threaded mode of work, in order to take advantage of the advantages of multi-core server. Based on the research of various Node.js multi-core schemes, a simple and efficient Node.js multi-core parallel framework is designed in this paper. Based on this framework, the Node.js multi-core HTTP server is implemented, which not only takes advantage of the Node.js model in high concurrency and I / O performance. And it solves the problem of multi-core CPU utilization caused by single thread of Node.js, which greatly improves the concurrent performance of HTTP server. In this paper, a Weibo system based on Node.js is designed and implemented. Firstly, the overall architecture of the system is presented. Then, the data pattern is designed based on MongoDB. Data persistence storage is realized. Then, the hierarchical buffer layer is designed using Redis to store data at memory level. RabbitMQ message queue is also introduced and implemented. It reduces the pressure of HTTP server and improves the throughput. Finally, the system is tested in real environment and compared with the traditional implementation. It is proved that Node.js is more suitable for high concurrent Web systems.
【學(xué)位授予單位】:電子科技大學(xué)
【學(xué)位級(jí)別】:碩士
【學(xué)位授予年份】:2014
【分類號(hào)】:TP393.09;TP311.52
【參考文獻(xiàn)】
相關(guān)期刊論文 前1條
1 凌質(zhì)億;劉哲星;曹蕾;;高并發(fā)環(huán)境下Apache與Nginx的I/O性能比較[J];計(jì)算機(jī)系統(tǒng)應(yīng)用;2013年06期
,本文編號(hào):1466515
本文鏈接:http://www.wukwdryxk.cn/guanlilunwen/ydhl/1466515.html
最近更新
教材專著