Architectural reflection case of the site architecture case

Source: Internet
Author: User
Tags amazon cloud services

Background of the project

The company already has a desktop version of the program, need to develop a corresponding website program, so that users do not have to install desktop programs, and no longer care about the issue of upgrading and updating, all desktop operations can be done on the site.

Design of the project

1. Browser

It's not a choice, it has to be.

Here we have mainly considered two points:

1th, because the browser side and the server need frequent interaction data, so we chose WebSocket as the front and back of the communication technology, but WebSocket is not supported by every browser. This time we considered the Socket.io, it is relatively well encapsulated websocket, and for the browser does not support WebSocket also provides a polling and other alternative ways, these are handled by the Socket.io themselves, do not need external force intervention, quite convenient, so we chose Socket.io for For the medium of communication.

2nd, due to the development of the desktop UI program, we chose the single page technology to implement the user interface. To reuse some of the same UI, we used the relevant template technology provided by Google closure to dynamically generate elements on demand and then add them to the page using jquery. jquery is also a kind of library that can not be ignored by the front-end, we still use.

2. WebServer

It's not a choice, it has to be.

Considering that there are frequent interactions between the front and back, and these interactions are not CPU-intensive operations, mostly with browser for data interaction, and then choose Nodejs to create the server, personally, I always think that Nodejs will be the asynchronous callback mechanism to the point of no one can be enemy.

Webserver from a role, the following features are primarily implemented:

One is that, as a medium for connecting browser and Backendserver, all the data that the program interacts with are forwarded through webserver. The communication between Webserver and browser is implemented using WebSocket (Socket.io), while Webserver and Backendserver communications are implemented using the usual TCP sockets.

Second, webserver is managed through the Backendserverinspector component Backendserver, which is mentioned below.

Third, webserver directly manages the user's session information, where all user data is stored in MongoDB.

3. Backendserver

Because the desktop program already exists, so you can reuse all of the business logic of the program, so the site's architecture on the basis of traditional browser/server, plus the Backendserver component.

The Backendserver component is an EXE program executed by a command line that contains all the logic and data of the desktop program and simply strips out the UI part. The communication between Backendserver and webserver uses the usual TCP socket communication mechanism.

4. Backendserverinspector

In addition to these major components, since Backendserver is just a desktop program that strips the UI off, each feature is not loose, and a backendserver can only process one user's data at a time, So we need a management component such as Backendserverinspector, which is responsible for starting, shutting down, and detecting backendserver.

When webserver needs to process a new user, Backendserverinspector checks for available Backendserver and launches a new Backendserver program if no backendserver is available. If a backendserver program does not respond, it will close the Backendserver program.

5. MongoDB

In order to store the user's information, we use MongoDB as the database. NoSQL developed in full swing this year, we also decided to adopt in the project, here is not only consider mongodb efficient performance, as well as the Restfull API, natural distributed features are also factors we consider, although most of them are not used in practice, but relative to the relational database, Eliminating the abstraction of the database (ORM, or hibernate) is quite comfortable.

Implementation of the project

1. Reusing desktop programs

This is the background of the project, in order to reuse the functionality of the desktop program in a limited time, so that we do not have enough events to the desktop program function and interface to peel off the feeling, to create a pure SOA service is just a loud slogan, and even a lot of people do not mean at all.

The final result of this section is simply to add the original program to send and receive the message TCP socket module, complete with the Webserver communication function, the UI system is almost complete retention.

2. Nodejs Features

This part needless to say, Nodejs is also the recent hot technology, the implementation of webserver is not much different, just pay special attention not to block the main thread.

3. HTML5 Graphics Processing

I personally think that the canvas in HTML5 is the first choice of web-shaped processing, the normal 2D operation using the canvas API can be done, the complex 3D world to use WEBGL development, which is not a common in the browser technology, So we always recommend customers to use Chrome and Firefox browser.

4. NoSQL Trends

MongoDB is also a new technology, the use of this realization of user information persistence is sufficient, and there is no big difficulty in implementation.

5. AWS-Amazon Cloud services

We tried Amazon's cloud services, a cloud service that was absolutely a huge shock to traditional servers, with extended performance and ease of use unmatched by traditional technologies. No wonder this cloud service is the first choice for many startups.

Reflection on the project

The start of the project was somewhat exploratory, and ended up being halted because of the high cost of the server.

The advantage of this project is that many new technologies are used to ensure efficient interactive performance and scalability. Insufficient is the frequent interaction that causes network traffic to be too large and the network costs too high.

I personally think this design is worth improving is that the desktop program's UI-related logic should include some concepts completely separate from the underlying commands and operations, put them on the page to implement, which can save a part of the traffic. But the cost of stripping these logic and developing a more pure service-oriented program is undoubtedly high.

Architectural reflection case of the site architecture case

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.