I've been getting into web applications and node.js lately, and it's obvious that you should write user data to the disk, but when should I? It would be a bit overkill and very resource intensive to write to the disk every time data is updated, so when should you?
I'd recommend creating a temporary memory (RAM) cache to store user data. (For data of active users)
This temporary disk cache should be read and written to as though it were the normal on-disk user save data. Just ensure that every once in a while this cached data is written to disk, and you're good to go.