The b/S architecture brings the following two benefits:
(1) The client uses the same browser. The browser is unified and does not require special configuration. The interactivity of the browser makes it very easy for users to use it.
(2) The server is based on unified HTTP. Unlike the traditional C/s architecture using custom application layer protocols, the B/S architecture uses HTTP. Using HTTP is also a service provider
The development model is simplified so that the server developer can adopt the relative standard development mode and save the development cost. There are many HTTP-based servers, Apache, IIS, Nginx, Tomcat,
JBoss and so on. These servers can be used directly and do not need to be developed separately.
1.1 b/S Network architecture overview
b/S based on the Unified Application layer protocol HTTP to interact with the data, and the traditional C/S Internet reference mining Long Connection , HTTP uses a non-state short-link communication mode, usually, one request to complete the data interaction. This approach can serve multiple users at the same time.
Many actions occur when the user enters the URL in the browser. First, it will request DNS to resolve this domain name to the corresponding IP address, and then according to the IP address to find the corresponding server, to this server to initiate a GET request, the service returned data resources to the user access.
The server may have many stations, which one to use to process the request, which requires a load balancer device to evenly distribute user requests;
Whether the requested data is stored in a distributed cache or in a static file, or in a database;
When the data is returned to the browser, the browser parses the data to discover that there are still some static resources (such as CSS,JS or pictures) that also initiate additional HTTP requests, and the static resources of those requests are likely to be on the CDN, and the CDN server will then process the user's request.
Regardless of the network structure, there are always some immutable principles:
(1) All resources on the Internet are represented by a URL.
(2) The server-side interaction must be based on HTTP.
(3) data display on the browser side.
1.2 How to initiate a request
How to initiate an HTTP request and how to establish a socket connection is not a big difference, except that outputstream.write writes binary byte data in a format that conforms to HTTP. Before establishing the socket, the browser must resolve the IP address according to the DNS of the domain name entered in the Address bar, and then establish a socket connection to the remote server based on the IP address and the default 80 port number, and then the browser is assembled into a get-type HTTP request header based on this URL. Sent to the target server via Outputstream.write, the server waits for Inputstream.read to return data and finally disconnects the connection.
Chapter One deep Web request process