Company to do a simple share, the content of the article is I according to their own video and hand again, tired.

Today I want to share with you something about architecture and the middle stage.

Mainly will introduce the source of the stage, this we may be more clear, online articles and video ah a lot.

There is also about the development process of the structure had to be explained in the middle, from which the birth of the central Taiwan.

Finally, I will make an introduction about the trading center and the financial center, because one of the businesses I have done in other companies in the last two years is trading center and another is related to the financial center.

China origin

First, take a look at the origin of the Central Taiwan.

The source of Zhongtai is Mainly Ali. They visited a game company in Finland, namely SuperCell, in 2015.

This company is awesome. They claim to be the most successful mobile gaming company in the world, and they make very famous games that many of you have played.

Such as tribal warfare, Boom Beach and so on.

I played that game, but I didn’t think it was very interesting.

The size of the company is less than 200 people, and the development mode of the company is usually carried out by a small team of 2-7 people, which is called cell internally, which is also the origin of the name of the company.

The development process is often an internal decision to build a beta version as quickly as possible, then move on if it’s popular, or drop it if it’s not.

When a product fails, not only will they not be punished, they will have a party to celebrate and celebrate what they have learned.

However, I think it is very strange, if they follow this model, Tencent, Ali and other big companies are damned.

As we all know, Tencent tried to sell 1 million yuan in the early days, but no one wanted it. Ma had no choice but to keep doing it.

However, such a small company made $1.5 billion in net profit in 2015 and was acquired by Tencent for $8.6 billion in 2016.

What we’re going to talk about today is their development model. How can they develop a new game so quickly?

We imagine that developing a new game is time consuming, and developing a decent game in a few weeks should be very difficult.

It’s all about their “middle stage”, which they’ve accumulated over the years.

They’ve spent many years refining common game materials, algorithms, and so on.

This also is behind Ma Yun to come back after Ali vigorously engaged in the Taiwan.

Talk about architecture

After speaking about the origin of the central Taiwan, before the central Taiwan, we still want to talk about the development process of the framework.

The era of monomer architecture

When I first started, it was 11, 12 and almost every project I worked on was like this.

A team has everything in one place, such as user registration, login, payment, orders, often a small change and a big project to be released.

Generally, the single architecture is a single process, which is also for our current microservices, that is, you can upload a JAR package or a WAR package, all modules are in a process, if you want to upgrade or restart, the entire application service has to restart.

Of course, there were simple project partitioning and module layering, such as the MVC pattern we used back then.

Simplicity is very simple, but the disadvantages are also obvious.

The first point is that the cost of teamwork is high. If a small company has few people, it is ok. Once the business develops rapidly and the amount of code is impressive, my computer often can only run one project when I started working, but there seems to be no other project.

Frequent changes to a simple thing can be fraught with conflict, not to mention issues with the release of a large service.

Second, the project is so complex that everything is a hodgepodge, all in it.

The third point, the problem of database connection, a service is too big, on a database cluster, more and more business, more and more servers, to the back of the single machine may only make a single digit connection are not enough.

So, generally, with the split service, the database will also be split, independent services have a separate database.

Finally, the problem of scalability is that all functions are contained in one service. The actual situation may be that some function modules are heavily loaded, such as the service of order or inventory, which requires frequent reads and writes. At this time, it is difficult to expand.

A more serious problem is that if one module fails, the entire application becomes unusable.

At this point, there is no way, but to split.

This brings us to our second architectural pattern, SOA.

SOA(Service-Oriented Architecture)

When I was working at Ele. me, there were a lot of SOA names in there, and they continue to be.

What does SOA stand for? The full name is service-oriented Architecture, which means service-oriented Architecture, basically the same as microservices we have today.

The core of SOA lies in: loose coupling and service reuse. When there is a bottleneck in a single architecture, the first thing that comes to mind is dismantling. In the ERA of SOA, there are already concepts such as service registration discovery and service governance, which are no different from microservices.

SOA actually has two patterns, one is centralized, the other is decentralized, the figure below is the centralized service invocation.

The service calls are routed through the ESB service bus, the callers are shielded from interface changes, the ESB does all the dirty work of routing service requests, converting data formats, adapting and accessing various HTTP sockets.

So it’s pretty obvious what the problem is.

The first one is the request, the same number of requests is twice the usual decentralization, where A calls B, now through the ESB.

The second is the visual problem, which is that the ESB will be very stressed and can be resolved by clustering, but the PERFORMANCE bottleneck of the ESB will lead to bottlenecks for all services.

But what was the main reason for its popularity?

It’s the smokestack architecture that causes the problem.

What is a smokestack architecture?

As this chart illustrates, you have several businesses that, for various reasons of time or team or company, have developed into several separate services. Development and operation have nothing to do with each other. Most companies have this problem in the past.

For example, my previous company was a hotel business, and then it had take-out, restaurants, and coffee.

If a business focuses on a set of user system, order system, inventory system, the final result is like a standing chimney, that is, chimney architecture.

The phenomenon of chimneys is very common, and everyone plays his own game and runs his business first, but there are many defects.

First of all, repeated construction and development, needless to say, can be seen, every time to do a set of, not to say the development cost, said that the server and operation and maintenance costs are enough headache.

The second point is that the cost of interaction between systems is skyrocketing. As the business grows, you might have to do some precision marketing, design user profiles, do data analysis, that kind of thing. That’s normal.

Oh oh, at this time you find that the user is in several systems, the cost of this interaction is too high.

To do a data statistics, but also to adjust several system interfaces, may be different data structure, make you dead.

Still have namely business precipitation and development, this also is to want to say in the back stage.

Isn’t there some common abstract capability that can be shared between these systems?

This is the direction of development in Taiwan, abstraction, precipitation and sharing.

Microservices Architecture

Finally, we come to the age of microservices, which we’re all familiar with and don’t need to say much about.

As for now there are Serverless, cloud native what low code here will not expand, and so on the back of the opportunity to say again.

Getting back to the topic of microservices, what is the difference between microservices and SOA?

Personally, I think it’s close. Microservices are more free-form and fine-grained SOA.

Microservices don’t have a lot of framework constraints, we can use whatever we want, although we can do it in SOA, we can use Dubbo for communication, we can use Feign, Thrift, GRPC, we can use whatever we want.

For example, with Spring Cloud, Eureka can help us with service registration and discovery. By clicking @enableEurekaclient, you can connect to Eureka as a client.

Zuul is used for direct routing, Hystrix is used for current-limiting fuses, Ribbon is used for load balancing, and Feign is used for remote calls.

It is very convenient. Of course, you can also choose To use Spring Cloud Alibaba, which I think may be the trend in the future for a period of time.

The Dubbo Nacos Sentinel set is clearly more in line with domestic usage.

Shared services

After finishing the development of the architecture, we can return to the topic of Taiwan.

In fact, the role of Taiwan has been self-evident, is sharing.

For some of the more mainstream e-commerce, the division of several shared service centers.

First of all, the user center is essential. The user is the basic service. The user center integrates the common capabilities of users, including registration and login, SSO single sign-on, and user labeling and user portrait with big data.

Marketing center is also very important, including all kinds of promotional activities, coupons, red envelopes, card coupons, points, membership levels, rebates and marketing related things.

Trading center processing user next order, if place an order to have return commission, integral word and so on, this is called fulfill an agreement, say again later, about trade medium is what I want to say later.

The payment center is responsible for payment, refund, tripartite payment, bank docking, budget control and so on.

In fact, data center and business center are two directions, today I want to talk about business center, for the precipitation and sharing of business system, data center is more inclined to the direction of big data, I will not repeat here.

The lowest level services are our infrastructure and middleware capabilities, such as databases, messaging services Kafka, Rabbitmq, storehouses, file systems.

This picture seems to show that there is nothing else except the middle stage and the front stage, which is not the case. I just want to express that the shared service is the core supporting the upper level business, while the lower level and the background service are not drawn, which is in accordance with the structure of the big middle stage and small front stage.

Service split

Talking about this service abstraction and sharing on the way to talk about the principle of service separation, this statement is too much, different opinions, more is to follow the original experience to do processing.

In general, now our mainstream split are split according to the business point of view.

High cohesion, low coupling, this is nothing to say, all services should follow this principle, otherwise you will be a blind tear.

High cohesion means, for example, trading in the middle, only split around trade-related, highly dependent components.

Low coupling means that different services, businesses are isolated from each other and not coupled together, but there has to be a process for that.

For example, if you start a business with very few people, the user address information is put in the user’s service, and there seems to be no problem.

With the development of business, the address information and logistics services seem to be more and more related, whether it can be separated into logistics services.

Therefore, we should approach the problem from the perspective of development, not from a one-size-fits-all approach.

Go back to a small company, others tens of thousands of users, a few programmers, a service, you have to do micro services, open dozens of services, this is not right.

Data integrity

In fact, similar, business related data must be complete, such as you do split, split after the user name to another system, it is not very reasonable.

Continuous iteration

That is to say, to do sustainable adjustment and separation of the architecture upgrade, this is still to follow the development of the business, not too fine, not too thick at a time.

If you catch my drift, I’m not driving.

Trading in China

Said for a long time, finally said to the trade in Taiwan, I did the trade in Taiwan before almost two years of time, I think still relatively understand, in addition to some things did not achieve, because of the company’s development and time.

Trading medium also mentioned above, is mainly from the user to see the goods, and then to the order confirmation page, finally place an order, payment, distribution, receipt, such a whole process is trading medium doing things.

Transaction is defined as the exchange of valuable goods and services between buyers and sellers, either in the form of money or in the form of barter.

And the transaction process, now is generally divided into contract and performance of two, which is basically all the trading rules.

So and so did what at what time, this is a contract.

For example, if a buyer provides a valuable item to a seller, such as money, the seller needs to provide a service to the buyer.

Performance is when someone does something at an agreed time, such as delivering money, goods or services.

The whole process is roughly like this. Of course, we generally divide it into two directions: forward and reverse. Forward is the process of completing the transaction, while reverse can be understood as the link of cancellation and refund.

Since it is middle stage, it is necessary to be able to adapt to various trading scenarios.

For example, in the hotel industry, you book a room, which is the forward transaction, and then you check in and check out, which is the fulfillment process.

The supply chain buys, the merchant delivers, and you sign for it, which is the process of contracting and performance.

The same goes for ordering takeout.

All of these scenarios, then, can be summarized by the common process, which is the common transaction process mentioned above.

Having said the abstract concept, I need to describe it a little more graphically.

Above we talked about some of the more common service separation and service division, the following is based on the actual scenario to see how our services are divided.

This picture shows meituan’s order confirmation page, also known as the bill of lading page. The graph is too long, so I split it into 3 smaller graphs to describe it.

Can we analyze which services should constitute this page and who should aggregate the interfaces of so many services?

First of all, address information has been mentioned above, which is provided by user service or logistics service.

Then the delivery time should be provided by logistics algorithms, who will calculate a reasonable delivery time according to a lot of information such as transport capacity, weather and riders.

The details of the goods in the middle must be provided by the goods and services.

As for whether the distribution fee, various subsidies and red envelope coupons should be provided by marketing, it will actually be very complicated, because we need to calculate the price of various conditions and calculate the final amount to be paid, which is generally output by price services.

This part at the bottom is called tie-in sale, in order to purchase a membership at the same time, this in fact is equivalent to the two orders, one is take-out orders, another order is tie-in sale order, order of purchase a membership and eventually merge two order payment, have to do is keep the eventual consistency, the order is successful, at the same time members to buy success.

After the final order is successful, send a message, logistics team according to the message to fulfill the delivery, marketing according to the order message to send points, send red envelopes how to send, in addition, if there is a bundle member, also need to upgrade the member, which is also part of the performance.

There are two other interesting things about this place.

The first is the issue of withholding inventory, should be placed successfully withholding inventory, or pay successfully withholding inventory (do not worry too much about the issue of saving order and withholding inventory distributed transaction, this will ensure the final consistency).

In general, all businesses will deduct inventory on order, but there is a problem with this.

In the past, when we held activities, we would offer a lot of rooms for preferential activities, and the unit price would be lower, but the inventory was limited. This is called tail house sale.

A lot of scalpers will first place an order to occupy the inventory, and then sell to the user, immediately cancel the order, to help users place an order.

Therefore, we have two modes before. For this type of special situation, the inventory will be deducted after the payment is successful. In the general mode, there is no such problem just like e-commerce takeout, and the inventory will be deducted after the order is placed.

There is a problem with this coupon, I do not know if we found it, bought a member to send coupons, can be used immediately, the following also marked, this single available.

You can certainly think of this problem, generally we are coupons to the user to use, here after placing a successful order to send a message -> performance -> coupons, this coupon has not how to use in advance.

This is a more common trading system, two years earlier should not have this play, but also an optimization, generally called virtual vouchers.

When placing an order to cancel the coupon, it will generally pass a special mark and parameter to the marketing, and the marketing will do special treatment according to this judgment. As for the specific logic, I am not very clear, it is quite complicated.

It’s clear when you combine it with the panorama and the architecture.

<.>

The financial middle

The financial center is not pure enough, rather than the center, it is more appropriate to say that the business division, generally now the financial center of a lot of domestic companies can not escape the basic content of these several pieces, a lot of very similar, it is a little different according to different business.

Payment is the core of the whole financial center, and the unified cash register is the core of payment.

Clearing is also very central, very important, and I’ve done this for a while, budget, events, vouchers from a marketing perspective, budget from a financial perspective.

In general, when creating activities, we must apply for a budget. When creating activities, we must set the number of inventory and apply for a financial budget. In general, it is 1:1.

Financial intermediates figure it out for themselves.

To China,

I can’t show you this one, because it involves some personal things about the company, but you can talk about others.

For example, in the development process, as I have experienced, once a department like the Central Taiwan Branch is established, it is easy to be monopolized and have too strong voice. Moreover, it requires too much stability, which hinders business development to a certain extent.

Secondly, for the support and rapid development of business, in fact, may not be as good as imagined, experienced everyone should also have experience.

Moreover, China must involve this product too much political game, I think the SuperCell that small companies can indeed, but the volume is too big companies play well can be difficult, the small size of the company and not much necessary WTF middle office, you are not what game company right, after all or Internet companies is given priority to, Do business development primarily.

Ok, that’s all, everybody 88, I’m Ai Xiaoxian, we will see you next time, I will keep the rhythm of zhou Geng intermittently recently, the reading is a little cruel, everyone to help like and forward some, thank you very much.

The book referred to in the article is phoenix Architecture, written by Mr Zou. If you have not bought the physical book, you can read the electronic version: icyfenix.cn/introductio…

I modified some of the company’s internal PPT before, and some of the records are for reference, like a book of Ali. I read some of the records before, but NOW I can’t remember them.