Web site Distributed architecture

Source: Internet
Author: User

Original: http://xubaoguo.iteye.com/blog/1882030

absrtact : The Internet website and most enterprise management software is the same as the use of B/s architecture model, but the large public website b/s architecture will be more complex, the requirements of the architects more high, today I would like to talk about my blog on the design of the website b/s technical structure. Whether it is the B/s structure of enterprise management system or Web site technology architecture can be abstracted as follows: In the traditional B/s ...

<!--singlead begin--><iframe id= "baidu_clb_slot_iframe_664111" style= "border-width:0px; margin:0px; Vertical-align:bottom; Display:block; "src=" About:blank "frameborder=" 0 "marginwidth=" 0 "marginheight=" 0 "scrolling=" no "width=" height= " "$" ></iframe> <!--Singlead End---

Internet web site and most enterprise management software is the same as the use of B/s architecture model, but the large public website b/s architecture will be more complex, the requirements of the architects more high, today I would like to chat on my blog on the website I designed b/s technical structure.

Whether it is the B/s architecture of enterprise management system or Web site technology architecture can be abstracted as the following diagram:

In the traditional B/s architecture of enterprise management system, the technical structure is often a project, each logic layer is the business logic module of the project. But as a Web site to provide public services, due to the large number of users, site concurrency, demand changes, frequent changes and the site for security considerations, the above logical layering in the implementation of the technical framework will be more complex. I made a website shortly before, I designed the technical structure of the following diagram:

I split the site project into three sub-projects: front-end projects, server-side projects, and memcache projects, with front-end projects containing pages, static resources, and control layers; The server-side project contains the business layer and the database operations layer, and the Memcache project caches the data common to the front-end project and the service-side project.

In the system deployment, front-end projects and service-side projects are distributed (our site front-end is 4 servers, the server is 4 servers), the user requests to enter the first through the load Balancer device for the request distribution, the front end and the server and between the server and the database has a firewall to ensure the security of the system, The front-end cluster and server cluster belong to different network environments, the front-end cluster can access the external network, the server cluster and the database is located in the network can not directly access the external network, but the front-end network environment and the server network environment between the communication.

The service side and the client communicates with our custom message, the transmission protocol HTTP, because my website security requirement is relatively high, the user transmits the request protocol to use the HTTPS.

In order to ensure the efficiency of the service-side and client-side communication, we use a long connection (our Web server language chooses Java, the communication layer is developed using the Netty framework), in order to ensure a long connection, we write a heartbeat detection service, which runs in the background thread. Heartbeat is detected every 5 minutes, while the interval of detection is configurable. In addition, we have previously estimated the maximum concurrency of the site, at the site launch, we built a thread pool (we use the server is a 8-core processor, the maximum number of threads per core 256, so our line constructor total total maximum thread count is 8*256*4=8196), each thread processing a user's request.

Because the client project takes the distributed deployment, so there is a session sharing problem, our site session sharing does not use the Web container to bring the session sharing mechanism, but we have developed a session mechanism, the principle is very simple, Specifically, we will generate a unique identifier for each user session, and our unique designation is this: the ID value of the session for the current user + the random 16-digit and letter combination + the current nanosecond value, and then the hash of the value is a key, The original value stored in the session is stored in the Memcache cluster, and the key of the data is the unique identifier of the user we have calculated. The end of our site is not using the Session object, but our own design of the session mechanism, we also encapsulated a set of custom tags, on the page to operate our custom session.

Server also has a similar sharing mechanism, but different, when the client requests the service side, the request will be specific to the server side of the servers, because this site some requests processing asynchronous, that is, some customer requests are not immediately returned to the user, but the request is now distributed to the service side, At this time the client will return the user a corresponding flag, stating that the request has been processed, and a server side of a thread at this time has started processing the request, the client at a certain interval of time to send the request to the server, the query request whether the processing completed, but the server is distributed, the request is sent randomly, Client inquiries may be distributed to other servers, so such requests, I will be processed in the client record server IP address and thread ID, at the time of the inquiry will be access to the specified servers and threads, until the request processing completed, and finally close the query, the results are returned to the user.

As we split a Web site project into three separate projects, it added difficulty in project management and coordination, so we introduced the MAVEN framework to manage and build the project, while building a common project that is dedicated to the development of the server and front-end public programs.

This framework separates the presentation layer from the business processing layer, so client engineers can concentrate on the client, and the service-side engineers focus on the service side, so as long as you learn how to encapsulate the communication protocol, it is very advantageous for the project team to scale horizontally.

Web site Distributed architecture

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.