Why Nacos Beats Eureka: In‑Depth Performance and Functional Testing
This article details how the Alibaba Nacos service registry was evaluated and chosen over Eureka, Zookeeper, and Consul for a large‑scale micro‑service platform, presenting comprehensive performance benchmarks, functional API tests, sync behavior analysis, and automated JUnit testing with real‑world deployment data.
Background
The original Eureka registration center could not handle the rapid growth of micro‑services and traffic. Spring Cloud’s first‑generation Eureka is in maintenance mode, prompting a migration to a more robust solution. After evaluating Alibaba Nacos, HashiCorp Consul, and Zookeeper, Nacos was selected for the Solar micro‑service system.
Registry Comparison
Eureka : Legacy Spring Cloud registry, now in maintenance mode.
Zookeeper : General‑purpose coordination service.
Consul : Service discovery and configuration, not deeply tested.
Nacos : Spring Cloud Alibaba member, supports service discovery and dynamic configuration.
1. Nacos Performance Test
A three‑node Nacos cluster (each 1 CPU × 4 GB) was deployed in a UAT environment. The test registered 1,499 services and 12,715 instances for one hour.
Test Script
def registry(ip):
fo = open("service_name.txt", "r")
service_name_list = fo.read().split(";")
service_name = random.choice(service_name_list)
fo.close()
client = nacos.NacosClient(nacos_host, namespace='')
client.add_naming_instance(service_name, ip, 333, "default", 1.0,
{'preserved.ip.delete.timeout':86400000}, True, True)
while True:
client.send_heartbeat(service_name, ip, 333, "default", 1.0, "{}")
time.sleep(5)Results
CPU usage: ~40%
Memory usage: ~50%
All services and instances remained stable throughout the hour.
2. Nacos Functional Test
The following REST APIs were verified (all return ok on success):
Register instance – POST /nacos/v1/ns/instance (params: ip, port, serviceName)
Deregister instance – DELETE /nacos/v1/ns/instance Update instance – PUT /nacos/v1/ns/instance Send heartbeat – PUT /nacos/v1/ns/instance/beat Update health status – PUT /nacos/v1/ns/health/instance/list Query instance list – GET /nacos/v1/ns/instance/list Query instance detail – GET /nacos/v1/ns/instance Full API reference: https://nacos.io/zh-cn/docs/open-api.html
3. Nacos‑Eureka Sync Test
Cross‑registration: Gateway registers to Eureka, Service A to Nacos, Service B to Eureka; synchronization works correctly.
Stress test: >1 M requests caused no errors; sync server remained stable.
Lossless call: When the sync server crashes, calls from gateway → A → B continue without impact.
Automatic sync creation: First deployment automatically creates sync tasks between Eureka and Nacos.
Sync server scaling: One 4C 8G machine can handle ~100 services; adding more servers balances load.
Etcd comparison: At least two Etcd nodes are required for 600 services; hash virtual node count must stay consistent.
4. Nacos Client UI Test
Cluster management UI correctly shows three node IPs after server restart.
Service list updates with newly registered services and instance counts.
Service details, health status, and metadata display correctly.
Only admin users can edit or delete services.
5. Automated Testing Framework
Tests were built with Spring Boot, JUnit, and custom annotations ( @DTest and @DTestConfig) to drive configuration changes and assertions.
Example Test Class
@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);
}
}Custom annotation definitions:
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface DTest {}
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface DTestConfig {
String group();
String serviceId();
String prefix() default StringUtils.EMPTY;
String suffix() default StringUtils.EMPTY;
String executePath();
String resetPath() default StringUtils.EMPTY;
}Sample gray‑release verification checks that version markers appear in the response and differ across calls, ensuring proper routing.
6. Test Results Summary
All functional and performance tests passed. Nacos demonstrated stable CPU/memory usage under heavy load, correct API behavior, reliable sync with Eureka, and a clean management UI. The automated test suite confirmed that gray‑release strategies work as expected.
Conclusion
Nacos provides excellent performance, a straightforward interface, and seamless integration with Spring Cloud, making it a compelling choice for large‑scale micro‑service registration and configuration management.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Alibaba Cloud Native
We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
