CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

37
CHEN Ge CSIS, HKU March 9, 2000. Jigsaw Jigsaw W3C’s Java Web W3C’s Java Web Server Server

Transcript of CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

Page 1: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

CHEN Ge CSIS, HKU March 9, 2000.

JigsawJigsawW3C’s Java Web W3C’s Java Web

ServerServer

Page 2: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

What is Jigsaw?What is Jigsaw?

• Jigsaw is a Web Server developed Jigsaw is a Web Server developed by W3C. The source code is of by W3C. The source code is of version 2.0.4.version 2.0.4.

• Jigsaw is written in pure Java, and Jigsaw is written in pure Java, and the document of Jigsaw claims the document of Jigsaw claims “Jigsaw will run on any platform that “Jigsaw will run on any platform that supports Java, with no changes”supports Java, with no changes”

Page 3: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

Jigsaw’s Internal DesignJigsaw’s Internal Design

• Basic Concepts in JigsawBasic Concepts in Jigsaw– ResourceResource– FrameFrame– FilterFilter– IndexerIndexer

Page 4: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

Jigsaw’s Internal DesignJigsaw’s Internal Design

– A Resource is a full Java object, A Resource is a full Java object, containing only information that the containing only information that the raw Resource (a file, a directory...) can raw Resource (a file, a directory...) can provide (e.g., for a file, the size, last provide (e.g., for a file, the size, last modification date...) modification date...)

Page 5: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

Jigsaw’s Internal DesignJigsaw’s Internal Design

– A Frame is a full Java Object, containing A Frame is a full Java Object, containing all the information needed to serve this all the information needed to serve this Resource using a specific Protocol (e.g., Resource using a specific Protocol (e.g., HTTPFrame for HTTP). HTTPFrame for HTTP). Jigsaw attaches Frames to Resources to Jigsaw attaches Frames to Resources to handle protocol related activities.handle protocol related activities.

Page 6: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

Jigsaw’s Internal DesignJigsaw’s Internal Design

– A Filter is a full Java Object, associated A Filter is a full Java Object, associated to a Frame, that can modify the to a Frame, that can modify the Request and/or the Reply. For example Request and/or the Reply. For example the Authentication is handled by a the Authentication is handled by a special filter.special filter.

Page 7: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

Jigsaw’s Internal DesignJigsaw’s Internal Design

– A Indexer is also a full Java Object, which trA Indexer is also a full Java Object, which tries ies to create and setup some resource to create and setup some resource automatically. The resources can be automatically. The resources can be created depending on their name or created depending on their name or their extension. Once the resource has their extension. Once the resource has been created, the Indexer is also in been created, the Indexer is also in charge of attaching the right frames to charge of attaching the right frames to this resource, like the HTTP frame, the this resource, like the HTTP frame, the filters and so on. filters and so on.

Page 8: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

Jigsaw’s Internal DesignJigsaw’s Internal Design

• A sample FileResource:A sample FileResource:

Page 9: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

Jigsaw’s Internal DesignJigsaw’s Internal Design

• The inheritance tree of Jigsaw:The inheritance tree of Jigsaw:

Page 10: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

Jigsaw’s Internal DesignJigsaw’s Internal Design

• The ResourceStoreManageThe ResourceStoreManage– Jigsaw use a ResourceStoreManage to Jigsaw use a ResourceStoreManage to

manage all the resource used in the manage all the resource used in the runtime of the server. runtime of the server.

– The ResourceStoreManage’s The ResourceStoreManage’s implementation use some simple cache implementation use some simple cache policy to make the resource reference policy to make the resource reference more efficient.more efficient.

Page 11: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

Jigsaw’s Internal DesignJigsaw’s Internal Design

• The ResourceStoreManageThe ResourceStoreManage– It seems that, if we start multiple It seems that, if we start multiple

Jigsaws on a machine, all the servers Jigsaws on a machine, all the servers will share the same will share the same ResourceStoreManage.ResourceStoreManage.

Page 12: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

How Jigsaw Works?How Jigsaw Works?

• Jigsaw utilize Java’s Jigsaw utilize Java’s threadthread extensively. All the major classes of extensively. All the major classes of Jigsaw are running as Java Threads.Jigsaw are running as Java Threads.

• Jigsaw separates serving document Jigsaw separates serving document into two different processing stagesinto two different processing stages– Indexing StageIndexing Stage

– Serving Stage Serving Stage

Page 13: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

How Jigsaw Works?How Jigsaw Works?

• Separate serving document into two Separate serving document into two stages make the resource lookup stages make the resource lookup and resource sharing more efficent.and resource sharing more efficent.

Page 14: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

How Jigsaw Works?How Jigsaw Works?

• Using an sample http request Using an sample http request handling process in Jigsaw to handling process in Jigsaw to explain how Jigsaw works, and view explain how Jigsaw works, and view some important classes in Jigsaw.some important classes in Jigsaw.

Page 15: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

How Jigsaw Works?How Jigsaw Works?

• When Jigsaw starts upWhen Jigsaw starts up– An instance of the class An instance of the class httpd httpd created. created.

httpd

Page 16: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

How Jigsaw Works?How Jigsaw Works?

httpdInitialize(

) httpd

Indexer

rootmanager

Page 17: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

How Jigsaw Works?How Jigsaw Works?

httpd

Indexer

rootmanagerinitializeServerSo

cket()

• After initialization, the httpd call the After initialization, the httpd call the initializeServerSocket() to create the initializeServerSocket() to create the server socket and the server socket and the ClientSocketFacotryClientSocketFacotry which is a pool of SocketClient.which is a pool of SocketClient.

httpd

Indexer

rootmanager

Server port

factory

Page 18: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

How Jigsaw Works?How Jigsaw Works?

• After create the server socket After create the server socket successfully, httpd creates a thread, successfully, httpd creates a thread, assigns itself to the thread, and runs assigns itself to the thread, and runs as a thread.as a thread.

httpd

factory

Indexer

rootmanager this.thread = new Thread (this); ;…;this.thread.run();

httpd

factory

Indexer

rootmanager

Page 19: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

How Jigsaw Works?How Jigsaw Works?public void run () {

…while ( ( ! finishing) && ( socket != null ) ) { Socket ns = null ; try {

ns = socket.accept() ;ns.setTcpNoDelay(true);

} catch (IOException e) { … } if ( (socket != null) && (ns != null) && (factory != null) )

factory.handleConnection (ns) ;}// Our socket has been closed, perform associated cleanup.cleanup(restarting) ;

}

httpd

factory

Indexer

rootmanager

Page 20: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

How Jigsaw Works?How Jigsaw Works?

• When there’s an incoming When there’s an incoming connection request, the connection request, the httpdhttpd thread uses the client pool to thread uses the client pool to handle the request.handle the request.

httpd

factory

Indexer

rootmanager

/archives/index.html

SocketClientFactoryhandleConnection()

Page 21: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

How Jigsaw Works?How Jigsaw Works?

• SocketClientFactorySocketClientFactory maintains a maintains a pool of pool of SocketClientSocketClients. It first either s. It first either finds a free SocketClient thread in finds a free SocketClient thread in the pool, if available, or kills some the pool, if available, or kills some old connections to get a free old connections to get a free SocketClientSocketClient, if the load have not , if the load have not exceeds the max-load.exceeds the max-load.

Page 22: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

How Jigsaw Works?How Jigsaw Works?

• When the Factory find a free When the Factory find a free SocketClientSocketClient, it bind the incoming , it bind the incoming socket to the socket to the SocketClient,SocketClient, and the and the SocketClientSocketClient will starts a thread to will starts a thread to perform the request.perform the request.

• Because all the Because all the SocketClientsSocketClients run as run as threads, when a connection is bound to threads, when a connection is bound to a a SocketClientSocketClient, the server can keep on , the server can keep on listening on the net for new incoming listening on the net for new incoming requests.requests.

Page 23: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

How Jigsaw Works?How Jigsaw Works?

• Then the Then the SocketClientSocketClient will process will process the incoming request, and calls the the incoming request, and calls the httpd’shttpd’s perform(Request) method to perform(Request) method to lookup for the necessary resources. lookup for the necessary resources. The perform method will return back The perform method will return back a object containing all the resources a object containing all the resources needed to reply the request. needed to reply the request. SoketClient SoketClient uses this object to send uses this object to send back the request result.back the request result.

Page 24: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

How Jigsaw Works?How Jigsaw Works?

• After the request is replied, the After the request is replied, the SocketClientSocketClient close the connection close the connection and return itself to the free and return itself to the free SocketClientSocketClient pool in the pool in the SocketClientFactorySocketClientFactory..

Page 25: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

Some Notices on JigsawSome Notices on Jigsaw

• Jigsaw uses a thread pool (cache) to Jigsaw uses a thread pool (cache) to handle incoming request, instead handle incoming request, instead creates a new process or thread to creates a new process or thread to deal with it.deal with it.

• Jigsaw caches requested resources Jigsaw caches requested resources in a resource hashtable according to in a resource hashtable according to the resource id, in order to reduce the resource id, in order to reduce file system access.file system access.

Page 26: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

Some Notices on JigsawSome Notices on Jigsaw

• When the httpd is looking up the When the httpd is looking up the requested resource, if it is a read requested resource, if it is a read only request, it will only increase the only request, it will only increase the lock number (reference number) of lock number (reference number) of that object, so one resource can be that object, so one resource can be accessed simultaneously by multiple accessed simultaneously by multiple request.request.

Page 27: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

Some Notices on JigsawSome Notices on Jigsaw

• Jigsaw also uses some LRU algorithm Jigsaw also uses some LRU algorithm to discard long-unused resources in to discard long-unused resources in memory. And also kills long idle memory. And also kills long idle connection and connection and SocketClientSocketClient to to decrease the server’s work load.decrease the server’s work load.

Page 28: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

Some Notices on JigsawSome Notices on Jigsaw

• It does not provide direct It does not provide direct configuration method to run it on configuration method to run it on multi-machines cooperatively. But multi-machines cooperatively. But its internal design makes it possible its internal design makes it possible to replace or add some of its classes to replace or add some of its classes to gain new functions.to gain new functions.

Page 29: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

End of JigsawEnd of Jigsaw

Page 30: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

High-performance Web High-performance Web Servers in other Servers in other institutesinstitutes• JAWS---An Web Server in CS Dept., JAWS---An Web Server in CS Dept.,

Washington UniversityWashington University– JAWS’s findings:JAWS’s findings:

• ““Factoring out I/O, the primary Factoring out I/O, the primary determinant to server performance is determinant to server performance is the concurrency strategy”the concurrency strategy”

• ““For single CPU machines, single-For single CPU machines, single-threaded solutions are acceptable and threaded solutions are acceptable and perform well. However, they do not scale perform well. However, they do not scale for multi-processor platforms. “for multi-processor platforms. “

Page 31: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

High-performance Web High-performance Web Servers in other Servers in other institutesinstitutes– JAWS’s findings:JAWS’s findings:

• Process-based concurrency Process-based concurrency implementations perform reasonably implementations perform reasonably well when the network is the bottleneck. well when the network is the bottleneck. However, on high-speed networks like However, on high-speed networks like ATM, the cost of spawning a new ATM, the cost of spawning a new process per request is relatively high. process per request is relatively high.

• Multi-threaded designs appear to be the Multi-threaded designs appear to be the choice of the top Web server choice of the top Web server performers. The cost of spawning a performers. The cost of spawning a thread is much cheaper than that of a thread is much cheaper than that of a process. process.

Page 32: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

High-performance Web High-performance Web Servers in other Servers in other institutesinstitutes– JAWS’ Framework Overview:JAWS’ Framework Overview:

Page 33: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

High-performance Web High-performance Web Servers in other Servers in other institutesinstitutes

– ““... the key to developing high performance ... the key to developing high performance Web systems is through a design which is Web systems is through a design which is flexible enough to accommodate different flexible enough to accommodate different strategies for dealing with server load and is strategies for dealing with server load and is configurable from a high level specification configurable from a high level specification describing the characteristics of the describing the characteristics of the machine and the expected use load of the machine and the expected use load of the server.”server.”

– More on JAW:More on JAW:• http://www.cs.wustl.edu/~jxh/research/rehttp://www.cs.wustl.edu/~jxh/research/re

search.htmlsearch.html

Page 34: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

High-performance Web High-performance Web Servers in other Servers in other institutesinstitutes• Scalable Web Server Architecture Scalable Web Server Architecture

from Lucent & UT Austinfrom Lucent & UT Austin

Page 35: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

High-performance Web High-performance Web Servers in other Servers in other institutesinstitutes• Scalable Web Server Architecture Scalable Web Server Architecture

from Lucent & UT Austinfrom Lucent & UT Austin– Redirection Server is usedRedirection Server is used

– Data is distributed among the serversData is distributed among the servers

– Problem occurs on constantly moving Problem occurs on constantly moving docsdocs

Page 36: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

High-performance Web High-performance Web Servers in other Servers in other institutesinstitutes• Web Server Clusters in UCSBWeb Server Clusters in UCSB

– Master/Slave ArchitectureMaster/Slave Architecture

Page 37: CHEN Ge CSIS, HKU March 9, 2000. Jigsaw W3C’s Java Web Server.

High-performance Web High-performance Web Servers in other Servers in other institutesinstitutes• Web Server Clusters in UCSBWeb Server Clusters in UCSB

– Masters handles static requests.Masters handles static requests.

– Dynamic content requests may be Dynamic content requests may be processed locally at masters, or processed locally at masters, or redirected to a slave node or another redirected to a slave node or another master.master.

– Slaves may be either dedicated or non-Slaves may be either dedicated or non-dedicated.dedicated.