Using Generative Design Patterns to Develop Network Server Applications

Using Generative Design Patterns to Develop Network Server Applications

8 1 Using Generative Design Patterns to Develop Network Server Applications Zhuang Guo, Jonathan Schaeffer, Duane Szafron, Patrick Earlx implement a design pattern, a programmer only needs to select Abstract— Design patterns are generic solutions to recurring a pattern template, customize it by setting template options, software design problems. The Correct Object-Oriented Pattern- and provide a few application-specific hook methods. based Parallel Programming System (CO2P3S) uses design Prior to the research reported in this paper, CO2P3S had pattern templates to generate code for design patterns. CO2P3S has been used to generate small parallel and sequential been used to generate simple parallel/distributed applications applications. This research evaluates the utility and from basic concurrent design patterns such as mesh, performance of CO2P3S on larger network server applications. wavefront, pipeline, search-tree, etc. It had also been used to The Network Server design pattern template is introduced, generate simple sequential applications from basic sequential which significantly eases the complexities involved in network design patterns such as decorator, observer, composite, etc. server application development. The Network Server is highly configurable and suitable for the construction of a large Experiments showed that CO2P3S can greatly ease the variety of network server applications, with a diverse range of complexity of parallel application development, and that the functionality and performance requirements. In this paper we generated parallel applications have comparable performance to highlight a generated Web server with performance comparable their handcrafted counterparts [3]. Although these are all small to Apache. applications, the success of CO P S has motivated current Index Terms—network servers, parallel programming, 2 3 programming environments. research efforts to apply it to the generation of larger and more complex applications. In this paper we describe a design I. INTRODUCTION pattern template called the Network Server (N-Server) that was Network server applications are essential to networked created for the construction of network server applications. computation, as they support sharing of critical system The N-Server employs an event-driven concurrency model resources and provide services to multiple clients concurrently. and uses the Reactor [22] pattern as the fundamental Web servers, FTP servers, and e-mail servers are three mechanism for event demultiplexing and dispatching. I/O examples of these applications. The continuing growth and operations must be non-blocking for event-driven concurrency. usage of computer networks has put more demand on various To meet this requirement, Java NIO [12] is employed for non- new network server applications. However, their construction blocking socket I/O, and non-blocking file I/O operations are remains a difficult task, due partly to the limitations of emulated using a pool of threads (because they are not yet conventional tools and techniques. In this research, we available in the Java API). Many design pattern options have experimented with an innovative approach: using generative been created, some of which exist purely to address design patterns to construct network server applications. performance issues, while others deal with features demanded Design patterns are proven solutions to recurring software by many network server applications. These options include design problems [16]. They capture experts’ design knowledge event logging, performance profiling, event scheduling, file and experiences. With design patterns, junior developers can caching, and overload control. The options make the N-Server learn from their seniors’ best practices rather than reinventing highly customizable and suitable for the construction of a the wheel. Although they provide many benefits, design large variety of network server applications with dramatically patterns often exist in the form of documents and fail to different functionality and performance requirements, ranging address one important application development aspect: code from trivial applications (e.g., Time server) to those as sophisticated and performance-sensitive as Web servers. reuse. The CO2P3S (Correct Object-Oriented Pattern-based Parallel Programming System) system overcomes this To evaluate the N-Server, a Web server (COPS-HTTP) and problem by using design pattern templates, a generative an FTP server (COPS-FTP) were constructed. Only a small pattern form that generates correct object-oriented framework amount of code needs to be manually programmed for each code for design patterns [19]. Each template consists of a set server, while the rest of the code is either generated from the of options for adapting the generated code to the specific N-Server or reused from existing application libraries. More application context of the corresponding design pattern. To importantly, the generated code contains all of the complex concurrency control code and the manually written code is simpler server-specific sequential code. An experiment was x Z. Guo, J. Schaeffer, D. Szafron and P. Earl are with the Department of Computing Science, University of Alberta, Canada. Email {zhuang, conducted to compare the performance of COPS-HTTP against jonathan, duane}@cs.ualberta.ca. This work was funded by grants from the Apache, a widely used Web server, and we found that Natural Sciences and Engineering Research Council of Canada (NSERC) comparable levels of performance were achieved. Two and Alberta’s Informatics Circle of Research Excellence (iCORE). 8 2 additional experiments were conducted to demonstrate the and implementation. It is hard to implement an event-driven effectiveness and the ease-of-use of the event scheduling and concurrency model correctly. The lack of OS support for non- automatic overload control features of the N-Server. blocking I/O mechanisms negates the performance advantage The major contributions of this research include: (1) the of event-driven concurrency models. Therefore, a poorly introduction of the N-Server pattern template to support designed event-driven model can fail to achieve good construction of network server applications, (2) evidence that performance. In general, we believe that employing event- the generative pattern template approach can be used to driven concurrency models in a server design is an effective construct larger and more complex applications, and (3) a approach, if complexity and correctness issues can be solved. configurable Web server with a clean framework-based Unlike other design pattern templates in CO2P3S that are architecture that enables the rapid deployment of significantly based on a single design pattern, the N-Server pattern different network server applications, with performance that synthesizes the ideas of four concurrent and networked design scales well with multiple processors and is comparable to that patterns: Reactor [22], Proactor [10], Acceptor-Connector [21], of Apache. Section 2 of this paper describes relevant and Asynchronous Completion Tokens [11]. Both the Reactor background issues. Section 3 gives a brief overview of related and Proactor address the problem of how an event-driven work. Section 4 describes the design of the N-Server. Section application demultiplexes and dispatches events. In the 5 presents the results of several performance experiments. Reactor, different kinds of Event Handlers encapsulate Finally, Section 6 outlines our conclusions and future work. application-specific logic for processing different kinds of events. Each Event Handler has a different implementation of II. BACKGROUND a common hook method. Each Event Handler registers with A network server application needs a concurrency strategy the Event Dispatcher. The Event Dispatcher repeatedly polls to handle multiple requests simultaneously and to scale well for ready events and dispatches a registered Event Handler to when run using multiple processors. Based on how process each one. Unlike the Reactor, which waits passively concurrency is achieved, concurrency models used by server for events to occur and react, the Proactor associates a applications can be grouped into two broad categories: Completion Handler with an asynchronous operation. The multiprogramming and event-driven. Multi-programming Completion Handler encapsulates application-specific concurrency models use multiple operating system functionalities to handle a client request. Upon completion of processes/threads to achieve concurrency. When the execution the asynchronous operation, the associated Completion of one process/thread is paused when performing a blocking Handler is dispatched to process the result. The Acceptor- operation, the CPU can switch to another one, so that client Connector helps to reduce the development complexity by requests are served simultaneously. Although separating two independent aspects of network communication multiprogramming concurrency models are straightforward to applications: data communication and connection implement, they do not scale very well. When the number of establishment. An event-driven application often issues processes/threads is large, the overheads associated with asynchronous operations to acquire one or more services (e.g. multiprogrammingincluding context switching and disk I/O), and a service indicates its completion by sending scheduling, cache misses, and lock contentioncan cause back a response. The Asynchronous Completion

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    8 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us