Fire and forget mode
Fire and forget mode enables multi-threaded, asynchronous inserts and can be set on the collection to enhance performance for inserts.
Fire and forget mode can be activated only when applications use a connection pool. If an application enables fire and forget for a single connection, the mode setting is ignored and the insert is run single-threaded.
The number of threads that are used for fire and forget is 10 by
default. This value can be changed by setting the asyncMaxThreadCount
in
the nosql.properties file. For example, to set
the number of threads to 100, use nosql.asyncMaxThreadCount=100
.
To enable fire and forget mode, the collection must set the WriteConcern
value to either NONE
or NORMAL
.
Other WriteConcern values such as SAFE
and JOURNAL_SAFE
disable
fire and forget mode because they guarantee writes to the database. For
more information, see the Java™ documentation for more information on WriteConcern.
The downside to using this mode is that the data is not guaranteed to be written to the server. Moreover, the application does not see an exception that is raised if an error did occur during an insert. However, for application scenarios that can tolerate loss of data, the performance gain from using this mode can be significant.