R
Railway3mo ago
pauldps

Idle Rails app not sleeping

I deployed a Rails API recently with App Sleeping enabled, but the app is not sleeping after idling for hours. There's activity in Network metrics that I can't figure out where it's coming from, as the logs don't show anything other than old API requests. Things I've tried: - Disabled public URL to prevent external access including bots. Doesn't seem to change anything in Network graph - Disabled database connection reaping in my database config (it was running every 10 seconds) but it doesn't seem to have fixed it. For context, the app connects to an external Postgres database (not on Railway). There's not anything else external such as Redis, it's only the database.
No description
20 Replies
Percy
Percy3mo ago
Project ID: 71754a48-09bb-4250-b361-ff5ab1df9597
pauldps
pauldps3mo ago
71754a48-09bb-4250-b361-ff5ab1df9597 Found a message that might explain the problem (edit: not sure) https://discord.com/channels/713503345364697088/1210336429855473705/1210697666514915368 So since it connects to an external/public database it can't go to sleep, even without outbound traffic?
pauldps
pauldps3mo ago
Also it seems it's only incoming traffic which should not matter for App Sleeping according to ➡️ https://discord.com/channels/713503345364697088/1210336429855473705/1210706235033391186
No description
Brody
Brody3mo ago
there is outbound traffic though, looks at your graph very closely inbound traffic would tend to generate outbound as your app answers the request
pauldps
pauldps3mo ago
ah ok, indeed there are tiny variations in the outbound traffic I'm assuming the inbound traffic is coming from the database connection since the public URL is disabled although I just noticed that in the same project I have another API, not in Rails but in Node/Bun, that connects to a database which is a libSQL private instance inside the project and is also not sleeping, would the same apply even if the db for that one is not external/public?
Brody
Brody3mo ago
private network traffic does not count towards inbound and outbound, in fact you can't even currently wake a service via the private network.
pauldps
pauldps3mo ago
it must be something else then. The app in question is Node/Bun with these deps:
"dependencies": {
"@libsql/client": "0.5.6",
"@paralleldrive/cuid2": "2.2.2",
"bcrypt": "5.1.1",
"drizzle-orm": "0.30.5",
"elysia": "1.0.9",
"jose": "5.2.3",
"lodash": "4.17.21"
},
"dependencies": {
"@libsql/client": "0.5.6",
"@paralleldrive/cuid2": "2.2.2",
"bcrypt": "5.1.1",
"drizzle-orm": "0.30.5",
"elysia": "1.0.9",
"jose": "5.2.3",
"lodash": "4.17.21"
},
perhaps something in there is doing telemetry or something
Brody
Brody3mo ago
that's also possible
pauldps
pauldps3mo ago
something seems off. The Bun app was sleeping before (I think... I don't have evidence other than the huge gap in the graph below). After an unintentional restart there's constant network traffic:
No description
pauldps
pauldps3mo ago
It restarted because I mistakenly disabled Private Networking for the Rails app without knowing that it was a project-wide setting, so all my apps deployed when I changed it I changed it back (reenabled Private Networking for the project) and it re-deployed a second time, which resulted in that constant Network activity. I'll let it run overnight to see if this behavior continues
pauldps
pauldps2mo ago
Updated 30d Network graph from above
No description
pauldps
pauldps2mo ago
could this Network traffic be investigated? There were no changes in the app code-wise. This refers to the Bun app that connects to the libSQL database via private networking. Logs don't show incoming requests for the past 2 days or so, so I'm at a loss here. I now know that the Rails app will never go to sleep due to connecting to an external database, but that shouldn't be the case for the Bun app I think.
Brody
Brody2mo ago
I'm sorry but this isn't something the team could help with the team is only able to provide hobby users support for billing or platform issues
pauldps
pauldps2mo ago
Then help me understand this graph a bit better so I can investigate myself on correct data: - is private networking activity reported in that graph? - is Docker-level (OS/Kernel/etc) activity (anything outside of my app code) reported there as well?
Brody
Brody2mo ago
1. no 2. any traffic going outside and coming back of the private network is counted
pauldps
pauldps2mo ago
so it's just real ingress/egress from my app? what if the Docker image for some reason uses an apt package that does telemetry for instance? (I'm assuming it doesn't count)
Brody
Brody2mo ago
that would be counted, since that would be outbound traffic
pauldps
pauldps2mo ago
got it. Would that affect the app's ability to sleep? Assuming yes
Brody
Brody2mo ago
yep, outbound traffic is what keeps the service awake
pauldps
pauldps2mo ago
thanks for the answers. I'll try tweaking the Dockerfile as well as investigating traffic from the app, something like monkey-patching http.request in Node feel free to close this (I don't know how)