From 241b9bc3a2d7a9cdf87c763e032fd2a251624bef Mon Sep 17 00:00:00 2001 From: Panxt <993660576@qq.com> Date: Sat, 16 Nov 2024 11:22:05 +0800 Subject: [PATCH 1/3] Introduce a compile flag ENABLE_MULTIDB --- doc/database/multi_database_instances.md | 28 +++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/doc/database/multi_database_instances.md b/doc/database/multi_database_instances.md index c4858d4dca..fa92a18d49 100644 --- a/doc/database/multi_database_instances.md +++ b/doc/database/multi_database_instances.md @@ -26,6 +26,28 @@ DUT try to load a new images * [x] restore selected files in /etc/sonic/old\_config to /etc/sonic/, if any * [x] if no folder /etc/sonic/old\_config/, generate config\_db.json based on xml and etc. +### High-Level Design + +SONiC build system includes a new build-time flag to ENABLE_MULTIDB (Default: unset, Value: y). +When this flag is set, a flag file is touched at /etc/sonic/ by sonic_debian_extension.j2. +``` +## Enable MULTIDB +{% if ENABLE_MULTIDB == "y" %} +sudo touch $FILESYSTEM_ROOT_ETC_SONIC/enable_multidb +{% endif %} +``` +Example ENABLE_MULTIDB flag usage: + +Enable MULTIDB: +``` +make ENABLE_MULTIDB=y all +``` + +Do not enable MULTIDB: +``` +make all +``` + ## New Design of Database Startup * We introduce a new configuration file. @@ -94,7 +116,7 @@ DUT try to load a new images * By default, each image has one default startup database\_config.json file in SONiC file system at /etc/default/sonic-db/. -* The users is able to use the customized database configration, what needs to do is creating a database\_config.josn file and place it at /etc/sonic/ +* The users is able to use the customized database configration, what needs to do is creating a database\_config.json file and place it at /etc/sonic/ * We changed the database Docker ENTRYPOINT to docker-database-init.sh which is new added. @@ -108,8 +130,8 @@ Detail steps as below: * [x] if no folder /host/old\_config/, copy some default xmls and etc. as usual 3. **database service** * [x] **database docker start, entrypoint docker-database-init.sh** - * [x] **if database\_config.json is found at /ect/sonic/, that means there is customized database config, we copy this config file to /var/run/redis/sonic-db/, which is the running database config file location, all the applications will read databse information from this file** - * [x] **if database\_config.json is NOT found at /ect/sonic/, that means there is no customized database config, we copy this config file at /etc/default/ to /var/run/redis/sonic-db/, this is the default startuo config in the image itself.** + * [x] **if database\_config.json is found at /etc/sonic/, that means there is customized database config, we copy this config file to /var/run/redis/sonic-db/, which is the running database config file location, all the applications will read databse information from this file** + * [x] **if database\_config.json is NOT found at /etc/sonic/, that means there is no customized database config, we use multi\_database\_config.json.j2 or to database\_config.json.j2 generate database\_config.json depending on whether /etc/sonic/enable\_multidb exists** * [x] **using supervisord.conf.j2 to generate supervisord.conf** * [x] **execute the previous entrypoint program /usr/bin/supervisord, then all the services will start based on the new supervisord.conf, which including starting how many redis instances** * [x] **check if redis instances are running or NOT via ping_pong_db_insts script** From b2c6b27905dad9b995fc9cc93dc38061983ac498 Mon Sep 17 00:00:00 2001 From: Panxt <993660576@qq.com> Date: Sat, 16 Nov 2024 11:45:48 +0800 Subject: [PATCH 2/3] update multi_database_instances.md --- doc/database/multi_database_instances.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/database/multi_database_instances.md b/doc/database/multi_database_instances.md index fa92a18d49..4b580a475f 100644 --- a/doc/database/multi_database_instances.md +++ b/doc/database/multi_database_instances.md @@ -114,7 +114,7 @@ make all } ``` -* By default, each image has one default startup database\_config.json file in SONiC file system at /etc/default/sonic-db/. +* By default, each image uses multi\_database\_config.json.j2 or database\_config.json.j2 to generate database\_config.json depending on whether enable multidb. * The users is able to use the customized database configration, what needs to do is creating a database\_config.json file and place it at /etc/sonic/ @@ -131,7 +131,7 @@ Detail steps as below: 3. **database service** * [x] **database docker start, entrypoint docker-database-init.sh** * [x] **if database\_config.json is found at /etc/sonic/, that means there is customized database config, we copy this config file to /var/run/redis/sonic-db/, which is the running database config file location, all the applications will read databse information from this file** - * [x] **if database\_config.json is NOT found at /etc/sonic/, that means there is no customized database config, we use multi\_database\_config.json.j2 or to database\_config.json.j2 generate database\_config.json depending on whether /etc/sonic/enable\_multidb exists** + * [x] **if database\_config.json is NOT found at /etc/sonic/, that means there is no customized database config, we use multi\_database\_config.json.j2 or database\_config.json.j2 to generate database\_config.json depending on whether /etc/sonic/enable\_multidb exists** * [x] **using supervisord.conf.j2 to generate supervisord.conf** * [x] **execute the previous entrypoint program /usr/bin/supervisord, then all the services will start based on the new supervisord.conf, which including starting how many redis instances** * [x] **check if redis instances are running or NOT via ping_pong_db_insts script** From 4aeb225486a24b4588686d89d4682ae762c1f5c0 Mon Sep 17 00:00:00 2001 From: Panxt <993660576@qq.com> Date: Sat, 16 Nov 2024 11:51:02 +0800 Subject: [PATCH 3/3] multi_database_instances.md --- doc/database/multi_database_instances.md | 44 ++++++++++++------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/doc/database/multi_database_instances.md b/doc/database/multi_database_instances.md index 4b580a475f..9b890d2be2 100644 --- a/doc/database/multi_database_instances.md +++ b/doc/database/multi_database_instances.md @@ -4,6 +4,28 @@ ​ Today SONiC only has one redis database instance created and all the databases use this unique database instance, like APPL\_DB, ASIC\_DB, CONF\_DB and so on. We found when there are huge writes operations during a short time period (like huge routes created), this only database instance is very busy. We tried to create two database instances and separate the huge write into two database instances. The test result shows the performance (time) improved 20-30%. Also creating multiple database instances help us to separate the databases based on their operation frequency or their role in the whole SONiC system, for example, like state database and loglevel database are not key features, we can avoid them affecting read and write APPL\_DB or ASIC\_DB via multiple database instances. +## High-Level Design + +SONiC build system includes a new build-time flag to ENABLE_MULTIDB (Default: unset, Value: y). +When this flag is set, a flag file is touched at /etc/sonic/ by sonic_debian_extension.j2. +``` +## Enable MULTIDB +{% if ENABLE_MULTIDB == "y" %} +sudo touch $FILESYSTEM_ROOT_ETC_SONIC/enable_multidb +{% endif %} +``` +Example ENABLE_MULTIDB flag usage: + +Enable MULTIDB: +``` +make ENABLE_MULTIDB=y all +``` + +Do not enable MULTIDB: +``` +make all +``` + ## Current implementation * Single Redis database instance for all databases @@ -26,28 +48,6 @@ DUT try to load a new images * [x] restore selected files in /etc/sonic/old\_config to /etc/sonic/, if any * [x] if no folder /etc/sonic/old\_config/, generate config\_db.json based on xml and etc. -### High-Level Design - -SONiC build system includes a new build-time flag to ENABLE_MULTIDB (Default: unset, Value: y). -When this flag is set, a flag file is touched at /etc/sonic/ by sonic_debian_extension.j2. -``` -## Enable MULTIDB -{% if ENABLE_MULTIDB == "y" %} -sudo touch $FILESYSTEM_ROOT_ETC_SONIC/enable_multidb -{% endif %} -``` -Example ENABLE_MULTIDB flag usage: - -Enable MULTIDB: -``` -make ENABLE_MULTIDB=y all -``` - -Do not enable MULTIDB: -``` -make all -``` - ## New Design of Database Startup * We introduce a new configuration file.