Architecture

Document Sample
Architecture Powered By Docstoc
					SI540 Understanding Networked Computing




         Architecture
                        Review

• What does code that’s ready for execution look like
  when working with a compiler? An interpreter?
• If you have a source code program that you want to
  execute on two different platforms
   › What modifications, if any, do you have to make to the
     source code if it will be compiled? Interpreted?
   › What else do you have to do to the code to prepare it for
     execution when working with a compiler? An interpreter?
   › What applications do you need for each platform in order to
     prepare and execute the code if you’re using a compiler? An
     interpreter?
• Based on the answers to these questions, which
  code is more portable, compiled or interpreted?

                                                                   2
             Learning Objectives
• Understand the principles of good (modular) system
  architecture
   › Hierarchical decomposition
   › Abstraction
   › Encapsulation
       › Open-closed principle
                                               Next session
   › Layering
• Know common networked computing architectures
   › Client-server (2-tier and 3-tier)
   › Peer-to-peer
• Understand Layered Definition of Information/Data
• Apply these principles in design


                                                        3
            System Architecture
                                             A system is
                                             decomposed
                                             into interacting
                                             subsystems



• Components
   › The parts that interact to make the system
• Functions
   › What the components do
• Interfaces
   › How the components interact
                                                                4
          Computer Architecture

• Components
   › CPU
   › I/O
   › Memory
• Functions
   › CPU: Computation
   › I/O: Communication w/ outside world
   › Memory: storing code and data temporarily
• Interfaces
   › CPU: instruction set
   › I/O: get and put via the bus
   › Memory: Store and load via the bus


                                                 5
     Good System Architectures

• Facilitate abstract (simplified) views of the
  system
• Not too many parts
   › Hierarchy helps
• Natural functional groupings
• Separation of concerns (modular)
   › Limited interaction between parts
   › Parts can be understood/modified/replaced
     independently



                                                  6
                      Example:
                   Browser Modules
• What components/modules might we expect
  a Web browser to include?
   ›   Content fetcher (via HTTP)
   ›   HTML renderer
   ›   User interface
   ›   Preferences
   ›   JavaScript
   ›   Cookies
   ›   Plug-ins
   ›   Others


 Mozilla modules listing is available here http://www.mozilla.org/owners.html
                                                                                7
Hierarchical Decomposition
                   A system is
                   decomposed
                   into interacting
                   subsystems




Each
subsystem
may have its
own internal
decomposition
                                      8
                 Abstraction

• Simplified description
  › Components
     › Omit subcomponents
  › Functions
     › Describe only important functions
     › Omit implementation details
  › Interfaces
     › Omit details of input and output formats


                                                  9
                    Encapsulation

• Enforced abstraction
• Interface provides only way of
  interacting with system
   › Only see input and output, not internal state
• Note: Encapsulation has a more specific meaning when
  talking about Object Oriented Programming
   › Procedures (methods) and data stored together
       › “Data is encapsulated with the methods that act on it”
   › Only way to access data is through methods
       › E.g., “Private” variables in Java
   › We will use the more general meaning

                                                                  10
   Programming Interface As An
    Example Of Encapsulation
• View of a module from the perspective of
  another module interacting with it
  › Tells other modules what services (functions) they
    can expect
  › Tells module implementer what services have
    been promised
• In the figure below, what does implementer of
  module 1 know about module 2?         Assume
                                                 encapsulation

      Module 1   Action(parameters)   Module 2



                      Returns                                    11
          eBay’s API Revisited

• What service is promised by each of the
  functions shown below?
• What must a module do in order to have
  the service provided?


Get_Auctions(sellerID)  array_of_auctions

Leave_Feedback(userId, transactionID, score,
  comment_text) {OK || error_code}

                                               12
  Changing Module Functionality

• Sometimes a module implementer wants to extend
  the functionality of an existing module
• Suppose eBay wants to make it possible for a
  program to retrieve closed auctions for a user
• One idea would be to change the Get_Auctions
  interface
Get_Auctions(sellerID)  array_of_auctions
                                
Get_Auctions(t1, t2, userID)  array_of_auctions

• What’s wrong with this?
   › Old applications, which rely on the original interface, will stop
     working
                                                                         13
       Preserving Flexibility:
     The Open-Closed Principle
• Can always change how functions are
  implemented, without changing the interface
  › Modules only interact through interfaces
• What about changing the existing interface?
  › Other modules will break
• Open-closed principle states that a module is
  › Open for extension
     › You are allowed to provide additional functionality
       through additional interfaces
  › Closed to modifications
     › You are not allowed to change existing interfaces

                                                             14
             Applying
      The Open-Closed Principle
• Idea 1: Change Get_Auctions interface
Get_Auctions(t1, t2, userID)  array_of_auctions
   › But then all old applications will stop working
• Idea 2: Add a new Get_closed_Auctions interface
Get_closed_Auctions(t1, t2, userID)  auctions

   › Get_Auctions(userID) works the same as before
   › This obeys the open-closed principle
• Some languages allow for “overloading” an interface
   › Get_Auctions could be name for both original and new
     subroutine
   › If three parameters passed, second version assumed

                                                            15
Topics for Discussion:
• Components
• Functions
• Interfaces
• Alternative
   decompositions?
    › Are there other
      natural functional
      groupings
• Encapsulation?
    › What functions
      do you think
      should be
      encapsulated?
• Open-closed
  principle?
    › Do you think the
      site obeys the
      open-closed
      principle?

                       16
               Client-Server
            Network Architecture
• Client-server
   › Computers perform different (asymmetric) functions
   › For example, client provides user interface while the server
     provides database functionality
• Interface and protocols constrain the interactions
   › What requests clients can make
   › How servers respond
   › Rules dictating the sequence of requests
• Server may act as client to other servers

                    Client             Server



                                                                    17
   Two- Vs. Three-tier Architecture
                            Web
    Web                    Server                 DB
  Browser                                        Server




• What’s wrong with two-tier architecture?
  › Server may get overloaded;
  › Some operations may be faster or slower than
    others, so making lots of copies of whole server is
    not the most efficient solution
• Instead, divide task by function                        18
            MIRLYN Example

• Retrofitting a web interface onto a
  legacy system
• MIRLYN originally:
  › Used a command-line interface
  › Assumed user was working at a dumb
    terminal
     › That is, a machine providing input and
       output, but no processing
• Now MIRLYN is accessible via the Web

                                                19
Command-line + Dumb Terminal




                               20
Web Interface




                21
           MIRLYN Architecture
                             Web
   Web                      Server                 MIRLYN
 Browser                                          Mainframe




• Web server translates between Web browser and
  mainframe
   › Collects input via browser
   › Pretends to be a dumb terminal when passing input to and
     receiving output from the MIRLYN system mainframe
   › Formats output for display on browser
                                                                22
          MIRLYN And The
        Open-Closed Principle
• What other functionality might we add to
  MIRLYN?
  › How would the system developers implement
    these new functions without causing other
    programs to break?




                                                23
                   Layering

• Interactions only between adjacent layers
  › 3-tier MIRLYN architecture is one example

                  Web Browser

                   Web Server
               MIRLYN Mainframe

• Layering is a special case of decomposition
• Each subsystem is a “layer”

                                                24
        Layer above is a client of the
        layer below

                        Each layer provides actions to
                        (services) the layer above….

         ….by adding its own unique
         capabilities to the layer below….

….by invoking the actions (utilizing the
services) of the layer below.

                            Layer below is a server
                            to the layer above


                                                         25
                     Summary

• (Networked) computing systems are complex
  › Good architecture makes building them a more
    manageable task
• Principles of good (modular) system
  architecture
  › Hierarchical decomposition
  › Abstraction
  › Encapsulation
     › Open-closed principle
  › Layering


                                                   26
                         Review

• Hierarchical decomposition
   › Describe one possible decomposition of the postal service
• Abstraction
   › Give an abstract description of sending a piece of mail
• Encapsulation
   › What would sending mail look like if the process were
     encapsulated? If it weren’t?
   › How would your experience of the process (the interface)
     change if the postal service added optional 2-day delivery?
       › Give an example of a change the would violate the open-
         closed principle
• Layering
   › What are performance limitations of a two-tier architecture?
   › How does a three-tier architecture help?
                                                                    27
             Learning Objectives

• Understand the principles of good (modular) system
  architecture
   › Hierarchical decomposition
   › Abstraction
   › Encapsulation
                                                       Today
       › Open-closed principle
   › Layering
• Know common networked computing architectures
   › Client-server (2-tier and 3-tier)
   › Peer-to-peer
• Understand Layered Definition of Information/Data
• Apply these principles in design

                                                         28
               More About
        Interfaces And Protocols
• Interface constrains the interactions
   › What requests one computer can make
   › How other computers respond
• Protocols constrain sequences of requests
   › Analogous to protocols of behavior
   › Stateless protocols
       › Instruction can be given any time, regardless of what other
         instructions have been given
       › For example, it is always acceptable to make quiet
         conversation at a cocktail party; it is never acceptable to
         dance on the tables
   › Protocols with state
       › Some instructions must be performed in a specific order
       › For example, when addressing royalty, you may only
         speak when first spoken to
                                                                       29
Client-Server Versus Peer-to-Peer
       Network Architecture
• A simple distinction
   › Client-server
      › Computers perform asymmetric functions
   › Peers-to-Peer (P2P)
      › Computers perform symmetric functions
• Different architectures offer different benefits
• Pure P2P networks are rare
   › Most P2P networks rely on centralized server for
     some functions


                                                        30
       Client-Server File Sharing

• Server(s) perform all file sharing tasks
   › All files stored on server(s)
   › All queries regarding file availability addressed by
     server(s)
   › All files transmitted from server(s)
• Therefore, server(s) constrain performance
   › Can only hold as many files fit in server storage
   › Query response time dictated by server speed
   › Files transmitted over server network connection
     with limited capacity


                                                            31
 Client-Server File Sharing
 The MP3.com Architecture

                   1. Have any
Machine A         Metallica songs?

                       2. Yes
                3. Please send one

                    4. Here it is
                                             MP3.com

     Note: A few years ago, a band called
     Metallica sued a file sharing service
     (Napster) for allowing illegal music
     exchange over it’s network.
                                                       32
        Peer-to-Peer File Sharing

• At least some tasks are distributed among peers:
   › Files stored on and transmitted from peer hosts
   › Queries regarding file availability addressed by peer hosts
• Distributed tasks are not limited by server
  performance
   › Network can hold as much as can be stored on all peers
   › Transmission costs shared by all peers
   › Each peer contributes to responding to queries
• For example,
   › Napster distributed file storage and transmission
   › File availability was centralized



                                                                   33
Contrast with mp3.com

                Peer-to-Peer File Sharing:
                The Napster Architecture
                        Machine A
                                               1. Who has
                                              Metallica songs?


                                                 2. B, C,
                                                 and F do

         3. Please send                                             Napster.com
                              4. Here it is
         Metallica song




                                        Machine D           Machine F         34
   Machine B            Machine C
           Other Peer-to-Peer
       File Sharing Architectures
• Gnutella
   › Like Napster, distributed file storage and transmission
   › Added the ability to distribute file discovery
       › Ask your direct peers who else they know
       › Query those machines directly
• BitTorrent
   › No file discovery mechanism
   › No long-term file storage
   › Shares transmission burden among many users
       › Intended to provide rapid, wide-spread distribution of a
         large, popular file
       › Every machine downloading an in-demand file serves that
         file to other machines
       › Original source just tracks which machines are
         downloading, and tells new download requesters about
         others currently involved in downloading                   35
      Client-Server vs. Peer-to-Peer

• Advantages of CS          • Advantages of P2P
  ›   Know where to look      › Distribute workload
  ›   Server optimization     › No single point of
  ›   Server availability       failure
  ›   Data consistency        › No single point of
                                control




                                                      36
     Client-Server or Peer-to-Peer
           For These Apps?
•   Calendar and scheduling
•   Collaborative authoring
•   Remote conferencing
•   Newsgroup




                                     37
   Client-Server Architecture and
          Ultra-Thin Clients
• Almost all the functions on the server
• Client still does
   › I/O with user
• Client does not do
   › Storage
   › Application processing
• Different from a dumb terminal?
   › Graphical User Interface
   › Mouse
• Examples
   › “Network Computers” (NCs), Citrix, etc.


                                               38
   Application Service Providers
              (ASPs)
• Applications hosted off-premises
• ASP provides
  › Hardware and software
  › System maintenance
  › Customer support
• Client
  › could be ultra-thin
  › or a PC that just doesn’t use much of it’s capability
     › For example, use browser to provide user interface,
       while performing all computation and storage at ASP


                                                             39
                        ASPs

• What are the criteria for deciding which
  applications are good candidates?
  ›   Good connectivity
  ›   Many users (not too customized)
  ›   Difficult to administer locally
  ›   No concern over control over data
  ›   No concern over data security
       › Or ASP’s system more secure than system of
         organization using ASP’s services
• Examples?


                                                      40
                       Layering
• Usage so far:
   › Components in one layer/tier interact only with
     adjacent layers/tiers
• Typical usage of “layer” is analogous, but a little
  different
   › Adjacent layers are at different levels of abstraction
      › E.g., subcomponents define another layer
          › Higher level component can interact with all the
            components at the next layer down
   › Don’t skip layers…
      › Top-level component doesn’t directly interact with a
        subcomponent of a subcomponent


                                                               41
 Rethinking Data and Information
• Example: opinion poll
  › Layer 4: the President is (not) popular
  › Layer 3:                              Responses

                     350
                     300
                     250
             count




                     200
                     150
                     100
                     50
                      0
                           Excellent   Good     Fair   Poor   No opinion



  › Layer 2: codebook and coding of results
  › Layer 1: transcripts of telephone interviews
• Which stuff is information? Data?                                        42
         A Relative Definition

• Information is an interpretation of data
• Data is how we represent information
                 Information is an interpretation of data
  Information    based on known and consistent
                 structure of stuff in the data layer



                 Representation is a coding of
                 information by data in a form that can
Representation   be manipulated by operations at the
   as data       data layer to yield results that are
                 meaningful at the information layer        43
       Is the Definition Circular?

• Sort of, but it’s useful nonetheless
• You pick a starting point for analysis
   › Data layer
      › interpret to get information
   › Information layer
      › Represent to get data
• You can pick a different starting point later!
   › The thing hasn’t changed
   › Just your analysis of it


                                                   44
         Layered View of Bank
         Account Information
I.       Bank account object
     ›        What are the operations at this layer?
     ›        Represent as three component elements
         1.        Account number                                   Accounts
         2.        Account holder name                              Balances
         3.        Bank Balance                                     Numbers
               ›      What are the operations at this layer?        Strings
               ›      Represent as a number
                     ›    What are the operations at this layer?
                     ›    Represent as bit strings
                     What are the operations at bit string layer?
                     Is there another layer below this?



                                                                          45
              Layered View of
          Bank Account Information
                          Information     Account
                                          balances



 Information
                                          Numbers
                         Representation
                            as data

Representation                            Bit stings
   as data

                                                 46
         Layered View Of An
          eBay User Record
• Describe an eBay user record at three
  different layers
  › Model your description on the layered view
    of bank account information we just
    discussed




                                                 47
  Network Computing
   Software Layers


         Applications

     Application components

        Middleware

      Operating system

          Network

Why are new layers introduced?
                                 48
                Summary

• Peer-to-peer and client-server
  architectures
  › Different architecture make sense in
    different situations
• Layered view of data/information
• Software layers



                                           49

				
DOCUMENT INFO