ѧ
Journal of Software
2000 Vol.11 No.1 P.122-125



һInternetʵ
ԡáʿҢȪԴ
ժҪеĽInternetƿͿɿķڵĲ,IP㸺ƽȵĽ,һһġ߿õInternet.ͨڷȺ͸ؼɾʵϵͳ;̹ͨϺȷϵͳﵽ߿.ϸInternetϵṹƷʵּ,ӦܲԽ.
ؼʡInternet,ƽ,߿,ַת.
ͼšTP393
Design and Implementation of a Virtual Internet Server
ZHANG Wen-songWU Ting-tingJIN Shi-yaoWU Quan-yuan
(School of ComputerNational University of Defense TechnologyChangsha410073)
AbstractThe shortcomings of the existing solutions to the performance bottleneck and reliability problem of Internet servers are analyzed, and a solution based on IP-level load balancing is given in this paper, in which a scalable and highly available virtual Internet server can be built on a cluster of servers. Scalability is achieved by transparently adding or removing a node in the cluster. High availability can be provided by detecting the node or daemon failures and reconfiguring the system appropriately. The architecture, design and implementation of the virtual Internet server are discussed in detail. Brief performance testing results are also provided.
Key wordsInternet server, load balance, high availability, network address translation.
ѽΪĵļʱ,ӦöΧ,ԷܺͿɿԽԽߵҪ.,Internetķٷչûľ,ȽŵWebվΪʴܼʱû,ûʱصȴ,󽵵˷.ʱ,WebΪϵͳеƿ.WebϴʹCGIݿCPUܼӦõ,ƿͻ.,ŵȹؼӦϵ,κķж϶ɲɹʧ,˷ĿɿҲԽԽҪ.
ΪЧؽInternetƿͿɿ,Ǹ˻IP㸺ƽȵĽ,һһġ߿õInternet.ͨʹַת,ʹ÷ĸӽṹû͸.ϵͳͨڷȺ͸ؼɾһڵﵽ;ͨڵ̹Ϻȷϵͳﵽ߿.
1 صĽ
ƿзҪΪ3.
(1) .ܻΪƿʱ,򵥵ķǽΪߵķ.÷²㣺 ̷,лʹʱж,ԭмԴ˷ѣ Խ߶˵ķչ,ѵĴԽ󣻢 һ÷ӦʧЧ,ᵼж.
(2) RR-DNSĶ.NCSA(National Center of Supercomputing Applications)ĿWEBϵͳתϵͳRR-DNS(round-robin domain name system)ԭϵͳ13.˼ǣͨRR-DNSWebĲͬIPַ,طֵ̨,Ӷϵͳ.Ȼ,÷һЩ. ϵͳǰνṹ֯,ỺѽֵIPַӳ,Round-RobinڿͻЧ,ᵼ²ͬWEBصĸزƽ.,IPַӳTTL(time to live)ֵ趨,̫,زƽ;̫С,ƵʹRR-DNSΪϵͳһµƿ. ûͻԺͷʷʽͬ,ʹTTLֵΪ0,ĸԴڽصĸزƽ. ϵͳĿɿԺͿάԲ,һ̨ʧЧԱά,ᵼѱ÷ϵûַֹ.
(3) Ӧò㸺ƽȵĶ.EDDIE4,Reverse-Proxy5ݺpWEB6ݶʹûӦòȵķһWEB.ǶHTTPתͬWeb,ȡý,ٷظû.÷ҲһЩ.,ϵͳر,ʹϵͳ.󵽴,Ҫ4δӺûռлԼû͵ʵTCP,Ҫзд.һصĿʱ,ܿΪµƿ.ף7Linux 1.3汾ӦÿٱĲ뼼,ʹýиƽȵû̷豸ӽĿռٶ,лĴ,.,ӦòĸƽӦЭ,HTTP,ProxySMTPӦЭ,Ҫдͬĵ. 
2 Internetϵṹ
InternetûIP㸺ƽȼ,ڲϵͳĿռнIPϵTCPӸؾתƵͬķ,ҵԶεĹ,Ӷһһܵġ߿õInternet.Internetϵṹͼ1ʾ,ĸӽṹû͸,ûǵ,޸Ŀͻ˺ͷ˵ĳ.Ϊ,ʱҪϵͳ͸ԡؾԡݴԺ׹.


Fig.1Architecture of a virtual Internet server
ͼ1Internetϵṹ
2.1͸Ժַת
͸ַͨתʵֵ.ûͨVirtual IP Addressⲿַʷʱ,ĵ,Ըؾⷽһʵѡһ,ĵĿַVirtual IP Addressдѡĵַ,ĵĿ˿ڸдѡӦ˿,󽫱ķ͸ѡķ.ͬʱ,Hashм¼,ӵһĵʱ,HashпԵõԭѡĵַͶ˿,ͬĸд,Ĵԭѡķ.ʵĻӦľʱ,ĵԴַԴ˿ڸΪVirtual IP AddressӦĶ˿,ٰѱķû.ֹʱʱ,ӴHashɾ.,ûֻVirtual IP Addressṩķ,Ľṹû͸.Ըдı,ӦChecksum㷨TCP Checksumֵ8,ɨChecksumĿ.
2.2ƽ
ƽTCPΪȵ.HTTPЭ9,WEBϻȡÿҪһTCP,ͬһûĲͬᱻȵͬķ,ϸȵĵȫûʵͻĸزƽ.ڵ㷨,ǲת(round-robin scheduling)㷨ͻȨֵת(weighted round-robinscheduling)㷨.ת㷨Ǽзܾͬ,νȵͬķ,㷨,ڷдܲһ.Ϊ,ʹûȨֵת㷨,ӦȨֵʾĴ,ĿȨֵı䵽.Ҫ¼ѽTCPӵĿ,ĳ̨ʱ,1ֹʱʱ,1.ÿ̨ȨֵΪWi(i=1,...,n),TCPĿΪTi(i=1,...,n),ѡTi/WiСķΪȶ.㷨ʵҲȽ,޹.
2.3ϼ
ǲַ.һַ,ԴÿtÿARPaddress resolve protocol,зrûӦ,˵÷ѷ,Դ֪ͨ÷з̵ȴӵбɾ.һַ,Դʱÿ̷,ܷؽ˵÷̷,Դ֪ͨ÷̵ȴӵбɾ.Դͨʼ򴫺Ա,һ⵽ָ̻,֪ͨбе.
2.4
κ֧TCP/IPĲϵͳ,ɲκInternet,ҲԿͻκ޸,Internetվ.ͨϵͳṩĹ,Աɷ,ʱһ̨г.
3 ϵͳʵ
Linux 2.0ϵͳԴϼ͸д2 000CԴ,IPȡ͸дIP,ʵ˿Internet,ṩһippfvsadmĹ.ϵͳԴʹ˵Ϸ ,Ѿ6 000.֪,ϵͳӢ¡ĵȹʮվʽʹ.
ϵͳҪģͼ2ʾ,PFVS-Moduleģ,ڽȡ͸дIP;PFVS-tableĹ;Hash of Connectionsڼ¼ǰӵHash.ippfvsadmͨsetsockopt()ĹдPFVS-table,ͨ/procļϵͳPFVS-tableеĹ.

Fig.2Mail modules of the system
ͼ2ϵͳҪģ
4 ܲ
ǶԵ̨WebͶ̨WebɵWebʺʱ˲ԶԱ.ZD LABSWebBench 1.1,Pentium 16632Mڴ100M Intel EtherExpressPC,Linuxϵͳ,WebApache 1.3.1.ͻһPC,6̨,Windows 95/NTϵͳ.ͨ10/100MӦ3Com Switch 3000.WebBenchʱ,һؽ̺ͶģʵĿͻ.ؽɹغͲ,ͻ,ͻطʷ¼,ȲϺؽ̻㱨,ؽ̽ͳ.Խ1.
Table 1Brief testing results of Webserves
1WebܲԽ
Requests per second (GETs/s)Throughput (Bytes/s)Processing delay(ms)
Single Web Server97648.95835.516
Virtual Web Server(2 set)1901269.24538.474
Virtual Web Server(3 set)2821930.93438.928
ÿ봦,,۴ʱ,̨ܵWeb,Web.
,tcpdumpԵµдһĵƽʱΪ60s.һĵƽΪ536ֽڣǱIPӵγȣ,дĵΪ8.93MBytes/s.WebƽΪ600KBytes/s,Ŀ15̨ʱ,Ŵﵽ.ɼ,õ.
5 
ĶԽInternetƿззȽ,ָǴڵĲ㣻˻IPȵĶ,ַͨתƽȡϼ⼼,һṩзķһܡ߿õInternet.÷õ,ҲԿͻͷκ޸,κInternetվ.
ԣѧѧѧԺɳ410073
ãѧѧѧԺɳ410073
ʿҢѧѧѧԺɳ410073
ȪԴѧѧѧԺɳ410073
E-mail: wensong@iinchina.net
ο
1Katz E D, Butler M, McGrath R. A scalable HTTP server: the NCSA prototype. Computer Networks and ISDN Systems, 1994,27(687):155163
2Kwan T T, McGrath R E, Reed D A. NCSA's world wide web server: design and performance. IEEE Computer, 1995,28(11):6874
3Brisco T. DNS support for load balancing. RFC 1794, 1995. http://andrew2.andrew.cmu.edu/rfc/rfc1974.html
4Dahlin A, Froberg M, Walerud J et al. EDDIE: a robust and scalable Internet server. 1998, http://www.eddieware.org/
5Engelschall R S. Load balancing your Web site: practical approaches for distributing HTTP traffic. Web Techniques Magazine, 1998,3(5). http://www.webtechniques.com
6Walker E. pWEBa parallel Web server harness. 1997, http://www.ihpc.nus. edu.sg/STAFF/edward/pweb.html
7Anderson E, Patterson D, Brewer E. The magicrouter: an application of fast packet interposing.1996, http://www.cs.berkeley.edu/eanders/magicrouter/
8Rijsinghani A et al. Computation of the Internet checksum via incremental update. RFC 1624, 1994. http://www.internic.net/ds/
9Fielding R, Gettys J, Mogul J et al. Hypertext Transfer protocolHTTP/1.1. 1997, Http://www.w3.org/Protocols/
1998-10-26ո
1999-03-01޸
