编程知识 cdmana.com

Java "microservices" can still play like this!

  " Microservices " Quote because it's not a traditional definition of microservice Architecture , At best " Small services " Architecture , Because the service instance items are uniformly loaded by cluster nodes , Independent deployment . The following figure illustrates the service call process .# One 、 Service call flow ![](https://img2020.cnblogs.com/blog/4928/202012/4928-20201224195442955-1710120808.jpg)* ** Node Master Program **: Similar to Istio Of SideCar, Responsible for communication between external network and cluster nodes , In addition, it provides built-in distributed storage engine ( At present, metadata is stored here );* ** Node subroutines **: Responsible for loading service instances and service calls , Support the hot update of service cases .**1.2.** The client call service requests are forwarded to the main program through load balancing WebHost Inside ;**3.4.** According to the service identity, the main program sends the request to the subroutine through the shared memory queue ;**5.6.** If the service manager of the subroutine cannot find the service instance , Then request the main program to load the compiled service bit group code ;**7.8.** The main program reads the bit group code compiled by the service model from the built-in storage engine and returns , Subroutines pass through ClassLoader Load and cache service instances ;**9.10.** The service instance calls the specified service method and returns it to the main program WebHost;**10.11.** WebHost Return the service call result to the client .> The above steps are asynchronous , Data serialization is similar to webpack Custom format for .# Two 、 Development process demonstration    To get to know each other , Here's a simple development process .## 1. Building data structures    Through IDE Create a new data structure as shown in the figure below , The background automatically generates relevant entity code .![](https://img2020.cnblogs.com/blog/4928/202012/4928-20201224195454490-342828839.jpg)> Entity models can be mapped to different databases (Sql, NoSql Or a built-in database )## 2. Build business services    Through IDE Create a new query entity service as shown in the figure below , Note that the service method must return CompletableFuture, Because the whole architecture is completely asynchronous .![](https://img2020.cnblogs.com/blog/4928/202012/4928-20201224195502693-818625913.jpg)## 3. Create user interface    Through IDE Create a new view model as shown in the figure below ( Based on TypeScript Of Vue Components ), The proxy method of calling back-end service is automatically generated in the background , And it's also asynchronous ( return Promise).![](https://img2020.cnblogs.com/blog/4928/202012/4928-20201224195509480-1139377028.jpg)> The whole process is done by a browser , No need to write a line of configuration code .# 3、 ... and 、 Concurrent performance testing    It's also asynchronous with Spring WebFlux Compare and test the concurrency and response , The test configuration is Mac Host ( Pressure test )->4 nucleus I7 Virtual machines ( Service ).* WebFlux:```shellwrk -t2 -c200 -d20s http://10.211.55.8:8080/hello Running 20s test @ http://10.211.55.8:8080/hello 2 threads and 200 connections Thread Stats Avg Stdev Max +/- Stdev Latency 12.46ms 1.51ms 47.08ms 75.10% Req/Sec 8.06k 293.27 8.52k 81.00% 320913 requests in 20.01s, 28.16MB read Requests/sec: 16039.85 Transfer/sec: 1.41MB```* This framework ```shellwrk -c200 -t2 -d20s -s post_bin.lua http://10.211.55.8:8000/apiRunning 20s test @ http://10.211.55.8:8000/api 2 threads and 200 connections Thread Stats Avg Stdev Max +/- Stdev Latency 2.86ms 5.19ms 121.99ms 98.55% Req/Sec 40.50k 2.11k 46.14k 69.00% 1611550 requests in 20.01s, 242.83MB readRequests/sec: 80546.35Transfer/sec: 12.14MB```# Four 、 How to install it   ** At present, it's only in Ubuntu20.04 Development testing on the Internet , Not ready to support other non Linux The operating system .**1. From Git clone Packed execution ( Note that java Branch ):```shellgit clone -b java https://github.com/enjoycode/appbox.deploy.git```2. Install third party dependency packages ```shellcd Clone Directory sudo ./install-dependencies.sh```3. Start execution * First initialization execution ( Replace the following node address with the local address ):```shell./appbox --init=10.10.10.10:9000 --peer=1.1.1```* Restart ```shell./appbox```4. Open browser access IDEhttp:// Address :8000/dev/index.html, User name : Admin code : At will ( Authentication password has not been implemented yet )# 5、 ... and 、 Summary of this article    The whole java To achieve from 7 It starts at the end of the month 5 Months , There's a circle in the middle 1 Months of detour , Strive for 1 to 2 Basically available within months , Welcome to join us

版权声明
本文为[itread01]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201224215001784v.html

Scroll to Top