What is the sleep mechanism of app?

What is the sleep mechanism of app?
Will it automatically go to sleep after a week of inactivity?

Way before that, actually.

How long?

I don’t measure, but it usually feels like a couple of days. Anyway there are no guarantees, your application might be put to sleep at any moment.

I feel that keeping active will also cause sleep. Is this mandatory?

I don’t think I understand what you mean. Has your application been put to sleep while a user was connected?

What I mean is that someone will visit my project homepage every day, and the project will still go dormant after a few days.

It seems that there is no connection between dormancy and whether there is anyone visiting

I just revisited my analytics. I have a dormant app that was last visited “1 day ago”. Another application of mine that has been awake for months shows visits every few hours (which is extremely weird, but let’s keep that aside).

So there seems to be some connection, but the seven days mentioned in the docs are quite far from what I am seeing.

It is indeed very strange.
The 7 days mentioned in the document are not accurate.
I hope the staff of streamlit can update the document.