Configuration
Discret provides some configuration options that will be passed to the engine at startup.
parallelism: integer
Defines the global parallelism capabilities. This number impact:
- the maximum number of room that can be synchronized in parallel,
- the number of database readings threads
- the number of signature verification threads
- the number of shared buffers used for reading and writing data on the network
- the depth of the channels that are used to transmit message across services
Larger numbers will provides better performances at the cost of more memory usage. Having a number larger that the number of CPU might not provides increased performances
auto_accept_local_device: boolean
When connecting with the same key_material on different devices, those devices exchanges their hardware fingerprint to check wether they are allowed to connect. This add an extra layer of security in the unlucky case where your secret material is shared by another person on the internet (which could be relatively frequent as users tends use weak passwords).
When connecting over the internet, new hardware is always silently rejected.
However, on local network we trust new hardware by default. This behaviors can be disabled by setting 'auto_accept_local_device' to false. In this case, when a new device is detected on the local network:
- a sys.AllowedHardware will be created with the status:'pending'
- a PendingHardware Event will be triggered
- the current connection attempt will be rejected
auto_allow_new_peers: boolean
Defines the behavior of the system when it discover a new peer while synchronizing a room.
auto_allow_new_peers=true:
- I implicitly trust friends of my friends. It is easy to setup, but could cause problems.
auto_allow_new_peers=false:
- Trust is given on a case by case basis, this is the recommended configuration.
Let's imagine that you have manually invited Bob to chat with you. Bob want's you to meet Alice and creates a group chat with both of you. During the synchronization, you device detects a new peer(Alice), and add it to the sys.Peer list.
If auto_allow_new_peers is set to 'true', you're device will allow Alice to directly connect with you. It makes the network stronger, as Alice will be able to see your message even if Bob is not connected. But it comes at the cost of some privacy, because you now share your IP address with Alice. In case of large communities, this setup will make your allowed peers very large, increasing the number of network connections, and increase resources usage.
If auto_allow_new_peers is set to 'false',
- a sys.AllowedPeer tuple is created with the status set to pending
- a PendingPeer event is triggered
max_object_size_in_kb: integer
Defines the maximum size of an entity tuple. Object size should be kept relatively small to ensure efficient synchronization.
This parameter has a direct impact on the size of the buffers used to read and write data on the network Increasing this value will increase the RAM usage of the application
!!WARNING!! once your program is in production, decreasing this value will break the system. No data will be lost but the system will not be able to synchronized objects that are larger than the reduced value.
read_cache_size_in_kb: integer
Set the maximum cache size for the database reading threads. Increasing it can improve performances. Every read threads consumes up to that amount, meaning that increasing the "parallelism" configuration will increase the memory usage.
write_cache_size_in_kb: integer
Set the maximum of cache size for the database writing thread. increasing it may improve performances
write_buffer_length: integer
Write queries are buffered while the database thread is working. When the database thread is ready, the buffer is sent and is processed in one single transaction. It greatly increase insertion and update rate, compared to autocommit. To get an idea of the performance difference, a very simple benchmark on a laptop with 100 000 insertions gives:
- Buffer size: 1 Insert/seconds: 55 <- this is equivalent to autocommit
- Buffer size: 10 Insert/seconds: 500
- Buffer size: 100 Insert/seconds: 3000
- Buffer size: 1000 Insert/seconds: 32000
If one a buffered query fails, the transaction will be rolled back and every other queries in the buffer will fail too. This should not be an issue as INSERT query are not expected to fail. The only reasons to fail an insertion are a bugs or a system failure (like no more space available on disk), and in both case, it is ok to fail the last insertions batch.
announce_frequency_in_ms: integer
how often (in milliseconds) an announces are sent over the network to meet peers to connect to.
enable_multicast: boolean
Enable/disable multicast discovery, i.e. local network peer discovery
multicast_ipv4_interface: String
Discret uses the IP multicast feature to discover peers on local networks. On systems with multiple network interfaces, it might be necessary to provide the right ip adress for multicast to work properly. the default (let the OS choose for you) should work on most cases.
multicast_ipv4_group: String
The multicast group that is used to perform peer discovery
pub enable_beacons: boolean
Enable/Disable beacon peer discovery. I.e. meet peers over the Internet.
pub beacons: List<BeaconConfig>,
List of Beacon servers that are used for peer discovery. Here is a sample configuration in the TOML format:
[[]]
= "sever.com:4264"
= "weOsoMPwj976xqxRvLElsbb-gijWWn0netOtgPflZnk"
[[]]
= "192.168.1.8:4266"
= "weOsoMPwj976xqxRvLElsbb-gijWWn0netOtgPflZnk"
A beacon defines two fields:
- hostname: the server address
- cert_hash: The certificate hash used by the server. This value is generated at the start of the server.
You will find information on how to start a beacon server and retrieve the cert_hash in the Beacon section.
pub enable_database_memory_security: boolean
Enable_memory_security: Prevents memory to be written into swap and zeroise memory after free.
Disabled by default because of a huge performance impact (about 50%). It should only be used if you're system requires a "paranoid" level of security. When this feature is disabled, locking/unlocking of the memory address only occur for the internal SQLCipher data structures used to store key material, and cryptographic structures.
source: cipher_memory_security