Busy fish exploration and practice of ServiceMesh

  background:
  
  In Ali server development to Java-based background, how heterogeneous language other business call existing Java services, and how to get through the group middleware, has become the primary problem with using non-Java language team must be resolved.
  
  Existing schemes issues:
  
  Before ServiceMesh programs mature, we use: by way of Dart C C ++ extensions to call each client middleware SO libraries (like JNI) /. The business program at the beginning of a good solution to the problem of ecological construction Dart server. But the program also exists the following questions:
  
  Coupled with high dimensional transport. Business code and library code SO client packaged together, running in the same process, once the micro-services framework needs to be upgraded, service codes also require maintenance and restart.
  
  Complexity: multiple locales in the process, cross-language data representation and transmission issues, will increase the complexity of the system, reduce the performance of existing services.
  
  High access costs
  
  New features lag
  
  ServiceMesh program:
  
  Due to some problems existing programs exist, we turn ServiceMesh looking for ideas to solve the problem
  
  As shown above: Compared with currently more common micro-services framework, ServiceMesh the micro client service core functionality independent, and as a separate Proxy processes deployed on each host, Proxy business processes through process communication with the outside world. This independent Proxy process is the core of ServiceMesh: SideCar.
  
  Between business processes and SideCar two most common communication schemes: 1 interception traffic Iptables based forwarding scheme, 2 business processes through direct SideCar Lightweight Mesh client. From the realization of the principle point of view, Iptables program direct scheme there will be some loss of performance and latency compared. We chose ALiMesh program uses a lightweight Mesh client program.
  
  After Mesh technology, business process and business code contains only lightweight Mesh Client, code logic becomes simple, locate the problem more clearly. Business students can focus more on business development, rather than focus on micro-services complex logic. Development of micro-services framework to maintain the core functions of the expansion and upgrading of the responsibility of the dedicated team Mesh, independent upgrade and maintenance, and business decoupling, no business perception.
  
  ServiceMesh solution to the existing conventional solutions: operation and maintenance costs, access costs, code complexity problem. Mesh and the use of open-source programs, you can also use the power of open source, constantly adding new features.
  
  ALiMesh Access:
  
  The introduction of SideCar, making communication with the original business, in and out of traffic between in-process communication between the micro-services into the process increases the jump, then how about the specific impact on the business performance of the introduction of ServiceMesh bring? Next we based ALiMesh (Istio open source solutions Ali version) along the Scoring look.
  
  ALiMesh provides two access schemes: Http embodiment, HSF mode. Http way which is divided into Http1.0 and Http2.0 way.
  
  AliMesh Http scheme (quick access scheme):
  
  As shown, the mode Http: in the data plane, business processes between SideCar, SideCar Service Provider and employing Http protocol interaction, the data coding using Json. Business process integration based on Http protocol Mesh Client, Mesh SideCar invoke Java HSF remote service call by generalization.
  
  In the control plane: the service provider ISTIO control plane data synchronization ConfigServer list, SideCar with ISTIO pilot channel synchronization service to go native.
  
  Because of the versatility of Http protocol, the access scheme is simple, fast Mesh verify the feasibility of the scheme, but the performance has not yet reached the online service requirements, the test, the main indicators are as follows:
  
  Note: Currently busy fish using only ServiceMesh OutBound function. In order to simulate real traffic situation online details page, every upstream request processing will be called 21 times the downstream Java HSF service, so when converted into Mesh flows, multiplied by 21 times the figure QPS, the following tests are so
  
  As shown in Figure: Mesh mode direct connection, Consumer side CPU consumption doubled compared to every RPC call RT increased by nearly 2ms. CPU and HSF Provider side also increased nearly 40%, which is HSF students with test results are basically consistent. After analysis, we initially targeting the main cause of increased CPU consumption is the connection Http1.1 agreement (already using connection pooling) and data encoding.
  
  In order to verify that the problem of the program, we tested the Http2.0 access scheme. Http2.0 compared Http1.x, it has a natural advantage in connection multiplexing, data format, etc., the compression head. After testing, performance ALiMesh is also more Http1.x have been greatly improved. Or near our part to meet the technical requirements. Detailed indicators as shown below:
  
  As shown, after optimization, business processes Consumer side, CPU, and some slightly excessive consumption RT (CPU does not increase more than 20%). In order to explore higher performance, lower latency solutions, we turned to the HSF proprietary protocol scheme.
  
  AliMesh HSF extended protocol scheme (performance solution):
  
  As shown, the HSF embodiment, the RPC protocol as HSF Mesh SideCar an extended protocol. Data plane: business processes between SideCar, SideCar Service Provider and HSF 2.0 and using a proprietary protocol, data is encoded using the Hessian 1.0. Mesh integrates business processes transformation of the library as a HSFCPP SO MeshClient, responsible for communication with Mesh SideCar. In the control plane: SideCar Configsvr directly connected with, the synchronization list of service providers and the configuration information, using the difference in a synchronized manner, in order to reduce the consumption of CPU control panel. Detailed test data are as follows:
  
  Through continuous optimization, the ultimate success of the Mesh CPU control within 20% growth, increase per jump RT RPC call control in less than 1ms.
  
  ServiceMesh fish in leisure applications:
  
  Currently Dart + ALiMesh program in the server is already busy fish + stable operation for eight months, to serve the busy fish details page, you may also like, rent home business, many times during the Mesh optimization, upgrade, operation and maintenance work such as extensions, business processes have no sense of the normal external services, business students do not need to participate.
  
  After introduction ALiMesh, online business impact on the RT as shown below: The orange is a graph RT traffic monitoring curve of the Mesh, the blue curve is the previous week of Mesh RT traffic monitoring curve, the daily fluctuation removing online environment after the impact of the introduction of ALiMesh RT for online business is quite small.
  
  
int num = 1;
List<int> list = new List<int>(www.yishengyule158.com);
for (int i = 1; i <= 2000; www.xcdeyiju.com++)
{
list.Add(www.boyunylpt1.com);
}
Console.WriteLine ($ "num initial value:" + num.ToString ());
list.AsParallel().ForAll(n =>
{
a ++;
});
Console.WriteLine ($ "Unlock, after concurrent {list.Count} times as:" + num.ToString ());
Console.ReadKey (www.jujinyule.com);
Copy the code
This code is to allow a variable execution times since 2000 by the normal result should be 2001, but the actual results are as follows:
 
 
 
Experienced students can immediately think of the need to lock, C # built a lot of lock objects, such as lock mutex, Interlocked internal lock, Monitor these more common, in fact, achieve internal lock using a Monitor object. Variable increment, the Interlocked object provides a variable increment, decrement, addition, or the like, we use the method Interlocked.Increment increment, the function is defined as: int Increment (ref int num), the object is to provide atomicity variable increment operation, the incoming target value, or returns ref num are the result of self-energizing. On the basis of our previous increase some code:
 
Copy the code
a = 1;
Console.WriteLine ($ "num initial value:" + num.ToString ());
list.AsParallel(www.huichengtxgw.com).ForAll(n =>
{
Interlocked.Increment(ref num);
});
Console.WriteLine ($ "use internal lock, the concurrent {list.Count} times as:" + num.ToString ());
Console.ReadKey();
Copy the code
Let's look at the results:
 
 
 
ID plus a lock after repeated be solved, in fact, not happy too early, due to normal environment with ID ID we still use these objects to build it, so he wrote to write code, using a collection to add these ID, for more realistic simulation production environment, I forAll inside with another layer of loop code as follows:
 
Copy the code
a = 1;
Random random = new Random();
was total = 0;
var m = new ConcurrentBag<int>();
list.AsParallel(www.yacuangyl.com).ForAll(n =>
{
var c = random.Next(1, 50);
Interlocked.Add(ref total, c);
for (int i = 0; i < c; i++)
{
Interlocked.Increment(ref num);
m.Add (whether);
}
});
Console.WriteLine ($ "use internal lock, concurrent + {list.Count} After the inner loop times as:" + num.ToString ());
Console.WriteLine ($ "The actual value: {total + 1}");
var l = m.GroupBy(n => n).Where(o => o.Count() > 1);
Console.WriteLine ($ "Concurrent inside the safe collection ConcurrentBag added num, set duplicates: {l.Count ()} th");
Console.ReadKey();
  
  ServiceMesh program, the service logic between the micro and communications services business logic has nothing to do with these decoupled from the business application, and let weight-loss business applications, allowing business students to focus more on business development. While giving a heterogeneous language to build low-cost eco-end service, access to the existing system.
  
  Of course, the performance loss, personally think that the overall advantages outweigh the disadvantages. Business team can be tested to assess the actual situation according to their own business, on balance if you want to access ServiceMesh.
  
  Next, we will further expand the application AliMesh fish in leisure and work with ALiMesh, push AliMesh landing in Dart Faas, fit more middleware.

Guess you like

Origin www.cnblogs.com/qwangxiao/p/11330836.html