Like how the cloud has multi-language support

One, background

There is praise Saas company that provides a full range of software services to businesses, support business procurement, shop, trade, marketing, order, logistics etc. management services.

In this software services that are able to meet most of the businesses, for businesses escort.

Saas common form is the pursuit of the process, is seeking common ground Saas ecological process, so when we are able to meet most customer needs, we have to consider the individual needs of large customers scene.

1.1 Customer Analysis

The above mentioned we should seek common ground, we want to meet individual needs, here briefly explain the large customer value, do not distinguish between the following advantages and disadvantages, and are put together:

  • Small and medium customers
    • Small scale, relatively weak ability to pay;
    • Business cycle is short, can not guarantee a good renewals;
    • Most of the basic ability to stay using the product, indicating that the software substitutability strong, difficult to form an adhesive;
    • But a huge number;
    • User acquisition cost is relatively low;
  • Large customers
    • Scale enterprises, strong ability to pay;
    • The development of stable, long cycle businesses, to ensure renewals;
    • Conducive to the formation of a benchmark case for promotion;
    • As long as the implementation requirements, capital requirements and is not sensitive to price;
    • Custom demand more, once customized, high replacement cost, good viscosity;

Simple list a bit, of course, there are many other points, compared to find, Saas will meet the needs of most customers, especially small and medium customers, small customers and the amount could reach 90%, but small customer renewals will lead to weak sales high costs and can not form a benchmark, with little influence on the industry; large customers pay for are strong, as long as they meet the requirements, may not have a relatively high price to say no, but basically every large customers have custom needs and, once entered into a collaboration, can a stable renewals.

1.2 to praise the cloud is doing

In front of a simple analysis of what small customers and large customers, due Benpian focuses on multi-language, so I will not explain too much, in fact, there are some small clients custom needs, hopes his unconventional shop, hoping to use low-cost and fast to meet their own needs, when large customers and then grow into more demand.

Saas under traditional circumstances is how to do it customized?

//核心业务流程
	............
    ...........
  if (店铺Id.equeals(0023423)) {
      //do custom logic
  } else if (店铺Id.equeals(0056673)) {
      //do custom logic
  } else {
      //do stardand logic
  }
	............
    ...........
复制代码

As a technician, might be very familiar with the above code, the customer is God, when customers mention a variety of needs, if the customer is not satisfied may lead to go into exile, if you go to meet, then our core business code coupling resistance will be high, and poor code extensions, custom code, and more and constrained the development of business, causing system bottlenecks; of course, the above code a little straightforward, will use the rules engine under normal circumstances, would be independent a custom application to handle disgusting business, but the problem remains; even worse is that customers want to customize the page, do not do business judgment in the node (s)? I believe we will see here say, this system will not expand, big business can not go forward.

This time there appeared like a cloud, so there is like a cloud initially it was a custom needs of individual customers, so that a wide variety of customers are able to cooperate and to praise, praise has provided software can be used in various industries, covering all Scenes.

Figure relatively abstract, but a better understanding. As can be seen from the figure, the arrow, there is a cloud-like expansion of the core business, our core business system outputs transaction process to have like a cloud, developers or businesses can customize their transaction processes , such as selling movie tickets businesses can lower single process add a seat selection process; as well as individual business-critical point output in the process of expansion capabilities , allows developers to achieve this expansion capability, such as prices , original price calculation is the core of the system to do, and now developers prices can write your own logic, the result of this calculation may be the price of the actual transaction price of goods; front page component-based , developers can customize their components, modify the original component's behavior. Of course there are many, many more complex custom.

Like so there is a cloud platform that provides the customization capabilities, and the ability to customize the market, developers create a wide variety of instrumental App , whimsy to achieve a variety of functions, then publish to the cloud to praise application market; browse business applications market, find a few applications or functions and their needs are matched, then purchase applications, fast and low-cost finished customizing your shop. In addition, we also offer industry solutions customized , if you have enough ability, you can customize the entire industry programs, such as a micro-channel in addition to praise praise Mall also have education, you can customize a set of like education, which is incredible; large private clients often want to customize, because large customers are often very special custom, can not be generalized, so large customers find developers can develop self-use App , the greatest degree of completion of their needs.

1.2.1 tool applications

There are two roles and resources, developers and businesses, shops and applications.

App developers to develop complete applications market shelves, businesses purchase applications, the relationship between businesses and stores will have the authorization and the application of the purchase, the shop at this time can use the functionality of the application, such as an application implements international address, then the next one shop buyers global address can be selected when the selection process of the address.

1.2.2 own applications

Type the name suggests is his own use, in which case businesses can find developers for themselves, develop a customized application to their own shop, ownership of the application also belong to the business.

1.2.3 Industry Solutions

This is a set of programs, mentioned earlier, you can develop a software industry, such as a taxi, take-away and so on, and tools applications require the same application market shelves, and businesses to buy.

1.2.4 have influence like clouds

Will boost overall business success, greatly enhance the success of the business development, to the merchant more possibilities;

It provides developers with the platform, expanding developer's revenue, enhance the ability to develop and expand influence.

Second, what is multilingual

2.1 Application

What is multi-lingual, multi-language applications in any place, can not do without a carrier, it is the application.

Application developers to develop custom functionality is an entity that contains the code, console, components (mysql, redis, etc.), permissions, service configuration, and so on.

At the same time the application is deployed in the container to praise the cloud provider's.

So why have deployed in a container like a cloud provider's:

  1. If deployed in a private room and outside the cloud, it is difficult to ensure the stability and delay the public network;
  2. We need to ensure the quality of the application, to prevent violations of law phenomenon;
  3. Deployed in the cloud to praise containers, and more recently have praised core applications, it can be called by RPC way;
  4. This way you can monitor the entire link, easily troubleshoot problems;
  5. Reliability, stability, security is guaranteed, which is the protection of the business.

More than 2.2 language

We hope that the formation of an ecological through this mode, supports a variety of language development of developers, so we line up on the developer community, enabling developers to easily learn, communicate, communicate better and have like a cloud, communicate with the business.

Multi-language, the language nor that the language is not the national language of the country of supporting multiple meaning Siha.

Multi-language refers us some specification, agreements, framework, infrastructure and so on to support developers to develop applications such as Java, Php, Python, NodeJs language and so on, and our calls.

As shown above, contains many multi-language module, we will focus on a few talk about the pick, virtually every piece of content can write a few articles.

Third, how to achieve multi-language

How to achieve multi-language, this is a good question, but also a problem, at least to do so is there like a cloud, which is a new model, although there are a variety of multi-language calling solutions, but there is praise for this model for the cloud did not refer to the road.

The beginning may not know how to get started, mind mapping is a great tool to help sort out what the right thing to do multiple languages, as shown above, the following breakdown of course content as well.

3.1 remote call

Let's look at remote call, after all, this is the main link, do not have this ability, we can not achieve scalability.

I believe that most Java developers are using dubbo students or spring cloud system, but they are currently able to solve basic RPC calls between Java applications, as a company, we can all go to define a unified technology stack with a certain unified model. But there like a cloud users are developers, there are applications like cloud deployment is the various language development.

3.1.1 Technology Selection

First, we need to ensure low-latency remote calls, support for multiple development languages, developers do not perceive a registered service discovery; need to monitor and link tracking capabilities; to praise those who do not perceive a need to develop cloud or no influence in the development of who actually go on development experience of the situation to add functionality, improve link and continue to upgrade.

Service Mesh concept fits our scenario, let's look at our multilingual practice.

3.1.2 Internal RPC

I believe that most companies use RPC framework of Dubbo, Dubbo secondary development on the basis of the company to meet their own scenes, there is praise as well.

I believe we are all familiar with this picture, there is consumer, provider, registry, monitor, but here are a few questions:

  1. Consumer and Provider requires Java applications;
  2. Consumer and Provider behavior coupled business applications in;
  3. Architecturally across the room to call across networks do not support.

Like internal company Dubbo second development to support several problems mentioned above, for Java applications, and basically similar in architecture. It can be understood as praise among the original Java application through Dubbo to do RPC (this is the status quo), and now to achieve inter-network calls in several languages and applications (target).

Of course, there are internal evolution itself like calling the program for a particular language.

3.1.3 Deployment Architecture

As shown, inner core domain and there have Like Like developers to customize fields belong to two separate networks, can not access each other between the two networks.

Side Car image above request is entirely self-developed components to praise, and named Tether, he completed a forwarding service, and have praised monitoring, log docking, monitoring and alarm of the service calls, and service discovery, load balancing, back-end services offline and so elegant, all sink to Tether layer processing, it can be understood as Tether service Mesh is the Side Car.

3.1.3 Mesh practice

Will find from the figure above, we have no direct connection by way of Dubbo in the process of core domain of an RPC call App behavior, but by the Side car forwards.

Service Mesh architecture diagram, if the previous deployment architecture diagram into two sides of the network domain server, you will find and Service Mesh view similar.

Service Mesh philosophy is the registered service discovery, service management, service calls, and so capacity as an infrastructure that enables applications do not have to perceive something other than business logic, which is the part of native cloud.

Because if let the application do these things, a lot of things become uncontrollable, such as inconsistent service protocol version, can not be unified upgrade Bug appears. And now there is this kind of like a cloud of micro-service architecture, just a silent upgrade Sidecar without the need of participation and co-developer of any business, greatly enhancing the flexibility and functionality of the overall architecture of iterations controllability.

As mentioned earlier, there are currently Dubbo RPC protocol like core domain using the Java language features coupled serious, it is not suitable for cross-language calls the scene. Based on this, there is like a cloud custom domain, we designed a protocol based on HTTP1.1 RPC and HTTP / 2 protocol is scalable, cross-language calling for the scene. Wherein the HTTP / 2 due to its standardized protocol, asynchronous, high performance, clear semantics and other characteristics.

3.1.4 call flow

We talk so much, give us a clearer call flow diagram to understand it.

For example, such developers to implement a price calculated extension point , when our core business logic to calculate the price:

  1. Price call center through Dubbo Bep (extension point gateway), when the benefits of doing so within the application itself uses Dubbo framework, without reform, it is normal Dubbo service and deal with it;
  2. Bep direct Side car, when the protocol conversion Bep request is received, then call Side Car;
    • If the other application is a Java application, it is still carried out in accordance with the original agreement calls Dubbo, mentioned before, there are internal Chan has done some Dubbo to support the development, this program already exists, so it is the lowest cost, for Java developers who is also very familiar Dubbo, this way more appropriate to praise and developers have it.
    • If the other application is not Java application, Bep will Dubbo protocol converter calls the Side Car was Http protocol.
  3. Side Car calls through the network to the rules of how to praise cloud developers to customize the domain of Side Car engine room, where there is a problem, there is room Like clouds custom domain Side Car App know that the call it?
    • First K8S custom domain is a cluster, when App released, were registered by the ability K8S service provided;
    • Like clouds have introduced Istio the Pilot, and some reform to the container application service discovery;
    • Another point is that previously mentioned, there is authorized to call the relationship between App and shops, so when the core domain Dubbo request to initiate an operating system to know which shop, the shop will know know which App.

So we provide multi-language programs are not one size fits all, but according to local conditions, according to the actual situation to do RPC multilingual solutions for Java applications, we used to praise the existing technical capabilities into the cloud to praise be implemented; other type of application, we provide a universal Http1.1 / 2.0 to expand the RPC protocol, wherein the HTTP / 2 due to its standardized protocol, asynchronous, high performance, clear semantics and other characteristics to meet our scenario.

3.1.5 RPC monitor

Traditional monitoring usually do in Dubbo application dependent data reporting Jar bag, that is, the application monitoring data to be reported, so there will be some problems when doing multiple languages:

  1. Each language had to do reporting framework when reporting protocol changes would have to update each frame, and promote the application to upgrade;
  2. Do data reporting application itself, if this logic problems, may result in service error, an application exception;
  3. Application framework layer will take up too much resources;
  4. Multilingual get fit;
  5. With the upgrade will monitor the development of business, the underlying system, frequent changes.

For these questions, we will Tracing, Metrics, Logging lower ability to Side Car, shielded multi-language, in this way, we can make no perception of developers to upgrade the underlying ability to upgrade monitoring; application layer only need to focus on service implement; when adding a new language, we do not need to collect any monitoring reconstruction.

3.2 Application Framework

Talked about long-distance calls, then the application how to implement the service it? We want to provide developers with the ultimate development experience, rather than allow developers to perceive the content too much protocol layer, regardless of if we can explain the details of our agreement in there like a cloud document and then allow developers to understand protocol to achieve agreement, but this bad experience, we can develop for several days still debugging protocol, but did not enter the business code to generate real value, which is completely unnecessary waste of time.

This requires an application framework to shield this trouble.

3.2.1 calls extension point

Whether or Php Java language or any other language, like a cloud will provide application framework, but this early in the design is a difficult choice, providing the application framework means that our costs will be high, development costs and maintenance costs, but we the protocol developed our own most clearly, there are problems like cloud development classmates know best, in the long run there is praise for the cloud and developers are very useful, especially for developers, greatly reducing developer communication costs and development costs as well as to praise cloud technical support.

Can be seen from the figure, when the application calls Side Car, parses the frame layer protocol, the protocol will be reduced by a number of necessary check, the current is converted into readable language object or entity, to a specific call routing rules expanded by point implementation.

Glance, developers will focus on the extension point to achieve on the line in the extension point to achieve, for each language designed the way each language to declare and implement such need Java annotations, Php adopt Facade and so on.

3.2.2 Log

For all languages, the log is a component of the process of developing and running in most need, the log is a relatively stable components, after so many years of development, has been able to define very clearly what information the log contains content, but also the application automatically call log to the printing process, so we will log reporting capabilities packaged in a framework, because he was closer to the business.

Skynet, there is a log platforms like cloud applications, all developers of application logs will be uploaded to the Skynet print calculation and storage;

So for logs, Skynet provides a unified logs protocols and ports, applications only need to follow the specifications package log format, you can print the log to Skynet, the application logs do not exist on the local file server;

3.2.2.1 Java applications

  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
  ...........................
    ..............................
        private static final Logger logger = LoggerFactory.getLogger(Xxxxx.class);
  ............................
    ...............................
    		logger.info("test log");
复制代码

In the application framework layer, has a good package logging and reporting protocol logic Skynet, developers only need to print the log as usual Slf4j use the same line.

So in the realization we use Slf4j specifications, SPI achieved by Skynet log pipeline.

3.2.2.2 Php Application

Monolog using Php frame, the processor adds the log SkynetProcessor Monolog encapsulated protocol log, the log to be printed by the SocketHandler Rsyslog.

3.3 Other

Return to start mind mapping multi-language, multi-language support to actually do a lot of things.

In principle we do these things is to try to make developers less aware, to ensure the robustness and scalability of the overall system.

Perhaps the most troublesome is the upgrade in doing these things, when we publish a new feature or upgrade an agreement to promote all applications to upgrade is a lengthy period of time we may have to do a myriad of underlying logic compatible, it will cause the system can not move forward, while developers will be very disgusted, frequently go to manually specify the version and release (this time without modifying the code line of business, and may have to reform the code).

Watch some of the other modules, on the first issue being skipped.

Fourth, planning and Prospects

The goal is to enhance the planning of the developer's experience, help businesses succeed.

It will open up more scalable, truly every detail point the whole process can be customized.

Experience in the development, the need to achieve WebIDE, easy development and debugging, so that developers do not even perceive the project, Faas may also be a good way.

On a multi-language, do try to get the underlying unity, rather than add a language brings us a vast amount of work.

At the same time we would like to see whimsy brightest developers, to develop a variety of very interesting and valuable applications. Based on this, there are like clouds in the June 5 on the line to praise the developer contest cloud, and the country issued a "battle", a high-quality application may award 400,000, are welcome to attend. www.youzanyun.com/contest

Reproduced in: https: //juejin.im/post/5d035bf0f265da1ba2525b7e

Guess you like

Origin blog.csdn.net/weixin_33946020/article/details/93173442