TTL index internals

Welcome to the community @Prateek_GUpta,

It looks like you already have answers to most of your questions aside from #4. Your comment for #1 is also related to index creation, not the TTL background thread.

There is only a single TTLMonitor thread, which wakes up every 60 seconds by default and iterates TTL indexes to find expired documents to remove.

The TTL background thread is enabled by default on all data-bearing mongod instances. The TTL background thread will be idle for a replica set member unless it is currently in Primary state, since documents can only be directly deleted on a Primary. Secondary members apply delete operations via replication so they are consistent with the TTL expiry outcome on the Primary.

Regards,
Stennie

1 Like