preface

  • Why microservices?
  • What are microservices?
  • Why are there so many components in SpringCloud?

As the first part of the SpringCloud tutorial, we don’t cover specific technology uses, but rather solve these puzzles with an easy-to-understand short story.

This paper is divided into three parts:

  1. Evolution of architecture, i.e. why microservices technology
  2. What are microservices, the standard concept of microservices
  3. What is the problem microservices is trying to solve, that is, what are so many components in microservices

From monomer to Micro Service “Evolution of Short Story Explanation Architecture”

The new technology will stand on the basis of the old technology, solve the problems of the old technology at the same time, iteration and evolution

This year, maybe 10 or 15 years ago, Little Deer joined a budding e-commerce company – And Xi Xi Mall.

At this time the company is a start-up, fewer people, less things, less users, of course, the boss of the money is also less, in line with the belief of how fast and how good to save, as the company’s only development engineer Deer, stumbled to develop a mall website can be used, the structure is as follows:

The website as a whole is very simple, in the current stage of no users is also very easy to use, but also very worry, but did not think of is that the company’s business is getting better, the number of users is more and more large, with the increasing number of visits, the project often stuck fault.

So the boss waved, guide the technological reform of the mall, EMMM, also add money to recruit people, and recruit sheep, pony several colleagues, and upgrade and optimization of the mall.

After heated discussion, the optimization direction is: increase the application load capacity, that is, load balancing, application server cluster

And then, thump, thump, a new structure emerged

Load balancing

After load balancing is added, application servers are no longer the bottleneck of the system, and the number of application server clusters can be flexibly increased with the increase of traffic.

However, for a long time, database problems, due to the increasing amount of data, coupled with promotion, log and other new business module, database access problems, a database can bear the pressure of life is limited after all.

So the boss waved, guide the technological reform of the mall, EMMM, and money to recruit, and recruited the calf, Xiaoming and other colleagues, and xixi xixi mall to upgrade and optimization.

After intense discussion, the optimization direction is: database read and write separation

And then, thump, thump, a new structure emerged

Reading and writing separation

By clustering the database and separating read and write, the pressure on the database to withstand was greatly increased, but with the further in-depth work of the business, new problems were exposed.

  • The newly added commodity search function uses the fuzzy query of database, which is inefficient and the query result is not accurate
  • Different modules have different data access popularity. Some data, such as the home page data, need to be frequently queried and displayed. It is inefficient to query the database each time.

So the boss waved a big hand, guide the technological reform of the mall, EMMM, and money to recruit people, and recruited several colleagues, and xixi xixi mall upgrade and optimization.

After intense discussion, the optimization direction is: the introduction of full-text search, Redis and other technologies.

And then, thump, thump, a new structure emerged

ES + Redis cluster

With the new structure, everything looks perfect and everyone on the team can finally have a good year.

Time is quiet.

With the continuous growth and xi Xi mall, the company ushered in the venture capital, venture capital two billion, so the mall development faster, new problems appeared.

What’s the problem?

  • The code coupling degree between different business modules is too high. When one module fails, the whole project goes down
  • Maintenance was difficult, and every code update required redeployment of all servers
  • Some service modules are too small to be deployed on multiple servers.

So the boss waved, guide the technological reform of the mall, EMMM, rich will do some dry things in line with the tuhao identity, waved, spend money directly bought a big bull team to carry out technical optimization of the mall.

Optimization direction: servitization.

As a service

The so-called servitization is to divide the company’s projects into modules, and make each module into an application program that can run independently and be deployed independently, as shown in the figure:

Order, goods, home page, promotion, etc., each business module is an independent application, we call such applications divided by modules as services.

  • Can be independently deployed on the server according to the need, the home page module is accessed more, you can deploy several
  • The database can be accessed independently, and each service can have its own database…

Wait, wait, wait. Not too much. This is what we actually call microservices.

The problems to be solved by servitization? ‘More questions to come’

When a project is transformed into a service, the process is not an overnight success. To servize the project, many problems need to be solved, such as:

  1. How do services call each other? The order service wants to call the data of the goods service. How? How to call more stable, more efficient? 【 Service Invocation Technique 】
  2. How to balance the load between services? The order service calls the commodity service. There may be many commodity services. How to load balance?
  3. How are services managed? How is the service located? How to deal with the fault? Service Registration and Discovery Technology
  4. How to monitor faults? There are many business modules and components in the microservice system. The indicators of different components are different. Then how to monitor these components?
  5. How to locate the fault? In a microservice architecture, a user’s request may involve multiple internal service invocations, so how to locate the problem? [Link Tracking Technology]
  6. How to analyze and process logs? More business modules, more logs, direct view of the log file has changed the display, so how to analyze the log search? 【 Log analysis Techniques 】
  7. Permission management? After microservices are split, there will be a lot of services exposed interfaces. How do these interfaces have unified permission processing? 【 Gateway Technology 】
  8. What can I do if the service invocation fails? When a service stops responding for various reasons, the caller usually waits for some time and then times out or receives an error return. If the invocation link is long, requests may accumulate and the whole link occupies a lot of resources waiting for downstream responses. How do you solve it? [Fuse, degrade, limit current]

And testing, and deployment automation and so on, with the emergence of micro service, for each of the above questions to solve, the introduction of one or more new technology in the project, and these new technologies we usually call it components, is also the key point of service learning, a set of technology, a set of solutions to solve the problem of all of the above.

The above problems, here we briefly covered, in all the tutorials, and then detailed analysis and explanation.

What is microservice?

the microservice architectural style [1] is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services, which may be written in different programming languages and use different data storage technologies.

  • Each service can run independently in its own process
  • A series of independent microservices build the system together
  • Each service is an independent business development, and a microservice focuses on a specific function, such as order management, user management
  • Microservices communicate with each other through lightweight communication mechanisms, such as Restful apis for invocation
  • It can be developed using different programming languages and data storage technologies

Website link: https://www.martinfowler.com/articles/microservices.html

conclusion

The new technology will stand on the basis of the old technology, solve the problems of the old technology at the same time, iteration and evolution.

Microservice technology is a set of technology, is a set of technical solutions to solve multiple problems.

Congratulations on completing this chapter. A round of applause! If this article is helpful to you, please help to like, comment, retweet, this is very important to the author, thank you.

To learn more about the use of SpringCloud, stay tuned for this series of tutorials.

Ask for attention, ask for likes, ask for retweets

Welcome to pay attention to my public account: Teacher Lu’s Java notes, will update Java technology graphic tutorials and video tutorials in the long term, Java learning experience, Java interview experience and Java actual combat development experience.