inotify Watch Limit Planner

Work out how many inotify watches a directory tree needs, and what fs.inotify.max_user_watches, max_user_instances and max_queued_events should be for the services that watch it.

Watch tree

Count every subdirectory, not just the roots: a directory watch covers entries in that directory only. find . -type d | wc -l counts a tree.

The busiest rate one watching process sees, and how long it may leave events queued before draining them. Both feed the queue target; leave the rate at 0 to skip queue sizing.

Your current limits optional

Read them with sysctl fs.inotify.max_user_watches fs.inotify.max_user_instances fs.inotify.max_queued_events. Empty fields are treated as unknown; enter all three to get a sysctl snippet.

What the numbers mean
MeasureValue
Watches per process
Watches per user
Target max_user_watches
Instances needed
Events before a drain
Target max_queued_events
Compared with the limits you entered
LimitNeededTargetCurrentVerdict

inotify reports file system events to a process that holds an inotify instance. A watch belongs to one path: a watch on a directory reports events for entries inside that directory, and every subdirectory needs its own watch, so a recursive watcher on a tree holds one watch per directory plus one per file it watches individually. Watches are counted per real user ID, so two services running as the same user add up; fs.inotify.max_user_watches bounds that total, and when it is exhausted inotify_add_watch fails with ENOSPC. fs.inotify.max_user_instances bounds how many instances one user may create, and since a queue belongs to an instance each watching process needs one. fs.inotify.max_queued_events caps the events waiting in an instance's queue at creation time; beyond it events are dropped, though the kernel always delivers an IN_Q_OVERFLOW event so the reader can tell it lost some. The targets here are planning figures: watches are multiplied across the processes of one user, your headroom percentage is added, and both targets are rounded up to the next whole watch or event. Queue sizing treats the peak rate as lasting for the whole drain interval, which is the worst case you supply. The instances figure is a floor, not a recommendation: max_user_instances is shared with every other program in the same session, so leave room above it. None of this is kernel policy — the limits exist to bound kernel memory, every watch holds kernel memory until it is removed, and a limit should be raised only as far as the tree and its growth need. The snippet keeps the larger of each value you enter, so it never lowers a limit. Everything is calculated in your browser; nothing is sent or stored.