tntapi
The tntapi service provides interaction between the sf-api service and the Tarantool-based feature vector database in the following way:
Tip
See Tarantool official documentation for details.
From
sf-api,tntapireceives data, such as information of detected objects, to write into the feature vector database.By request from
sf-api,tntapiperforms database searches and returns search results.
Multiple tntapi shards can be created on each Tarantool host to increase search speed. Their running concurrently leads to a remarkable increase in performance (70x-100x).
Functionality:
saving object data to the feature vector database,
database search,
implementation of direct API requests to the database (see Direct API requests to tntapi).
Important
In a multi-shard environment, the configuration has to be done for each shard.
When configuring tntapi, refer to the following box.cfg parameters:
Parameter
Description
listenenv
TT_LISTENBinary host/port, used for admin operations and replication, e.g.
127.0.0.1:32001.
work_direnv
TT_WORK_DIRBase working directory.
memtx_direnv
TT_MEMTX_DIRDirectory for snapshots, can be relative to
work_dir.
wal_direnv
TT_WAL_DIRDirectory for xlogs, can be relative to
work_dir.
memtx_memoryenv
TT_MEMTX_MEMORYMaximum RAM that can be used by a Tarantool shard. Set in bytes, depending on the number of objects the hard handles. Consult our experts by support@ntechlab.com before setting this parameter.
checkpoint_intervalenv
TT_CHECKPOINT_INTERVALThe interval between snapshots(), in seconds.
checkpoint_countenv
TT_CHECKPOINT_COUNTMaximum number of snapshots that may exist on the
memtx_dir.
force_recoveryenv
TT_FORCE_RECOVERYIf
force_recoveryequals true, Tarantool tries to continue if there is an error while reading a snapshot file (at server instance start) or a write-ahead log file (at server instance start or when applying an update at a replica): skips invalid records, reads as much data as possible and lets the process finish with a warning.See box.cfg for details.
Refer to the following parameters:
Parameter
Description
CFG_LISTEN_HOSTDefault =
127.0.0.1. Host to public HTTP API.
CFG_LISTEN_PORTDefault =
8001. Port to public HTTP API.
CFG_NTLSDefault =
"". IP address and port of thentlslicense server.
CFG_LOG_REQUESTSDefault =
true. Log requests.
CFG_FASTIDX_SEARCH_THREADSDefault =
1. Number of threads to search in the quick index.
CFG_ALLOW_META_SCHEME_MIGRATIONDefault =
false. Enablemeta_schememigration. Possible only when adding new fields to the schema, if the existing ones completely match.
CFG_META_SCHEME_MIGRATION_SINGLE_TRANSACTIONDefault =
true. IfCFG_ALLOW_META_SCHEME_MIGRATIONis enabled:
CFG_META_SCHEME_MIGRATION_SINGLE_TRANSACTION=true: migration of one gallery occurs in one transaction until all data has migrated to the new schema, there is no entry in xlog. Galleries with a large number of faces may require a significant amount of memory.
CFG_META_SCHEME_MIGRATION_SINGLE_TRANSACTION=false: before migration, a box.snapshot() is taken, a flag file is created in thewal_dirdirectory. In case of a crash during migration, it is necessary to delete all the contents of thewal_dirdirectory, the data will be downloaded from snapshot.
CFG_BATCH_SEARCH_MAX_SIZEDefault =
1. Maximum size of search batches. If you specify a value > 1,facensearch for queries with the same other filters will be performed by batches of exactly this maximum size.
CFG_BATCH_SEARCH_MAX_DELAY_SECONDSDefault =
0.3. Maximum query timeout when batching a search (batch_search_max_size > 1). If exceeded, the search will be performed regardless of the simultaneous presence ofbatch_search_max_sizeof similar search queries.
CFG_EXTRA_LUADefault =
"". Additional LUA code that will be executed during initialization.
CFG_METRICS_HTTP_BUCKETSBuckets for the histogram of query times in metrics, for example:
CFG_METRICS_HTTP_BUCKETS="[0.2, 0.5, 1, 5]"
The database structure is set via the /opt/ffserver/configs/tnt-schema.lua file. You will have to manually set it via the configuration file.