Distributed software Architecture style (C/S,B/S)

Source: Internet
Author: User

Distributed Software Architecture Style

1, three layer C/s structure

2, three layer B/s structure

Learn a lot about other software architectures

Three-layer C/s structure (3-tier C/S Architecture)

§ Layer 1th: User Interface gui-Presentation Layer--Client

§ Layer 2nd: Business logic-Functional Layer-Application server

§ Layer 3rd: Database-Data tier-database server

Basic components:

– Database server

? The database that holds the data and the business logic responsible for data processing;

– Application Server

? Business logic: the processing of data;

– Client application

? GUI: User interface

§ Connectors: Call-back mechanism or implicit invocation mechanism via the network

– Client? à application server: The client sends a request to the application server and receives the returned results.

– Apply Server?à Data server: Application server sends a request to the data server and receives the returned results.

Presentation layer:

§ The user interface part of the application, which is responsible for the dialogue between the user and the application.

§ Check the data entered by the user from the keyboard, display the data of the application output, and check the contents of the data only in the form and value range. Does not contain processing logic about the business itself.

§ Graphical user interface GUI is typically used to enable intuitive operation of the user. Easy to operate, easy to learn and use;

§ At the time of the change. Only the display control and data checker need to be rewritten without affecting the other layers.

§ does not include or include part of the business logic.

function Layer:

§ The body of the application system. Contains most of the business processing logic, usually in the form of business components. such as javabean/ejb/com, etc.); For example, the contract amount is calculated at the time of making the subscription contract, the data is configured according to the fixed format, and the order contract is printed.

§ Gets the user's input data from the presentation layer and processes it.

§ The processing process needs to obtain data from the data layer or update data to the data layer;

§ Processing results are returned to the presentation layer.

§ When users retrieve data, they try to transfer the information about the retrieval request to the functional layer at once. The result data processed by the functional layer is also transmitted to the presentation layer at once.

Typically, there are features in the functional layer that confirm the user's application and access to the database, and the ability to record the system's processing logs.

Data layer:

§ Database management System DMBS, responsible for the management of database data read and write;

§ Accept data query requests from the functional layer. Run the request. and return the query result to the function layer;

§ Accepts data access requests from the functional layer. and writes the data to the database, and the result of the request is returned to the functional layer.

§ Database management system must be able to quickly run large amounts of data updates and retrieval. Today's mainstream is the relational database management system, so. Most of the requirements for transferring from the functional layer to the data tier are in the SQL language.

Strengths:

§ In the case of a large number of users, the three-tier C/s structure will greatly improve performance and flexibility (usually support hundreds of concurrent users, through the cluster up to tens of thousands of concurrent users).

§ Agree to reasonably divide the function of the three-layer structure. Keep it logically relative to independence. Improves maintainability and scalability of systems and software--ui, BL, DB can be reused separately

§ Agree to use the corresponding platform and hardware system more flexibly and effectively. Make

In the handling load capacity and processing characteristics are adapted to the structure of the three-layer clear, and these platforms and components can be well-upgradeable and open.

Each layer of the application can be developed in parallel to select the most appropriate development platform and development language.

§ effectively separated from the presentation layer and data layer using functional layer, unauthorized users can not bypass the functional layer and illegal access to the data layer, for strict security management has laid a solid foundation.

§ Porting legacy systems (systems with older versions) to the three-tier C/s will be easy;

Disadvantages:

§ Three layer C/s structure of the communication efficiency between each layer if not high, even if the hardware assigned to each layer is very strong, it as a whole can not achieve the required performance.

§ Design must carefully consider the three-layer communication method, communication frequency and data volume, which is the same as improving the independence of each layer is the key issue of the three-layer C/s structure-the inherent shortcomings of layered style.

Program:

(1) server-side program Tcpserver.java

Import java.io.*;

Import java.net.*;

public class tcpserver{

publicstatic final int port=8888;

publicstatic void Main (string[] args) throws ioexception{

Establish ServerSocket

ServerSocket s=new ServerSocket (PORT);

System.out.println ("ServerSocket:" +s);

try{

/* Program blocked, waiting for connection. That is, until a client request arrives, the program can continue to run */

Socket ss=s.accept ();

System.out.println ("socketaccept:" +ss);

try {

The connection succeeds and the corresponding I/O data stream is established

DataInputStream Dis=newdatainputstream (Ss.getinputstream ());

DataOutputStream dos=new DataOutputStream (Ss.getoutputstream ());

In the loop. Communicating with clients

while (true) {

String Str=dis.readutf (); Read data from the client

if (Str.equals ("End")) break; When the end is read, the program terminates

System.out.println (str);

Dos.writeutf ("Echoing:" +str); Write data to the client machine

}

Dos.close ();

Dis.close ();

}finally{

Ss.close ();

}

}finally{

S.close ();

}

}

}

Server-Side Execution results are:

SERVERSOCKET:SERVERSOCKET[ADDR=0.0.0.0/0.0.0.0,PORT=0,LOCALPORT=8888]

Socket accept:socket[addr=/127.0.0.1,port=7312,localport=8888]

Test: 0

Test: 1

Test: 2

Test: 3

Test: 4

Test: 5

(2) client-side program Tcpclient.java

Import java.io.*;

Import java.net.*;

public class tcpclient{

public static Voidmain (string[] args) throws ioexception{

Set up Socket,server to "listen" at 8888port of this machine

Socket ss=newsocket ("127.0.0.1", 8888);

System.out.println ("Socket:" +ss);

try{

Socket established successfully, establish I/O stream for communication

Datainputstreamdis=new DataInputStream (Ss.getinputstream ());

Dataoutputstreamdos=new DataOutputStream (Ss.getoutputstream ());

for (int i=0;i<6;i++) {

Dos.writeutf ("Test:" +i); Sending data to the server

Dos.flush (); Flush the output buffer for immediate dispatch

System.out.println (Dis.readutf ()); Data output to be received from the server

}

Dos.writeutf ("End"); Send termination flag to server

Dos.flush (); Flush the output buffer for immediate dispatch

Dos.close ();

Dis.close ();

}finally{

Ss.close ();

}

}

}

b/S three layer structure:

Browser/server (b/s) is a three-layer C/s style of implementation of a way

– Presentation layer: Browser

– Logic layer:? Webserver? Application Server

– Data tier: Database server

Basic components:

– Database server? The database that holds the data and the business logic responsible for data processing;

–webserver/Application Server? Business logic: Process the data. The client application is stored on the webserver in the form of web pages;

Browser? Type the corresponding URL in the browser on the client

Connectors: Call-back mechanism or implicit invocation mechanism via the network

– Browser? àwebserver/Application Server: The browser sends a request to the Webserver/application server and receives the returned results.

–webserver/applies server?à data server:webserver/Application server sends requests to the data server and receives the returned results.

Strengths:

Based on B/S architecture software, the system installs, changes and maintains the whole

In server-side resolution, system maintenance costs are low:

–client no matter what business logic, the user in the use of the system, only need a browser to execute all the modules, really achieve the "0 client" function, very easy to perform their own initiative to upgrade.

– Good flexibility and scalability: For situations where the environment and application conditions are often changed, only the corresponding changes are implemented for the business logic layer to achieve the goal.

The §B/S architecture also provides the most realistic open foundation for online, networked, and unified services for heterogeneous machines, heterogeneous networks, and heterogeneous application services.

Better security: In such a structure, the client application cannot directly access the data, and the application server can control not only what data is changed and how it is visited, but also how the data is changed and how it is interviewed.

The three-tier model is a true "thin client" with very high stability, ductility and operational efficiency.

§ Three-tier mode enables the management of services together and serves the client in a unified way, providing good fault tolerance and load balancing capabilities.

Expanded the functional coverage of the organization's computer application system to

Leverage the various resources on the network, and the workload of application maintenance at the same time

Also greatly reduced

Before the –B/S structure appeared, the functional coverage of the management information system was mainly group

Woven interior.

The –B/S structure of the "0 client" approach makes it easy for the organization's suppliers and customers (these suppliers and customers, which may be potentially unknown) to become the client of the management information system, and to query the organization's relevant information within a limited range of functionality. Complete the data exchange and processing of various business dealings with the organization.

The combination of computer application system and Internet in §B/S structure also makes some new enterprise computer applications (such as e-commerce) newly proposed. The implementation of customer relationship management) becomes possible.

Disadvantages:

The §client browser exchanges data in a synchronous request/response mode. The server will refresh the page once per request;

§ The HTTP protocol "text-based data exchange" limit, the data query and other response speed, is much lower than the C/s system structure.

§ Data submission generally in the page, the data dynamic interactivity is not strong, not conducive to online transaction processing (OLTP) applications;

§ Limited by the ability to express HTML, difficult to support complex GUI (such as reports, etc.).

Program:

Front Interface code:

<%@ page language= "C #" autoeventwireup= "true" codebehind= "Default.aspx.cs" inherits= "Testweb1._default"%>

<! DOCTYPE HTML PUBLIC "-//w3c//dtd XHTML 1.0transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<title> front screen </title>

<body>

<formid= "Form1" runat= "Server" >

<div>

</div>

</form>

</body>

Server code:

Using System;

Usingsystem.collections;

Usingsystem.configuration;

Using System.Data;

Using System.Linq;

Using System.Web;

usingSystem.Web.Security;

Using System.Web.UI;

UsingSystem.Web.UI.HtmlControls;

UsingSystem.Web.UI.WebControls;

UsingSystem.Web.UI.WebControls.WebParts;

Using System.Xml.Linq;

Namespace TestWeb1

{

public partial class _default:system.web.ui.page

    {

protected void Page_Load (Object Sender,eventargs e)

        {

String strselect = "Selectloginname,username from Users";

string STRCN [email protected] "server=.\sqlexpress;database=business;integrated security=true";

SqlDataAdapter ad = new SqlDataAdapter (SELECT_STR,STRCN);

DataSet ds = new DataSet ();

AD. Fill (ds, "MyTable");

DataTable dt = ds. Tables[0];

string str= "<ul>";

foreach (DataRow row in dt. Rows)

            {

str+= "<li>" +row[0]+ "| |" +row[1]+ "| |" +row[2]+ "<li>";

            }

str + = "</ul>";

Response.Write (str);

        }

    }

}

C/S+B/S Hybrid Architecture:

– Mixing principle One: the principle of "internal and external distinction"

– Mixing principle Two: the principle of "the search and change is different"

§ Mixing Principle one: "internal and external" principle:

– Enterprise internal users access the database server directly via the local area network

? c/S structure;

? interactivity enhancement;

? The response speed of data query and change is high;

– External users of the enterprise access the webserver/application server via the Internet

? b/S structure;

? Users are not directly interviewed for data, data security.

§ "Internal and external" model is the disadvantage of the enterprise external users to change and maintain data, slow, more complex lock. The dynamic interactivity of data is not strong

§ Mixing principle Two: the principle of "the search and Change is different":

– no matter where the user is located inside or outside the enterprise (local area network or the Internet), all operations (ADD, Delete, update) that require data to be updated (maintained and changed) are required to use the C/s structure;

– Assuming that only the general query and browse operation (Read/query) is run, the B/s structure is used.

§ "Check and change different" model embodies the B/s system structure and C/s system structure common advantages.

§ However, because external users can directly connect to the database server through the Internet, enterprise data easy exposes to external users, which poses a certain threat to data security.

Distributed software Architecture style (C/S,B/S)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.