3-Tiers of Client Server

Steven F. Lott

Consultant, CTG

1. What’s your worst nightmare?

Large, Complex Systems

Large Database (over 2 Gb)

Complex Graphical User Interface (GUI)

Large user base

  • 100’s, 1000’s, Growing daily
  • Untrained users, casual users, infrequent users

High availability

  • 7x24

Network

  • Wide-Area (WAN)

What can you do?

  • Panic
  • Flee
  • Subcontract
  • Use Single Vendor Solutions
  • Microsoft, Novell, Oracle, IBM, ?
  • Switch Careers
  • Separate the Concerns

That’s Okay, but...

Separating Concerns allows us to

  • Focus on issues
  • Use standard interfaces between components
  • Use specialists’ skills

How do you put it all together?

  • Why can’t there be an off-the-shelf solution?
  • Why such an integration headache?
  • What happened to mainframes?
  • How will it all work?

“Reference Architecture”

What is an architecture?

  • List of components
  • Hardware
  • Software
  • Connectivity

Specifications

  • Performance, size, interface compatibility

Version Identification

Part of Design, Build and Test Efforts

Where do I get reference architectures?

CS/10000

  • A software product that defines many combinations

Trade Magazines

Big DB Box Example

  • Big UNIX Engine (RS/6000, Alpha, SPARCserver, etc.)
  • 128-256MB RAM,
  • 8Gb Disk (8 1G drives)
  • ORACLE 7.2.2 (or Informix or Ingres)
  • Intersolve’s ODBC
  • x MIPS, y TPS

2. Typical Architectural Patterns

Some Patterns

  • Server Only
  • Workstation Only
  • 2-Tier Client-Server
  • Fat Client
  • Thin Client
  • 3-Tier Client-Server

Server Centric

Mainframe & Terminals

Issues

  • The old “single-point of failure” mode
  • Maintenance downtime limits availability
  • Access can be limited by network bandwidth
  • GUI + DB too much work for any processor

Easy to administer

  • 1 app. and 1 DB in 1 location
  • Handles big DB’s

Workstation Only

PC with MS-Access or FoxPro

Issues

  • No central DB
  • No security
  • Configuration management nightmare
  • How do you get consistency in uncontrollable desktops?
  • 100’s or 1000’s of users?

Easy and Fun development environment!

Client-Server

Generally, workstation plus server

Simple as a file server with a central “DB” file

Issues

  • Processing – Server side or client side?
  • Security – Who can do what to the server?
  • Configuration Control – who is running what?

Two variants - fat client vs. thin client

Fat Client

Everything done on the workstation

  • Visual Basic, Power Builder, Delphi
  • Server has a skinny database

Issues

  • Client growth impossible
  • Network traffic server to client
  • Long-running (background) processing
  • Complex, fragile applications
  • Shared development on PC’s?
  • Runtimes on PC’s
  • Software distribution and configuration control

Thin Client

Everything done on the server

  • Server has all application programs and database
  • Client has presentation only

X-windows, Web Browsers, ActiveX controls for VB

  • Reduces the server’s load associated with a GUI

Issues

  • Server load, server growth
  • Complex fragile application

3-Tiers

Focus the processor loads

  • Client side does GUI and only GUI
  • App. Server does application processing
  • DB Server does DB and only DB

Example 1

  • PC running Oracle Forms 4.5
  • SQL*Net over TCP/IP to Oracle7 RDBMS running PL/SQL stored procedures
  • SQL*Net over TCP/IP to Oracle7 RDBMS with actual data objects

Example 2

  • PC running NetScape 3.0 with Java Applets
  • TCP/IP to Server running Java Applications
  • JDBC to Oracle7 RDBMS

Example 3

  • Visual C++ running on PC
  • CORBA over TCP/IP to application server running C++ applications
  • CORBA over TCP/IP to OODB (Ontos or O2) with persistent objects

Example 4

  • VB on PC
  • TCP/IP to application server with C++ applications
  • ODBC over TCP/IP to RDBMS with actual database

Why are 3 tiers so good?

Client is small, easy to configure, support & replace

  • Simple solution deployed everywhere
  • Minimal support

Appl. server is Centrally administered

  • No configuration nightmare
  • Plenty of room for growth
  • Background and batch processing is trivial
  • Security via Unix (Or NT or whatever)

DB server highly optimized

  • Expandable “disk farm”
  • No other processing on this box

3. Tech-Talk

How they Connect

VB client to C++ app. server

C++ app. server to Oracle RDBMS

Issues

  • VB not object-oriented
  • RDBMS not object-oriented

Benefits

  • Huge Speed
  • Thin Client

VB to C++ app. Server

Invent a new TCP/IP protocol for your application

  • Define all the transactions and responses
  • You have to do it anyway as part of analysis

Get Comer’s book and write a TCP/IP server

  • Only a hundred lines of simple C

Write your C++ application server

Write VB client presentation

VB Client Focus

VB does ONLY presentation

  • No business processing
  • No direct access to RDBMS

User actions become transactions

  • send through TCP/IP to app. server
  • Responses are displayed

C++ App. Server Focus

C++ does all business processing

  • Must handle all requests from VB and provide a response
  • Keeps the central transaction journal
  • And debugging log

Must be very expandable

  • Should have a unique class for each type of transaction

C++ to RDBMS

  • ODBC or Oracle’s Pro*C 2.0
  • Create a “mixin” or strategy design pattern to implement SQL access for C++ classes
  • Transactions will create objects from fetches of table rows
  • Changes to objects will lead to updates and inserts
  • Destruction of an object will lead to a database delete
  • Much processing should be PL/SQL in the DBMS

Caution

  • Be careful of keeping C++ objects which are supposed to reflect DB actions
  • DB can’t notify C++ when underlying DB object has changed
  • C++ must create objects based on DB fetches, do work, update DB with final object state

Also

Objects have unique identity

  • Irrespective of any Relational Key values

You may need to introduce surrogate keys

  • Meaningless identifiers for each row
  • Implements a formal “Object ID”
  • Use Oracle Sequence Generators to guarantee uniqueness

4. How do I do it?

Learning

Learn a little about Object Oriented Analysis and Design

  • DB Server has “Objects” and their static attributes
  • App. Server has access methods for the objects
  • Client has presentation which displays objects and activates processing methods.

Learn about Dynasty and Forte

  • tools to build large 3-tier systems

Details depend on your role

I’m a Consultant

I help with package selection, vendor selection, etc.

Be sure you can separate buzz-word compliance from a real architecture

  • Where is security handled, which tier?
  • How can high-availability be achieved?
  • Where is their architecture scaleable?
  • Can they add more app servers?
  • Can they add more DBMS servers?

Be sure each component plays to its strengths

Determine the level of standards compliance

I’m an Integrator (Installer)

I install hardware and software

Be sure you know how many boxes are appropriate for what types of loads

  • How servers (app. & DB), what size?
  • What is the transport protocol?
  • How do I test connectivity to be sure everybody can talk?
  • How do I assure service levels? What kinds of spares do I need?
  • Backups? How often?
  • Recovery? How Difficult?

I’m a Developer (Designer, Architect)

I create new software or modify software

Be sure you know how responsibilities are allocated

  • Does the transport protocol timeout, hang or crash when a host dies?
  • Is there a transaction manager to handle load leveling?
  • Does the DBMS do locking automatically?
  • Can SQL clone a table or do I have to write a cursor loop to select and insert each row?
  • Where in the architecture feature <I>X </I>is handled?

Final Notes

The World-Wide Web

For an outstanding 3-tier architecture, log onto the web. Any site with a search engine has three tiers.

  • Your PC is presentation
  • The Web server (www.altavista.com) does the application
  • Another box you can’t see has the database

http://www.altavista.digital.com/

Oracle’s WebServer 2.0 is an convenient integration of Web server and DBMS connectivity

But I don’t want to emulate the Web

Okay, build your client in VB, PB, Visual Objects, Visual C++, Java...

Completely isolate all non-presentation logic into application server libraries

  • This is really, really hard–it takes a lot of discipline
  • Developers always want an easy way out and will circumvent this to meet their deadlines

Completely isolate all data storage into the database

  • This is easy, now that everyone accepts SQL as the one true data access method

Are there any risks?

Yes, you will always have trouble with creating a clean application server

  • Any application services layer is better than none
  • Build the GUI last, after you understand the application

Your products may not cooperate if they are non-standard

Only pure TCP/IP will really plug and play

  • IPX/SPX is high risk

Microsoft created most of the problem with desktop compatibility

  • Trusting them to provide a solution doesn’t seem right

What will the rewards be?

CSX rolls out a major system in Java for under $1M

  • Upgrading their old DOS system would have been $7M

One of my clients had a PB job that would have taken a stand-alone P90 3 months to complete

  • Using Windows NT server, WFW client and SQL changes we got it down to 3 hours

6 Key Points

    1. Big, growing applications require scalable architecture
    1. Separate 3 tiers: client, application server, database server
    1. Client does only presentation
  • TCP/IP Protocol to application server
    1. Application Server does all processing
  • ODBC (or SQL*Net) protocol to database server
    1. Know Standards Compliance and Performance
    1. Learn from WWW applications (CGI’s, Java, etc.)