


摘 要: Moodle 2需要運行在PHP 5.3平臺上,如何利用PHP 5.3通過PHP-FPM服務器管理PHP FastCGI進程的特性來提升Moodle 2系統性能是一個亟待解決的關鍵問題。為此,提出了一種基于LNMP的Moodle 2分布式計算架構,并成功研制出樣機。經功能測試和性能測試表明,該系統較單服務器系統提高了5倍的并發訪問能力,而CPU使用率卻降低了26.2%,實現了Moodle 2的高并發和高速訪問,并具有負載均衡、彈性伸縮和容錯性強的特點,為PHP系統特別是Moodle 2系統的大規模推廣應用提供了重要技術參考。
關鍵詞: Moodle; LNMP; 分布式系統; 高并發; 高性能
中圖分類號:TP302.7 文獻標志碼:A 文章編號:1006-8228(2013)06-05-04
Moodle 2 distributed computing architecture based on LNMP
Zeng Zonggen
(Electronic Information Engineering Department, Ningbo Polytechnic, Ningbo, Zhejiang 315800, China)
Abstract: Moodle 2 operates on PHP 5.3 platform. It is an urgent problem how to use PHP 5.3's characteristic of PHP-FPM server managing PHP FastCGI process to enhance the Moodle system performance. Moodle 2 distributed computing architecture based on LNMP is proposed. A prototype is developed successfully. The functional testing and performance testing show that five-fold increase concurrent access capability is obtained compared to the single-server systems, while CPU usage is reduced by 26.2%. Moodle 2's high concurrency and high-speed access are achieved, together with characteristics of balance, flexibility, fault-tolerance, which provides an important technical reference for PHP system and especially for the Moodle system's large-scale application.
Key words: Moodle; LNMP; distributed system; high concurrency; high performance
0 引言
Moodle 2是澳大利亞Martin Dougiamas博士主持研發的第二代Moodle免費開源網絡課程平臺[1],其功能之強大使得在全球范圍內掀起了一股Moodle 2升級、應用熱潮。
但由于Moodle 2要求運行在PHP 5.3以上,而PHP 5.3是PHP技術發展的分水嶺,它采用PHP-FPM[2]服務方式管理PHP FastCGI進程,如何利用這一特性來有效提高Moodle 2訪問速度和并發處理能力是一個亟待解決的關鍵問題。
本文經過深入研究與實驗,成功研制出一種Moodle分布式計算架構,使用源代碼編譯方式成功編譯、安裝、優化了LNMP[3],并在LNMP上安裝了Moodle 2系統,樣機連接地址為http://61.164.87.150:5483/,經httperf測試證實,該樣機實現了Moodle 2的高性能。
1 Moodle 2分布式計算架構
Moodle過去多運行在WAMP[4]或LAMP[5]架構上,性能方面表現得總是不太理想。而采用LNMP分布式計算架構,即CentOS+Nginx+MySQL+PHP,能有效解決上述問題,主要原因:
⑴ 高并發下CentOS操作系統(Linux 2.6+內核)的epoll網絡模型CPU利用率較Windows操作系統僅有的select網絡模型高很多[6];
⑵ Nginx是由俄羅斯人Igor Sysoev設計的開源、高并發HTTP和反向代理服務器[7],據業界測算,它可支持單臺服務器超過3萬的純PHP腳本并發訪問,性能超過Apache服務器的10倍之多;……