nacos
nacos copied to clipboard
Nacos unable to publish flow control rules to Sentinel Dashboard
Describe the bug Nacos unable to publish flow control rules to Sentinel Dashboard
Expected behavior Nacos releases flow control rules that can be synchronized to Sentinel Dashboard
Actually behavior
【Bug】Nacos unable to publish flow control rules to Sentinel Dashboard
Version Description:nacos=2.4.0、Sentinel Dashborad=1.8.8、spring.cloud.alibaba.version=2023.0.1.2
dependencies
<!-- sentinel-gateway依赖 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>
</dependency>
<!-- sentinel-datasource-nacos依赖 -->
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-nacos</artifactId>
</dependency>
application.yaml
spring:
cloud:
nacos:
server-addr: # Nacos server address
username: # Nacos username
password: # Nacos password
discovery: # [Configuration Center] Configuration Items
namespace: dev # Namespace. We use the dev development environment here
group: DEFAULT_GROUP # The Nacos configuration group used defaults to DEFAULT_GROUP
config: # [Registration Center] Configuration Items
namespace: dev # Namespace. We use the dev development environment here
group: DEFAULT_GROUP # The Nacos configuration group used defaults to DEFAULT_GROUP
sentinel:
datasource:
r1:
nacos:
username:
password:
namespace: dev
server-addr: # Nacos server address
data-id: ${spring.application.name}-sentinel
group-id: DEFAULT_GROUP
rule-type: flow
transport:
dashboard: 127.0.0.1:8080
client-ip: 127.0.0.1
Nacos configuration flow control
Since microservices are created using the 'dev' namespace, configurations need to be created in the 'dev' namespace.
[
{
"resource": "system-admin-api",
"resourceMode": 0,
"count": 10,
"grade": 1,
"controlBehavior": 0,
"intervalSec": 10,
"burst": 0,
"maxQueueingTimeoutMs": 1000
}
]
At this point, we can see that the QPS we have set is 10, and then start Sentinel Dashboard, gateway, and corresponding business microservices.
When accessing the system admin API service, it can be seen that there is no problem accessing when QPS is set to 10.
Modify Nacos configuration for current limiting (change count to 2)
After testing, it was found that it has already taken effect. If three requests are sent within 1 second, one will be intercepted.
Sentinel Dashboard configuration flow control
Situation 1
In the above situation, we directly added flow control rules and set the threshold of QPS to 10.
Situation 2
Restart the gateway and other services, first configure from the dashboard and then from Nacos
At this point, the configuration in Nacos is as follows
[
{
"resource": "system-admin-api",
"resourceMode": 0,
"count": 2,
"grade": 1,
"controlBehavior": 0,
"intervalSec": 10,
"burst": 0,
"maxQueueingTimeoutMs": 1000
}
]
The flow control rule interface of the dashboard is as follows. As it is read from memory, each flow control rule needs to be reconfigured.
How to Reproduce Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See errors
Desktop (please complete the following information):
- OS: MacOS
- Version nacos-server 2.4.0
- Module config
- SDK spring-cloud-alibaba-nacos Additional context Add any other context about the problem here.