Run
Run the service via the /opt/spt/bin/configdb executable. Command line options may be specified to override default options. When running as a Docker container, use environment variables to specify the command line options.
-f | --config-file- The path to the JSON configuration file. All other options are ignored. This option provides total control over all configurable options including encryption. File must have same structure as the struct. See test for sample JSON configuration. For Docker specify theCONFIG_FILEenvironment variable.Logging - Options related to logging.
-c | --console- Flag that controls whether logs are echo'ed to stdout. Default isoff. Always specified in the Docker entrypoint. No value (true,false) etc. must be specified.-l | --log-level- The log level to set. Defaultinfo. Supported valuescritical|warn|info|debug. Specify viaLOG_LEVELenvironment variable to docker.-o | --log-dir- The directory under which log files are written. Defaultlogs/relative path. On docker this is set to/opt/spt/logs. Files are rotated daily. External scripts (cronetc. are needed to remove old files).
-p | --http-port- The port on which the HTTP/2 service listens. Default6020(6026on Apple). Specify viaHTTP_PORTenvironment variable to docker.-t | --tcp-port- The port on which the TCP/IP service listens. Default2020(2022' on Apple). Specify viaTCP_PORTenvironment variable to docker.-b | --notify-port- The port on which notifications are published. Default2120(2122on Apple). Specify viaNOTIFY_PORTenvironment variable to docker.-s | --with-ssl- Flag to enable SSL on the HTTP/2 and TCP services. See SSL for details. Specify viaENABLE_SSLenvironment variable to docker.-n | --threads- The number of threads for both TCP/IP and HTTP/2 services. Default to number of hardware threads. Specify viaTHREADSenvironment variable to docker.-e | --encryption-secret- The secret to use to encrypt values. Default value is internal to the system. Specify viaENCRYPTION_SECRETenvironment variable to docker.-x | --enable-cache- Flag to enable temporary cache for keys read from the database. Defaultoff. Specify viaENABLE_CACHEenvironment variable to docker.-z | --peers- A comma separated list of peer instances to listen for notifications. Specify via thePEERSenvironment variable to docker. Eg.localhost:2123,localhost:2124
Sample command to run the service
Environment Variables
Service configuration can be customised using environment variables. All properties can be specified using a snake case convention with the common root CONFIG_DB_ prefix.
CONFIG_DB_THREADS- use to set the value of thethreadsfield.CONFIG_DB_ENABLE_CACHE- use to set the value of theenableCachefield. Set tofalseto disable (default). Set totrueto enable.CONFIG_DB_ENCRYPTION_SALT- use to set the value of theencryption.saltfield.CONFIG_DB_ENCRYPTION_KEY- use to set the value of theencryption.keyfield.CONFIG_DB_ENCRYPTION_IV- use to set the value of theencryption.ivfield.CONFIG_DB_ENCRYPTION_SECRET- use to set the value of theencryption.secretfield.CONFIG_DB_ENCRYPTION_ROUNDS- use to set the value of theencryption.roundsfield.CONFIG_DB_LOGGING_LEVEL- use to set the value of thelogging.levelfield.CONFIG_DB_LOGGING_DIR- use to set the value of thelogging.dirfield.CONFIG_DB_LOGGING_CONSOLE- use to set the value of thelogging.consolefield.CONFIG_DB_SERVICES_HTTP- use to set the value of theservices.httpfield.CONFIG_DB_SERVICES_TCP- use to set the value of theservices.tcpfield.CONFIG_DB_SERVICES_NOTIFY- use to set the value of theservices.notifyfield.CONFIG_DB_PEERS[0..6]_HOST- use to set the value of thepeers[n].hostfield (e.g.CONFIG_DB_PEERS0_HOST).CONFIG_DB_PEERS[0..6]_PORT- use to set the value of thepeers[n].portfield.CONFIG_DB_STORAGE_DBPATH- use to set the value of thestorage.dbpathfield.CONFIG_DB_STORAGE_BACKUP_PATH- use to set the value of thestorage.backupPathfield.CONFIG_DB_STORAGE_BLOCK_CACHE_SIZE_MB- use to set the value of thestorage.blockCacheSizeMbfield.CONFIG_DB_STORAGE_CLEAN_EXPIRED_KEYS_INTERVAL- use to set the value of thestorage.cleanExpiredKeysIntervalfield.CONFIG_DB_STORAGE_ENCRYPTER_INITIAL_POOL_SIZE- use to set the value of thestorage.encrypterInitialPoolSizefield.CONFIG_DB_STORAGE_MAX_BACKUPS- use to set the value of thestorage.maxBackupsfield.CONFIG_DB_STORAGE_USE_MUTEX- use to set the value of thestorage.useMutexfield.
Notifications
A notification system is available when services are run in a cluster. There is no complicated leadership election process (using Raft or similar) for cluster management/coordination. Each node is designed to run stand-alone. Peer instances are assumed to run independently (multi-master setup). A simple notification system has been implemented which will attempt to keep the independent nodes in sync. Notifications are primarily useful when using a cluster of instances that are also used as a L1/L2 cache on top of application databases. Notifications are sent asynchronously and hence will only achieve eventual consistency in the best case.
When operating in multi-master mode, it is important to configure each instance with the appropriate list of peers. See integration test for sample set up and test suite.
Each instance will publish updates (Put, Delete, and Move) via the notification service. Corresponding listener instances will listen to notifications from the peers.
Notifications are strictly one-way. Notification service only writes messages to the socket, and the listener instances only read messages from the socket. Errors encountered while applying updates on another node do not have any effect on the publishing node.
Notification service sends periodic ping messages to keep the socket connections alive.
SSL
SSL wrappers are enabled for both the TCP and HTTP/2 services. The package includes self-signed certificates. The Makefile can be modified to generate self-signed certificates for your purposes. The easier way to override the certificates is to volume mount the /opt/spt/certs directory when running the docker container.
At present, the file names are hard-coded:
ca.crt- The root CA used to verify.server.crt- The server certificate file.server.key- The server key file.client.crt- The client certificate file.client.key- The client key file.
Note: There is definitely an overhead when using SSL. The integration test suite that ran in less than 100ms now takes about 900ms. With 4096 bit keys, it takes about 1.3s.
Note: The TCP service only supports TLS 1.3