Is it hard to have a technical architecture that doesn’t have to be something fancy, just multiple microservices?

I watched some videos, they all use es, MQ, Redis things, I do not use these things, simply have multiple services, is it feasible?

Have you thought about using microservices?

First mall development according to your actual need to architecture, for example, only in WeChat small commodity scroll pictures show in the program, product categories, WeChat payment, order, address, shipping information briefly, and a set of background management system, including: users, roles, such as products, pricing, order, basically a complete market system can run. So is it necessary to micro service, or the single service is enough?

The main purpose of the microservice architecture is to solve the problem of frequent service function updates and releases, which always affect the large area of business jitter, thus reducing the agile iteration of new functions. Because this problem is unavoidable for a single service, it must affect reliability.

1. Distributed CAP: However, in the microservice projects I have been in contact with, the microservice release mechanism is often not mature. In fact, each release of microservice and release of single unit is the same effect, and all services have to be stopped and redeployed. Why is that? Because online transaction systems must prioritize consistency, no matter what development teams talk the talk when it comes to microservices, they will be honest when it comes to deployment. Do you already know how CAP theory works in a distributed environment?

As long as it is online transaction, it is necessary to guarantee distributed strong consistency in microservice environment. As shown below:

2. Distributed transactions: Another issue encountered by microservices is the separation of SQL operations from single applications to databases into PRC remote collaborations, where distributed transactions may be involved.

As shown in the figure below: The originator initiates a payment submission to the payment microservice. After the payment is completed, the payment microservice needs to notify the order service to update the order state with RPC call. At this time, the system has fallen into the vortex of distributed transactions. Are you ready for distributed transactions?

02 Technology is introduced gradually as the size of the business grows

Why Redis, ElasticSearch (es), MQ? Let’s go through each of these technologies in business, and you can evaluate whether to introduce them.

1. Redis: the main function is query cache, prevent database breakdown, the main situation is the mall has a high concurrency access state, but congratulations, you can use Redis to prove your business is very successful.

As shown in the figure below: A relatively standard MySQL read-write separation, Redis acts as a distributed architecture coupling for online transaction processing as a query buffer. This situation also occurs when the MySQL read-write separation cannot solve the high concurrency caused by a peak moment, the breakdown of the database, need to increase a second level cache to solve.

Please be sure to follow the K.I.S.S. principle, which is not added technically. Because there are always distributed consistency issues, in addition to the Redis cache, which is actually a very popular practice among engineers at present, but there are uncontrollable complexity in ensuring the consistency of MySQL master/slave replication, moreover, The introduction of data synchronization consistency between the cache system (Redis) and the database (MySQL) will make the overall architecture more complex, which will lead to a lot of unpredictable troubles after the online, so before full preparation, increase the complexity of the architecture should be cautious.

2. Elasticsearch: Content retrieval to a large number of goods, advanced classification is not only a keyword query, more need to be a professional search the goods content provides full text retrieval, convenient for the user by combining keywords, faster you want to find the goods, unless to oneself of the programming language you think good, can directly use luence, otherwise the es is a very good choice.

MySQL binlog->Canal->Kafka->Elasticsearch This is the surface said to be simple, but really to do well, internal to ooze through the engineer’s hard work and sweat.

3. MQ: When there is an interlocking situation between the mall’s micro-services and between the mall and the third-party services, the general micro-service architecture will form an event-driven mechanism, namely EDA. For example, after an order is initiated, it will be pushed to the downstream through messages, which may be processed by the distribution system of the order. So with MQ, the system is no longer a small commercial service, it is platform-level! As shown below:

Of course, the introduction of MQ does not necessarily mean that it has been developed to scale. It is also possible that the O2O business needs to be faced from the very beginning, and the online business events need to be pushed to the offline business system in the early stage, which requires MQ. It is recommended to consider mq supporting distributed transactions, such as RocketMQ. As shown in the figure below: When traditional enterprises engage in Internet +, at the very beginning, they have to consider using the message center to solve problems such as online and offline data docking, information security, and asynchronous collaboration.

03 summary

Finally, to sum up, I believe you should at least have a bottom in mind for the above content. You can make it clear that the technical system of the system architecture is constantly iterated and thickened, which is continuously supported according to the needs of the business and gradually produce good business support.

The more overdesign you have in the beginning, the more likely your system is to die, so should microservices be part of the design from the start? System performance optimization, advanced query, complex system optimization, etc., should be done in the early design? Is there already a matching team organization? These are all things that need to be considered, long term but deep.

Read another detailed article on microservices and distributed relationships:

Micro services want to use, first of all, the relationship between distributed and micro services clear

Understand the relationship between SOA and microservices in a general way

Head over to read Byte Creation Center – learn more about Read Byte creation