On the evolution of application system architecture

Source: Internet
Author: User
Tags ruby on rails

backgroundInternet entrepreneurship has continued to soar in recent years, with sectors ranging from social, information, e-commerce and life services. There are also many excellent apps, and the features of these products or platforms include "fast", that is, fast updating, fast iteration. However, as a software engineer's point of view, according to previous software engineering theory, the system should consider more complexity and good expansibility at the beginning of design, as far as possible to achieve the results of status quo, and these rapidly changing rookie products in the system architecture how to flexible expansion, rapid evolution? This is what we will begin to explore.   first, the initial system architectureat the very beginning, the Product manager (or project manager) found you and asked you to develop it within one months after nagging about the system's functional requirements.     
Manager:    "The leader is very busy, must be on-line in one months!" "    These functions are very conventional, need to develop so long!" "You:    ...

Of course, the above scene is slightly exaggerated , but in the Internet thinking mode of the app development scenario, such a rhythm is very common. Development managers are corner, and the brain begins to run at high speed:
"So short a Time". "Well, let's not consider the performance issue!" "" Unit testing can also save, do a self-test can, can save a lot of time?

after a series of struggles and reflections, the development manager infers the first-generation system architecture for the product:

          Architecture Features
single point, to meet the functionality of the main, simple, lightweight architecture. Data Flow HTTP requests from multiple scenarios are accessed directly by a single server, processing the business logic, and outputting the results. Component Introduction

1 App Server, application system service side node, can have many choices, take the Java series as an example :

Tomcat

The most popular Java EE container, official website http://tomcat.apache.org/

Jetty

A more lightweight servlet container, lightweight and compact, provides a programmable server implementation (easy embedding), and has a better performance in the continuation mechanism.

See http://www.eclipse.org/jetty/for details

playframework

one of the most popular non-mainstream application servers was the implementation of the first Java version of "Ruby on Rails". It abandons the various idea chains of the Java EE, which makes programming easier and more reliable. The playframework Framework is currently 2.x (both Java and Scala supported), but the learning curve is steeper than the 1.2.x version, and it is recommended to get started with the 1.2.5 release.                    It is worth mentioning that the framework has built-in Netty to support HTTP requests for access and processing. The Netty is a lightweight HTTP server based on NIO implementations,the implementation principle of Netty can be consulted: http://stonexmx.blog.163.com/blog/static/122158587201061331614536/Play Frame's official website: https://www.playframework.com/              2 mysql, Popular Open source database, application based on JPA/JDBC to achieve data persistence 3 memcached, high-speed memory server system that supports fast read and write of KV data stream, serves as data cache and accelerates accesswebsite address: http://memcached.org/  Ii. The beginning of evolutionwell, after one months of effort, the system is on the line. operations also began to work, followed by an emergency repair of various online problems.  The system is getting a little bit more active, and in a few months the product manager and the development manager began to hear some complaints: 
"The system how old hang ah, can not access, this what broken thing ah" "I have been replaced by WiFi, the picture is still not loaded?" "
.....

the so-called product less into resentment, the team finally couldn't stand the pressure, determined to start optimizing the system. In response to the above problems, the analysis is as follows:

1 availability; a single point of collapse, the entire system is directly unavailable, all users will be affected;The memory overflow of the JVM and the unexpected termination of the system process can cause such problems.   2 bandwidth; The application system in the initial design time more consider the network call, HTML dynamic page output, and the access to the picture has not done too much consideration, so the file resource access quickly bottleneck.   The development manager decided to optimize the architecture as follows :               Load Balancing use Nginx to provide load balancing for application servers, provide two application server nodes, guarantee a single point of collapse and the system is still available.   file access separation using a separate Web server (nginx) as a file access server, all static picture addresses will point to the standalone domain name.           Iii. Accelerating EvolutionFollowing the last optimization, user complaints have been significantly reduced, and product managers and leaders have expressed satisfaction with the work. The development manager is beginning to feel an unprecedented sense of accomplishment.  However, in a few months after the company focused on the introduction of the marketing team. This is quite a force for the team, in a short period of time, in the major network platform layout of multiple portals. A variety of promotional activities, event marketing ensued. The most impressive, as in the circle of Friends, an event marketing directly introduced several times the user volume. such a situation in the development trajectory of Internet products can at least be called a small burst of growth. of course, leaders, product managers are happy and excited. But this time, the research manager is beginning to worry about the heart:  1 access pressure; the concurrency of a server can easily reach the upper limit, once the load threshold is exceeded, will directly lead to increased access time, even the system crashes, inaccessible, and other situations;  2 data access; the expansion of data volume, the single database table is increasing, the query speed will be reduced;In addition, the single point of the database becomes a hidden danger       3 cache space; In the same vein as the database, in order to accelerate more data access, it is necessary to provide more capacity cache space; this time, the development manager made a more thorough improvement to the system architecture:               Load Balancing increase the load-balanced server node, improve the overall processing capacity;        Database Extensions The method of horizontal slicing is adopted to realize the distributed database cluster based on Shard;       memcached cluster open multiple memcached nodes to form a highly available cache cluster while supporting larger cache space among them, the most important part of the service-side program is the realization of distributed shard data, which can be segmented from local table with large data volume, and the mechanism of adding horizontal sub-library to data access; of course, Data migration at this time is also a priority.   Iv. prospects for the futureat this point, system optimization has been completed. The current backend architecture is in a state where performance is stable and easy to expand. The performance index aspect already can reach the millions user quantity roughly, the day PV is million, even possibly better. However, this is only a prototype, the application system of the scene is diverse, in the future need to solve the problem is not only these, such as:     1 System exists full-text search, or tabbed search scene, in order to improve the search performance, you may introduce Sphinx middleware;the Chinese version of Sphinx is Coreseek (Chinese full text search is supported). See official website: http://www.coreseek.cn/ 2 in order to improve the efficiency of transaction processing, you need a queue server to solve, this can be ttserver + worker mode; 3 Frequent parsing of cached data is cumbersome to develop, and you can also change Redis to support data structure-style caching directly ...Redis is an excellent nosql middleware that supports data structure caching and persistence.website address: http://redis.io/ Notesarchitecture design requires the "apply" principle, the architecture of different business scenarios will vary,only the most common extension ideas are discussed here, and the methods of reading and writing, data preparation and so on are not discussed here. the storyline mentioned in this article is fiction, and if there is a similarity, it is coincidence.

On the evolution of application system 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.