当前位置:网站首页>How does IOT platform realize business configuration center
How does IOT platform realize business configuration center
2022-04-21 23:00:00 【Huawei cloud developer community】
This article is shared from Huawei cloud community 《 Teach you how the IOT platform can realize the business configuration center 》, author : Hua Wei Yun IoT Senior engineer Zhang Jian .
Preface
Last one 《 Huawei cloud Internet of things advanced siege lion 4 Practice sharing of configuration center in 》 The article shares the business configuration center .
This article describes the business configuration center ( The following is a brief description of the configuration center ) The key technology and implementation of . Huawei cloud Internet of things platform implements a business configuration center according to the implementation method in this paper , This configuration center 2020 year 1 Monthly online , Smooth operation up to now .
1 Concept
1.1 Operation and maintenance configuration
It's not about users , It is usually configured at the cluster boundary level , The program will only read , Such as database configuration 、 Mailbox server configuration 、 Network card configuration 、 Subnet address configuration, etc .
1.2 Business configuration
As SaaS service , Each user has some business configuration on it . Such as the user's certificate configuration 、 Flow control configuration of user server, etc , These business configurations are relatively Operation and maintenance configuration It's more complicated for me , And there may be uniqueness restrictions , By user id only . This part of configuration data is usually triggered by user operation , Dynamic code writing , And notify each microservice instance . Usually , We hope that these configurations can be displayed in the interface , And support artificial modification . If the above logic is implemented by each micro service itself , There will be a lot of duplicate code , And there's no guarantee of quality . We want a common component to unify this capability . Open source or smaller projects will not choose to rely on a configuration center , But directly through the connection to the database or etcd To solve the problem
1.3 env
Represents a deployment environment .
1.4 cluster
Represents the cluster in the environment . It is common for blue-green publishing in a single environment , Blue cluster 、 Green clusters 、 Canary clusters, etc .
1.5 To configure
Configuration name , Such as user certificate configuration 、 User flow control configuration, etc .
1.6 Key
Unique key for configuration , Such as user id.
1.7 Value
Configure the value corresponding to the only key .
2 Configuration center design outline
2.1 Business configuration features
- Although there may be concurrency in business configuration writing , But the amount of concurrency is small , The frequency is low .
- Business configuration is often user-oriented id, The number of users in a single cluster is limited , Generally not more than 5 ten thousand .
2.2 Problems to be solved by the configuration center

2.3 Design points
- Single configuration requires configuration id, Every id through version Optimistic concurrency control to solve the problem of multi version conflict
- Notice is not reliable , When the application and configuration center are disconnected and cannot receive notifications , Ensure the reliability of data by regularly synchronizing data
- Support Schema Changes , because Schema Change infrequently , Also used version Optimistic concurrency control to solve the problem of multi version conflict
2.4 Whether the notification contains message content
I think we should only inform Key, The specific values let the application go to the configuration center to query . Just notice Key The implementation is simple and easy to understand . Notice at the same time Key&Value It is necessary to consider the two channels of periodic synchronization and notification concurrency , Possible race conflicts .
3 Configure the business process of the center
This section describes all business processes of the business configuration center , And try to abstract the interface irrelevant to the concrete implementation from the interaction
3.1 Add, delete, modify and check the configuration

3.2 Addition, deletion, modification and query of configuration value

3.3 Synchronize regularly
In the distributed environment , The notice may not be delivered , If the program falls into network interruption ( Or long gc), Notification message delivery timeout , After the program is restored , The data is no longer accurate . Therefore, the data needs to be synchronized regularly , Improve reliability .

During synchronization , Just request interaction id and version, Avoid transmitting large amounts of data . After the application receives the data that needs to be synchronized :
- Delete operation , Trigger deletion notification , Remove data from local cache .
- add to 、 Modify the operating , Query the configuration center for the latest data , Trigger notification and write to local cache .
3.4 Service startup
Service startup can also be regarded as a synchronous process , Just need to synchronize a large number of data additions . In order to avoid frequent and large requests to the configuration center , Introduce batch operation to reduce pressure

3.5 Limit
The design idea of the configuration center relies on the client to put all the data into the memory , If the number of users is too large , This model is not suitable .
notes : One way to save memory is , Only a full amount of... Is placed in memory id and version, Data can only be queried when needed . This idea requires the configuration center to persist some old data for query in the following scenarios
- In the business process , You need to use this configuration value .
- When the callback business program is modified , Need to provide the old value .
There is no other difference .
4 Abstract implementation of business configuration
From the business scenario described above , We abstract the interactive interface and abstract implementation of the business configuration center . Interface Swagger Yaml Uploaded to Github:https://github.com/Shoothzj/config-center/tree/master/swagger
4.1 Configure relevant interfaces
- Provide env、cluster、 Configuration name 、 To configure Schema、 Add configuration version number
- Provide env、cluster、 Configuration name delete configuration
- Provide env、cluster、 Configuration name 、 new Schema、 new Version To modify the configuration
- Provide env、cluster、 The configuration name is used to query the configuration
4.2 Configuration value related interface
- Provide env、cluster、 Configuration name 、Key、Value To add configuration values
- Provide env、cluster、Key、ValueVersion( Optional ) To delete the configuration value
- Provide env、cluster、Key、Value、ValueVersion( Optional ) Modify configuration values
- Provide env、cluster、Key Query the configuration value
- according to env、cluster、 The current configuration data of the application is used for periodic synchronization
- according to Key List batch query configuration values
4.3 Notify relevant interfaces
- Notify a env some cluster Next , One of the configuration items Key change , newly added 、 Modify or delete . The options are HTTP Long link (Inspired by Apollo)、Mqtt、WebSocket etc. .
4.4 Configuration center storage layer Abstract implementation
The configuration center storage tier requires storage To configure and Configuration values data , Support UpdateByVersion, And need to capture changes in data , Used to notify the application
4.5 Abstract implementation of service discovery
In order to connect the application to the configuration center , A discovery mechanism is needed to make the application aware of the address of the configuration center . There are many ways of high availability , Such as K8s Find out 、ZooKeeper、Etcd、ServiceComb、 Business environment variable injection ELB Address (ELB The address of the backend mount configuration center ) etc. .

4.6 Abstract summary
According to this abstraction , We can select the key technical points , To implement the business configuration center .
5 Configuration center implementation
5.1 Huawei cloud Internet of things configuration center realizes

- env+cluster+config The name of the data table
- One key、value Corresponding to a row of data
5.2 Another way to do it
As long as the above interfaces and abstraction capabilities are implemented , Business configuration center can be realized , It can also be achieved

- env+cluster+config+key Combine into etcd Of key
- One key、value Corresponding to a key value pair
5.3 Another implementation
Of course

- env+cluster+config+key Combine into RocksDB Of key
- One key、value Corresponding to a key value pair
Click to follow , The first time to learn about Huawei's new cloud technology ~
版权声明
本文为[Huawei cloud developer community]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204212023090125.html
边栏推荐
- 大厂面经合集,这些知识点你会吗
- APM industry awareness series - 12 - 13
- YARN线上动态资源调优
- MySQL Chapter 5 addition, deletion, modification and query of MySQL table data
- 成员变量与局部变量的对比
- Pytoch framework | torch nn. modules. Module(nn.Module)
- Track and trigger
- MySQL 第3章 SQL基础语法
- When the color contrast of beix3 is good, the color of the new version 3.1 is close to the original image
- 2022-04-22日报:基于Transformer的新型人脸属性编辑框架TransEditor
猜你喜欢

Apache Flink系列-④有状态函数

【ACM】46. Full Permutation (1. Here, the previous elements need to be used for permutation, so StartIndex is not used (only for combination and division); 2. Pay attention to whether the elements in t

音视频基本概念和FFmpeg的简单入门

MySQL 第5章 MySQL表数据的增删改查

CDGA敏捷开发的12个原则在企业数据治理中的应用

当贝X3色彩对比度好不好,新3.1版本色彩接近原图

Keil package common chip high-speed download address, including historical version, pay close attention to my quick collection

2022r2 mobile pressure vessel filling test exercises and online simulation test

1957年高考数学题

Cyclic queue and capacity expansion
随机推荐
One plus two earphone products: charge for 10 minutes and listen to music for 20 hours
MySQL Chapter 3 basic SQL syntax
mysql事务和隔离级别底层原理浅析
Precautions for self built VNC software
小程序如何集成即构IM实现即时通讯发消息聊天
[MQ] starting from scratch to realize mq-01-start of producers and consumers
Go language self-study series | golang pointer
Yarn online dynamic resource tuning
REM practical development adaptation scheme for mobile web development
Apache Flink series - ④ stateful functions
Analysts believe that Samsung Galaxy Z fold 4 and Z flip 4 may be cheaper than their previous products
模块三:外包学生管理系统-架构设计文档
1957 college entrance examination mathematics problems
7.3.1 homogeneous coordinate transformation & homogeneous transformation matrix
Application of 12 principles of cdga agile development in enterprise data governance
Kubernetes---Secret配置管理
AI application theory - special production and manufacturing session (parts installation and quality inspection)
go-map
APM industry awareness series - XV
【中南林业科技大学】【陈】第六周创新题素数