Recall from the company was set up on the first line of code is present and nearly three years, platform technology architecture, technical system is experienced four major upgrade transformation (currently fourth generation architecture system is under way), near the end of the year also want to spare some time to review, a small company from the beginning of zero trading volume over the technology behind the billions change up to now.


General introduction

In the financial industry, the Internet is not more than $one hundred in fact big platform, which is the secondary camp, actually every time the architecture of the upgrade is accompanying with business progress, problems on the previous generation of system architecture, the business development process to accumulate some excellent development case, in the next generation of systems development will promote the structure upgrade. On the one hand, it can smooth the transition; on the other hand, the company’s resources can provide strong support; at the same time, technical partners can use cutting-edge technologies and have a greater sense of achievement in development. In this way, we can upgrade the system architecture once every 9 months, and we have reached our current architecture.


, many netizens often ask you platform TPS is how much ah, what is the maximum concurrent ah, how about performance, to be honest we are a small company, the most exaggerated is tens of thousands of people bid at the same time, but as a medium of the Internet financial platform to do also really many, is more than just these parameters can say clear; What we’re not big on the platform, the use of technology is the current mainstream open source products, but with the constant development of the company also met a lot of problems in the process, also try to use more mainstream, open source, suitable for some of our solution to build the entire system, here share platform development behind the change of technology and upgrading, At the same time, I hope to make more exchanges with you and give more suggestions.


We made four major architectural changes, and each generation is summed up in one sentence:

  • Features of the first-generation architecture: the services are concentrated, the functions meet the needs of investment and financial planning, and the services are quickly launched

  • Second-generation architecture features; Distributed system transformation, platform taking shape, various vertical business systems set up online, product end greatly enrich user investment, big data platform research and use

  • Third generation architecture features; SOA governance, using ZooKeeper as the registry and Dubbo as the monitoring and scheduling center; Cas implements single sign-on, using Shiro for permission control

  • Fourth-generation architecture features; Fully enable micro service development mode, Springboot + SpringCloud technology stack as the fourth generation architecture technology support


The following is a detailed introduction


First generation system architecture

The year 2014 should be regarded as the first year of Internet finance. Before that, there were a lot of Internet companies using various modes to survive, which had been lukewarm. However, it suddenly became popular in 2014. Later, there were more and more reports that various Internet financial companies had received XXX dollars of investment, and the policies were gradually clarified. Therefore, many large companies (groups) followed up on the craze, including us.


The first generation of the system is the most important to fight against time, the company hoped to ensure the system in the shortest time to launch, at that time the mobile wave has been started, so it decided to give priority to the launch of mobile terminal, website can temporarily not consider. At that time, the company had PHP and Java development language technology reserves, because PHP has a great advantage in rapid development, so it decided to adopt the model of front-end PHP+ back-end Java. The system is divided into three layers: user layer: Android and IOS mobile terminal; Interface layer: PHP provides user and transaction interfaces; Back end: The back end has two parts, background and timing system. Background PHP development and interface layer of a common system, the other is a timing system, responsible for interest, dividend, due and other scheduled tasks using Java development.


For basic services and middleware, mysql does the most basic master/slave support. The first generation system only uses the master library of mysql, and the slave library is only synchronized backup. Memcached is used to handle the concurrent issue of users grabbing tokens, and this is the only one used; ActiveMQ is used to use secondary market transfer matchmaking and other asynchronous message notifications. Project deployment: PHP using Apache deployment, timing service using Tomcat6 to do the application server, using LVS to do the front-end Apache load, basically the first generation of these technologies, the following is the architecture diagram of the first generation system.

After the first generation system online, the website and H5 (mobile browser or WeChat side) system construction is particularly prominent, as an Internet financial company without official website can’t endure, then again on the beginning of the development of web and H5 system, in the meantime do before the background of the PHP picked out, using Java redesigning a version, So far, PHP is responsible for the three systems of website, APP interface and H5, and a core transaction shared by the three systems. Java side is responsible for background management and timing service. We generally call this architecture 1.1 generation architecture.


The 1.1 generation system architecture diagram, the green part is the changed part

The disadvantage of the first generation system is that the business is too centralized and rushed online, and there are many problems in the later period

Second generation system architecture

The background of the second-generation system is that with the rapid development of the company’s business volume, a lot of technical debts in the early stage broke out, and many problems appeared online. The most serious one was repeated dividend payment to individual users, which was scolded by all kinds of people. On the other side, there is constant demand from various business units and the company’s products, so this phase is busy fixing various production problems while developing vertical business systems. During that time, I was almost driven crazy. The first generation system was closed development, and before I came back, I rushed to put it on the shelf immediately. It was really painful and happy.


The first vertical subsystem came online: the contract system. At that time, there was no contract after users bid, so many users were very worried and put priority to the first one. Later, the contract system changed three versions, the first version only generated PDF, the second stage online electronic signature, the third stage watermark, custom dynamic generation OF PDF; Then the development of points system: user invitation, investment and other production points, used to exchange cash roll, etc.; Pull out the message system: station messages, SMS, mail, etc. On-line monitoring system, business monitoring and service monitoring, business failure warning; All business departments continue to demand, online financial system: financial personnel statistics and calculation amount; Risk control system: monitoring abnormal users and abnormal transactions; Developed sales system for sales; Because of docking with a lot of third party systems, and developed external access system.


The first generation system is very rushed, and the product interface is very bad, then started planning website 2.0, APP2.0, H52.0, according to the requirements of the front-end system, the back-end development of CMS system to release projects, the company’s announcement news, etc. The second generation product side common planning a lot of big data analysis some of the requirements, in the website to show the whole amount after data analysis, the amount of investment investment preference, all ran to where go to, front end use maps to show, for personal calendar will have the repayment, the collecting data analysis, etc., because of the need to run the whole amount of data, at the time of planning is offline to process design, Synchronize data from mysql library to mongodb cluster, and use Mongdo’s MapReduce technology to process a large amount of data, so our database layer becomes the following architecture

Mysql is synchronized to mongodb in real time. We use the tungsten-Relicator tool to start a monitoring agent on the mysql server to monitor the binlog of mysql in real time. At the same time, a server is also set up on the mongodb server. Agent monitors data changes and sends them to the server, which then inserts them into the mongodb cluster to achieve real-time synchronization. As shown in the figure above, I wrote an article to introduce: Big data practice – Data synchronization tungsten relicator (mysql-> Mongo), in fact, this tool is not particularly stable in use, but there are not many options at the beginning, fortunately, it is stable after slowly getting familiar with later.


We boldly used Golang to develop the data cleaning system. Golang version was 1.3 at that time, but now it is 1.8. We had no contact with golang before and trained our team, but golang language itself is very simple and efficient. Later, golang was used to develop a background, which was based on the Beego framework. The big data analysis system was later upgraded. In each front-end business system, UI user layer made a lot of buried points to collect user data, which was transmitted and received by activeMQ and stored in mongodb. After data cleaning, the cleaned results were stored in the result library for use by front-end business system. Later, beego+ Echart was used to make a new version of the data analysis system.


Architecture diagram of big data system

Due to the increasing pressure of back-end database, back-end management system and business system are separated from each other. Background management system to increase the cache, started redis cache; Using Nginx to build an independent picture server; During the development of the second-generation system, which was also the fastest development stage of the company, more than N activities were launched.


Second-generation System Architecture Diagram:

To summarize: the second-generation architecture has put on line various business systems, separated the master from the slave, and built a big data platform, which provides a technical basis for more data processing in the future. Disadvantages: After the business systems are divided, it is complicated to call each project. There are various background systems and separate account systems between them. Operation needs to switch back and forth to complete platform operation monitoring

Third generation system architecture

After the completion of the second generation of system development, we were left with three painful problems. The first one was that with the continuous increase of business systems, the call relationship between systems increased exponentially. At the beginning of the third generation of system, we developed many basic components, which exacerbated this problem. The second problem is complementary to the first problem. There are too many call relationships between systems. If one subsystem is moved, it may be necessary to modify the configuration file of the associated system and restart the service. The third problem is that we have developed a lot of background systems, but the accounts are not unified. Each subsystem has its own account center. Operation and business personnel need to log in back and forth to complete daily work.


The first problem was to introduce SOA service governance and solve the decoupling between the systems through the registration and discovery of services. After a lot of investigation, dubbo was finally selected. The reason was that a large number of people used the basic water to wade through. The second problem was to introduce the configuration center. After investigating Qihoo360/QConf of 360, Spring-Cloud-config of Spring, Diamond of Taobao, and Disconf of Baidu, I finally chose Disconf after a long period of deliberation. However, it is from here that we notice that Spring-Cloud and Spring-Boot have laid a foundation for the selection of the fourth-generation architecture. In fact, disconf is only used in a few projects and has not been fully promoted. The third problem is the account center, which uses CAS to implement single sign-on, Shiro to control permissions, and Dubbo to provide server-side interfaces such as the list of permissions after login.


Architecture diagram after transformation

On this basis, we have extracted a lot of basic components, comOMn component processing common basic classes, including character classes, date classes, encryption classes… ., set up fastDFS cluster to deal with the file system, did the redis cluster test; A separate scheduling system is developed to integrate all scheduling tasks into the scheduling system. Scheduling policies can be automatically added to the page when scheduling tasks are needed in that system. The front-end PHP system has been reformed, including separation of master and slave, static optimization and so on

Later, the company started the construction of the crowdfunding platform. This time, the system was completely developed in Java language, and the app side adopted the mixed development mode, in which all the first-level pages of the APP adopted the native development, all the second-level pages adopted the H5+ Vue mode, and the back-end all adopted dubbo for servitization. The final architecture was as follows:

Only part of the system is listed in the diagram, and other services are used instead

The third generation system started SOA service governance, introduced a unified account center, basic components; The disadvantage is that the development environment is more complex

Fourth generation system architecture

People are always not satisfied, and technology always wants to use the best architecture system. In the development of three generations of system architecture, I have learned about Spring Cloud and Spring Boot. After continuous learning, I am more and more aware of the convenience of Springboot and the advantages of rapid development. Spring Cloud system also fully meets all aspects that a large system needs to consider. The concept of micro-service is constantly put forward. The above is the technical background. On the other hand, the country began to strictly require P2P companies to deposit with banks. After analyzing the relevant interfaces of banks, we found that if we strictly follow the rules, our system needs to be greatly reformed. Meanwhile, in order to meet the regulatory requirements, the company also developed ious related products, which is also a big project. We decided to embrace microservices as well as bank deposits and IOUS.


There are three reasons why we should ditch Dubbo and embrace Spring Cloud. 1. Dubbo hasn’t been updated in years, and Spring Cloud is constantly updated. 2. Dubbo is mainly engaged in service governance and monitoring. Spring Cloud considers almost all aspects required by micro-services, such as unified configuration center and routing center. 3. Spring Cloud is more invastion-free and perfectly integrated with other Spring projects, resulting in higher development efficiency.


Since spring Boot + Spring Cloud has been selected for the transformation, the selection of micro-service technology has been decided. Then how to start the transformation? After all, the transformation of the new generation system cannot affect the original business, and the main problem is that although the initial system is carried out according to the distributed development mode, Due to the old system, some systems still share a database. Microservice requires each independent subsystem to have its own independent library operation. If other systems need to modify or query the data of the subsystem, they need to obtain it according to the service indirect call. Therefore, we plan to start the SpringCloud project from the newly developed project and the project to be transformed, and other systems will communicate through the router mode for the time being. The final system architecture diagram is as follows:

There is no end to the architecture. Change is constant, and the architecture is upgraded to better support the business. The two complement each other.

The technology involved in the above can not be explained clearly by a few words, many questions are actually very simple answers, but the thinking and logic behind is not simple, to be aware of the why and why. Therefore, I would like to recommend an architecture exchange learning group: 650385180, which will share some videos recorded by senior architects: Spring, MyBatis, Netty source code analysis, high concurrency, high performance, distributed, microservice architecture principle, JVM performance optimization these become the necessary knowledge system for architects. You can also get free learning resources. The following course chart is also available in the group.



Note: Add requirements

1. Those who have some work experience and don’t know where to start in the face of the current popular technology and need to break the technical bottleneck can be added.

2. I have been in the company for a long time and have been comfortable, but I hit a wall in the interview when I changed my job. Need to study in a short period of time, job-hopping can be added.

3. If you have no working experience, but have a solid foundation, and have a good command of Java working mechanism, common design ideas and common Java development framework, you can add.

4, feel very good B, general needs can be done. But the knowledge points learned are not systematic, it is difficult to continue to break through in the field of technology can be added.

5. Ali Java senior bull live explain knowledge points, share knowledge, sorting out and summarizing years of work experience, with everyone to establish their own technical system and technical knowledge in a comprehensive and scientific way!

6. No small or small white or other groups, thank you.