little-cui commented on a change in pull request #953:
URL: 
https://github.com/apache/servicecomb-service-center/pull/953#discussion_r618900304



##########
File path: datasource/mongo/fast_register_config.go
##########
@@ -0,0 +1,27 @@
+package mongo
+
+import (
+       "sync"
+
+       "github.com/apache/servicecomb-service-center/server/config"
+)
+
+const defaultQueueSize = 500000
+
+var (
+       configOnce    sync.Once
+       fastRegConfig FastRegConfig
+)
+
+type FastRegConfig struct {
+       enable    bool
+       queueSize int
+}
+
+func Configuration() *FastRegConfig {

Review comment:
       不能叫Configuration,否则表示整个mongo实现的配置入口

##########
File path: datasource/mongo/FastRegister.md
##########
@@ -0,0 +1,82 @@
+# Fast Register
+
+Fast registration feature, can support millions of instance registration
+
+This feature is primarily used in scenarios where an ultra-high performance 
registry is required and is not recommended for scenarios where performance 
requirements are low or instance levels are small
+
+This feature is turn off by default, if need fast register you should open the 
fast registration switch
+
+When this feature is open, you can call register interface API, the service 
center will put instances in the queue, then direct return instanceId to users, 
at last, register registry asynchronously by timing task
+
+## QuickStart Guide
+1.Turn on the Fast Registration Switch 
+
+Modify the service-center configuration file /conf/app.yaml
+
+The default configuration of app.yaml is as follows:
+```
+register:
+  mongo:
+    fastRegister:
+      # enable to fast register instance,
+      # if fastRegister.enable is true, instance will be registered 
asynchronously,
+      # just put instance in the queue and return, and then register through 
the timing task
+      enable: false
+      # if fastRegister.enable is true, should set the queueSize to indicate 
the max number of concurrent registrations
+      queueSize: 500000
+```
+
+Turn on the switch, setting as follows:
+```
+register.mongo.fasterRegister.enable=true
+```
+
+
+2.Configure the fast registration queue length, the default is 50W
+```
+register.mongo.fasterRegister.queueSize=500000
+```
+
+3.start service center
+```
+./service-center
+```
+
+4.Call the registry interface
+
+Call the registry interface, you will receive InstanceID soon, now a fast 
registration has been completed once
+
+* Registered instance APIs can be called concurrently
+* There is a slight delay between returning the instanceID and actually 
registering the instance to database, but 100w instance registration delays are 
within seconds
+* If more than 15 minutes did not discovery the instance ,there may be a 
problem with the environment. The client can register again with the InstanceID 
that has been generated and return to user
+
+## Process Design
+The flow chart is as follows:
+
+
+![register_image](fast_register_design.png)
+
+Normal Case:
+
+If the fast registration is enabled, it is put in the queue and eventually 
registered to MongoDB in batch by timed tasks(The time interval is 100 
millimeters)
+
+
+Abnormal Case:
+
+1. If the connection between Mongo and service center is broken, and the 
registration fails, the instance will be put into the failure queue and 
registered again
+2. If the registration fails for 3 consecutive times, the fuse will be cut off 
for 5s and resume after successful registration
+3. If a single instance fails to register for more than 500 times, the 
instance will be discarded, and the SDK will register again when the heartbeat 
finds that the instance does not exist
+
+## Attention
+1.The database with ETCD scenario does not have this feature; only the Mongo 
database scenario does
+
+2.Because the registration is asynchronous, there will be a certain amount of 
delay in the registration, the delay is basically in the second level
+
+## Performance Test

Review comment:
       用表格呈现

##########
File path: datasource/mongo/fast_register_test.go
##########
@@ -0,0 +1,129 @@
+package mongo_test

Review comment:
       缺少license header

##########
File path: datasource/mongo/FastRegister.md
##########
@@ -0,0 +1,82 @@
+# Fast Register

Review comment:
       文件放到docs/user-guides里面,并更新docs/user-guides.rst

##########
File path: datasource/mongo/fast_register_config.go
##########
@@ -0,0 +1,27 @@
+package mongo

Review comment:
       缺少license header




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to