In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you a sample analysis of Nacos performance testing, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Background story
The infrastructure department selects a new registry, and the test team needs to cooperate with the industry's mature registry products for analysis and comparison. As the master education uses a relatively pure Spring Cloud technology stack, so we need to focus on its registry, from the perspective of testing, function and performance research.
Spring Cloud technology stack officially supports three registries: Netflix Eureka, HashiCorp Consul and Zookeeper, which can migrate seamlessly to each other. Alibaba Nacos is a new member of Spring Cloud technology stack. The students of the test group have done research and analysis on the above four registries. In view of the shortage of time, except for Eureka and Nacos, the other two middleware have not done in-depth functional testing and performance testing. The following is a screenshot of the information from an official industry announcement by Alibaba Nacos for your reference:
Eureka introduction
Zookeeper introduction
Consul introduction
Comparison of the above three registries
This article will focus on the functional testing and performance testing of Alibaba Nacos.
Nacos Test piece Nacos performance Test ① Nacos Server performance Test
Nacos with UAT is developed and deployed, and the test is tested in person.
Core script
Def registry (ip): fo = open ("service_name.txt", "r") str = fo.read () service_name_list = str.split (" ") service_name = service_name_ list.Randint (0lemlen (service_name_list)-1)] fo.close () client = nacos.NacosClient (nacos_host, namespace='') print (client.add_naming_instance (service_name,ip,333," default ", 1.0,{ 'preserved.ip.delete.timeout':86400000}, True,True)) while True: print (service_name,ip,333," default " 1.0, "{}") time.sleep (5)
Pressure test data
Pressure test result diagram
Nacos Server is three 1C4G clusters, with 1499 services and 12715 instance registrations at the same time, and CPU and memory are kept within a suitable range for a long time, so Nacos performance is quite OK.
Nacos function Test ① Nacos Server Interface Test
For more information on API, please see the official Nacos documentation: Open API Guide.
Https://nacos.io/zh-cn/docs/open-api.html
② Nacos Eureka Sync Test
Cross registration
Gateway, service A, service B each have 10 instances, gateway registers Eureka, A registers Nacos, B registers Eureka, synchronization is normal, can be called.
Pressure testing
Check whether the Sync Server will be affected if the number of requests is greater than 1 million. As a result, ErrorRequest = 0, and the number of synchronization services and instances remain unchanged.
There is a lossless call
The gateway Sync Server is down, and the gateway service Eureka synchronization Nacos failed, which does not affect the gateway-> A-> B call.
Automatically create synchronization
When the publishing system applies to Eureka / Nacos for the first time, it automatically creates a synchronization task of Eureka-> Nacos or a synchronization task of Nacos-> Eureka
Reduce Sync Server
Sync Server 4C8G, stop machines, decreasing one by one. Conclusion: on average, one 4C8G machine can synchronize up to 100services.
Add Sync Server
There are 2 Etcd nodes, one downtime, and the Etcd read timeout. Conclusion: there are at least 2 Etcd nodes in 600 services. It is emphasized here that when adding new services, the number of virtual nodes in the Hash algorithm must be the same as the original, otherwise synchronization failure will occur and cross-registry calls will be affected.
Restart Sync Server
Increase the number of Sync Server, restart Sync Server, and recalculate and balance the synchronization number of each node.
③ Nacos Client functional Test
The Nacos Client interface focuses on testing cluster management, service list and access control.
After Nacos Server restarts, the cluster management interface displays the IP of 3 cluster nodes normally.
After the service registers Nacos Server, the number of registered service names and instances are added to the service list, and you can view the details.
Service online and offline operations, health status and metadata display are normal.
Edit, delete and other operations can only be performed by people with Admin permissions.
④ Nacos Client Automation Test
Automated test link
Full link test path
API Gateway-> Service A (two instances)-> Service B (two instances)
Full-link service deployment
Automated test entry
Combined with Spring Boot Junit, TestApplication.class has a built-in application launcher for the test framework, and MyTestConfiguration is used to initialize all test case classes. Add the @ Test annotation of JUnit to the test method
@ RunWith (SpringRunner.class) @ SpringBootTest (classes = {TestApplication.class, MyTestConfiguration.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class MyTest {@ Autowired private MyTestCases myTestCases; private static long startTime; @ BeforeClass public static void beforeTest () {startTime = System.currentTimeMillis ();} @ AfterClass public static void afterTest () {LOG.info ("* Finished automation test in {} seconds", (System.currentTimeMillis ()-startTime) / 1000) } @ Test public void testNoGray () throws Exception {myTestCases.testNoGray (gatewayTestUrl); myTestCases.testNoGray (zuulTestUrl);} @ Test public void testVersionStrategyGray () throws Exception {myTestCases.testVersionStrategyGray1 (gatewayGroup, gatewayServiceId, gatewayTestUrl); myTestCases.testVersionStrategyGray1 (zuulGroup, zuulServiceId, zuulTestUrl);} @ Configurationpublic class MyTestConfiguration {@ Bean public MyTestCases myTestCases () {return new MyTestCases ();}
General call Automation Test based on Nacos Client
Add @ DTest to the test method and judge the test result by asserting Assert. Note @ DTest as follows:
Target ({ElementType.METHOD, ElementType.TYPE}) @ Retention (RetentionPolicy.RUNTIME) @ Inherited@Documentedpublic @ interface DTest {}
The code is as follows:
Public class MyTestCases {@ Autowired private TestRestTemplate testRestTemplate; @ DTest public void testNoGray (String testUrl) {int noRepeatCount = 0; List resultList = new ArrayList (); for (int I = 0; I
< 4; i++) { String result = testRestTemplate.getForEntity(testUrl, String.class).getBody(); LOG.info("Result{} : {}", i + 1, result); if (!resultList.contains(result)) { noRepeatCount++; } resultList.add(result); } Assert.assertEquals(noRepeatCount, 4); }} 基于 Nacos Client 的灰度蓝绿调用自动化测试 在测试方法上面增加注解 @DTestConfig ,通过断言 Assert 来判断测试结果。注解 DTestConfig 注解内容如下: @Target({ ElementType.METHOD, ElementType.TYPE })@Retention(RetentionPolicy.RUNTIME)@Inherited@Documentedpublic @interface DTestConfig { // 组名 String group(); // 服务名 String serviceId(); // 组名-服务名组合键值的前缀 String prefix() default StringUtils.EMPTY; // 组名-服务名组合键值的后缀 String suffix() default StringUtils.EMPTY; // 执行配置的文件路径。测试用例运行前,会把该文件里的内容推送到远程配置中心或者服务 String executePath(); // 重置配置的文件路径。测试用例运行后,会把该文件里的内容推送到远程配置中心或者服务。该文件内容是最初的默认配置 // 如果该注解属性为空,则直接删除从配置中心删除组名-服务名组合键值 String resetPath() default StringUtils.EMPTY;} 代码如下: public class MyTestCases { @Autowired private TestRestTemplate testRestTemplate; @DTestConfig(group = "#group", serviceId = "#serviceId", executePath = "gray-strategy-version.xml", resetPath = "gray-default.xml") public void testVersionStrategyGray(String group, String serviceId, String testUrl) { for (int i = 0; i < 4; i++) { String result = testRestTemplate.getForEntity(testUrl, String.class).getBody(); LOG.info("Result{} : {}", i + 1, result); int index = result.indexOf("[V=1.0]"); int lastIndex = result.lastIndexOf("[V=1.0]"); Assert.assertNotEquals(index, -1); Assert.assertNotEquals(lastIndex, -1); Assert.assertNotEquals(index, lastIndex); } }} 初始默认无灰度蓝绿的配置文件 gray-default.xml 灰度蓝绿生效的配置文件 gray-strategy-version.xml 1.0 基于 Nacos Client 的自动化测试报告样例 ---------- Run automation testcase :: testStrategyCustomizationGray() ----------Header : [a:"1", b:"2"]Result1 : zuul ->Solar-service-a [192.168.0.107 R=dev] [G=solar-group]-> solar-service-b [192.168.0.107] [G=solar-group]-> solar-service-b [192.168.0.107] [G=solar-group] Result2: zuul-> solar-service-a [192.168.0.107] [G=solar-group]-> solar-service-b [192.168.0.107] [G=solar-group]-> solar-service-b [192.168.0.107] R=dev] [G=solar-group] Result3: zuul-> solar-service-a [192.168.0.107 Result3 3002] [VPL1.1] [R=qa] [G=solar-group]-> solar-service-b [192.168.0.107 VOL4002] [VPL1.1] [R=dev] [G=solar-group] Result4: zuul-> solar-service-a [192.168.0.107 Result3 3002] [Venture 1.1] [R=qa] [G=solar-group]-> solar-service-b [192.168. 0.107 Passed- Run automation testcase 1.1] [R=dev] [G=solar-group] * Passed- Run automation testcase:: testVersionRuleGray ()-Result1: zuul-> solar-service-a [192.168.0.107 Passed- Run automation testcase 3002] [R=qa] [G=solar-group]-> solar-service-b [192.168.0.1074002] [R=dev] [G=solar-group] Result2: zuul- > solar-service-a [192.168.0.107 R=qa] [G=solar-group]-> solar-service-b [192.168.0.107] [G=solar-group]-> solar-service-b [192.168.0.107] [G=solar-group] Result3: zuul-> solar-service-a [192.168.0.107] [R=qa] [G=solar-group]-> solar-service-b [192.168.0.107] 4002] [Vogue 1.1] [R=dev] [G=solar-group] Result4: zuul-> solar-service-a [192.168.0.107 Result4 3001] [R=dev] [G=solar-group]-> solar-service-b [192.168.0.107 Result4 4001] [R=qa] [G=solar-group] * PassedNacos Test Summary
Nacos not only has good performance, but also has a simple interface, so you deserve to have a registry.
The above is all the content of the article "sample Analysis of Nacos performance Test". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.