How to choose an application architecture? Recently, micro-service architecture is very popular. Small companies with 10 people to do a project also require micro-service architecture as a mandatory condition, and web applications with less than 1000 daily visits also require micro-service architecture. So is it good to use micro-service architecture? To figure this out, you need to understand the following buzzwords.

The cluster

In order to build a house, you need to lay bricks. If one person lays bricks too slowly, it takes 10 bricklayers to lay bricks, which greatly improves efficiency. Let’s say these 10 people form a cluster. Clusters are when everyone does the same thing, everyone does it together, and everyone doesn’t depend on each other. In our software production environment, clustering improves efficiency by stacking server hardware to do the same job.

distributed

Distribution, as the name suggests, is the concept of division of labor. Or to use the example of bricklaying, we need to move the bricks, put them on the wall, need cement mortar, and then we can start the bricklaying work. If the cement mortar, brick moving, wall laying are all done by the same person, even if it is 10 people, the efficiency may not be high, this time distributed play. We can have two people who specialize in cement mortar, two who carry the bricks under the walls, and six who just lay the bricks. In this case, although there will be no increase in personnel, efficiency will definitely increase. A cluster is not necessarily distributed, but distributed is definitely a cluster, and it requires multiple servers to work together. At this time, there will be another problem, if the cement mortar is not available, the bricklayer needs to notify and cement mortar pause, and quickly put the finished cement mortar to the wall. In reality, people can call by mouth and make phone calls. How to notify the server at this time involves remote Process Communication (RPC). We will briefly mention this and discuss it in depth next time.

Micro service

Micro service is A kind of structure, principle and distributed, it split granularity is very thin, fine to everyone just do something not decompose, and these small things not necessarily each on A different server, A server can put A lot of micro service such as A service, service B, C, another server service B, C, D service. It is important to note that all services need to be notified to a place called the registry, which can be understood as the project manager, who coordinates the management.

conclusion

If your business is simple and has very little traffic, all applications can run smoothly on a single server, and you don’t even need a cluster.

If you have few visits, but the business is very complex, for example, take the e-commerce order for example, the order process, you need to submit the order, pay, colleagues need to check whether there is inventory in the warehouse, and then send the address to the third-party logistics order, if all these things together, it takes 30 seconds. Users have to wait 30 seconds to see if their purchase is successful, which is a very bad experience. Even if you only have 100 transactions a day and only a small number of visits, the user experience is still not good. This is where you can solve the problem with distribution, splitting payment, inventory checking, third-party logistics notification, etc. into five or more tasks. In this way, the user experience is greatly improved and a purchase can be made in seconds.

If you have a high volume of traffic, and each process step is complex, then you can distribute the steps and distribute several server clusters, and then a microservices architecture is more appropriate. According to the previous experience of operating APP, the daily visits are several million, and each interaction is an application within 2 seconds. As long as the bandwidth is enough, the separation of Web and database and a Redis cache will suffice for two mainstream servers.

This article is originally published by Websoft9.