App sleeping not working??
I've been learning backend dev for a few months, and I'm trying to enable app sleeping on some of my older projects that aren't really in use at all but that I like to visit every now and then to reference.
The app sleeping isn't working on any of my projects, and the metrics show that there's pretty constant inbound and outbound traffic. If the frontend site isn't being visited at all, where would this traffic be coming from? I would really like to utilize app sleeping because my bill has been rather high for some apps that are barely in use. I know I could just remove the deployments, but I'd really like to utilize this new feature on some projects if possible.
Solution:Jump to solution
you could try using cloudflare and enabling some of the bot filters. That might reduce some of the hits you get
74 Replies
Project ID:
cf56f7ac-b7df-4a38-abf6-b3de04633374
cf56f7ac-b7df-4a38-abf6-b3de04633374
if the service is exposed to the public web, you'll get a fair amount of bots and things periodically scan it. That'll be enough to wake it up out of app sleeping.
Solution
you could try using cloudflare and enabling some of the bot filters. That might reduce some of the hits you get
Is this the case for personal projects hosted on railway where I'm the only one who ever visits them?? I even completely removed one of my projects from railway and redeployed it with a new domain and it instantly started having inbound and outbound traffic even though I hadn't even opened it yet
Yes it’s pretty common, all my projects get inbound traffic from bots.
Do you log the requests? If you do you can see what is happening
I've been looking at the deploy logs in railway that show when requests are made to the server, and there is no activity there except for when I visit the frontend and make requests. The constant inbound/outbound activity persists even when the logs show no activity
The same here. I've joined this server to get help about it. Here's my metrics data. It gets traffic from nowhere. And prevents my app to sleep 😢
I've chosen Railway because of the sleep feature and this issue showed up 😥
there's honestly not much railway nor the community can do for you besides provide the advice that Mac has
Let me know if you're able to figure this out on your end!! I really don't think its bots in my case and my deploy logs aren't showing any activity, so I'm kinda stumped about where this network usage is coming from
it doesnt have to be http requests, could be anything like next telemetry reporting, port lookups, icmp, ntp, etc
Is there a good way to see exactly what it is if it's not http requests??
I'm wondering if it has to do with the mongodb database that's also in this project?? The server deploy logs only show my http requests, but the database deploy logs show a connection continuously being accepted and ended, so surely it has to do with this right? I'm not sure why this is happening though or how to stop it. Is this a normal thing with databases in railway??
do you connect to mongo over the public network?
I'm not sure, I don't think so though. I insert the connection string through the private variables in railway which goes to the following:
what is
MONGODB_URI
set toIt's set to the connection string for the database in railway
mongoDB is part of the project in railway i'm not using it externally
the public or private connection string?
it's not the private one so i'm assuming it must be public
well there you go
What exactly does that mean? Why would that be causing the database to attempt to connect constantly?
idle timeout
either way, your app is connecting to something publicly, that would prevent it from sleeping
Okay, I'll definitely do more research on my own to understand the difference between connecting to a database publicly vs privately. I was just taught to use the standard 'MONGO_URL' in railway and haven't had any issues till now, so I have never looked into the private connection string. The private one should still function similarly as far as requests go?
Thanks for the help btw!
you would also not pay any database <--> service egress when using the private network
Database:
Server:
After switching to private networking, outbound traffic has dropped to 0 on both the database and server, but there is still some incoming traffic. Any idea why this is still happening?
no idea but incoming traffic doesnt matter
doesn't incoming traffic wake an app from sleep?? so it would also cause it to not really stay asleep for long?
you have a point
or is it only http requests that wake it?
im sure you can wake it other ways too
this is also on the app sleeping page, so I guess it won't even work with private networking
which makes me wonder how people use it with public networking??
thats worded really badly
it should read "Private Networking does not current have support for waking other services when calling the private domain, the public networking domain must be used to wake the service"
Ohhh I see
aka not applicable to you at all
its just when you want to wake service b from service a, you would need to call service b's public domain since it can't be woken from calling its private domain
Okay that makes sense
Thanks for all of your help! I'm glad the outbound traffic is down to 0 now, but I'm going to keep trying to figure out where this inbound traffic is coming from so hopefully I can get it down to 0 when nothing is in use and utilize app sleeping
Please let me know if you have any direction as to what I should be looking into for this bc I'm still a little stumped, hopefully google will help lol
the service in your screenshot, wouldn't it only cost 50 cents a month?
it's the memory that's been driving the cost up for me, so that's why i want to utilize app sleeping
i have a few projects i want to utilize app sleeping on bc the memory costs add up between them
fair enough
The database still has these logs coming in even though I'm not actively doing anything
This must be the incoming traffic still right?
you can probably expand those logs
I think mongo uses structured logging
I'm looking at mongodb docs right now trying to figure it out
this one just came through too
that's a local ipv4 address meaning it's a connection from the public network
but what your database is doing wouldn't prevent the app from sleeping
Is it possible for that to still get through if i'm using private networking now??
i dont think you have went and disabled the public network on the database, so yes
Ohhh I thought I just had to switch the connection string I was using
thats just how your app is connecting to the database
ohhh
i disabled public networking ont he database and I haven't received anymore logs but it's still showing inbound traffic hmmm
could it somehow be flowing to the database from the inbound traffic showing on the server too??
could it somehow be flowing to the database from the inbound traffic showing on the server too??this question doesnt make much sense tbh, so im not sure how to answer it
I also removed the public domain from the server just to see if the inbound traffic would stop, but it's still happening on both server and database
that doesn’t necessarily cut off acesss
Sorry for wording it poorly lol, I just meant like since there is inbound traffic on the server, which connects to the database, could that traffic on the server flow through to the database network usage too??
hmmm, yeah I'm a little lost on what to look at from here lol
me too
I wonder if more people will start having this issue as app sleeping becomes more popular
My apps are pretty basic so I'm just struggling to understand how anybody gets app sleeping to work if even on basic apps like mine there is constant inbound traffic
but like i said, theres really not much railway can do here, unless they decide to give the users a manual sleep and wake button
Yeahhh, does railway not have more insightful data that would show where my network usage is coming from at least??
they would have every kind of log imaginable, but thats not something they can just expose to the end user
Just wondering, but what about using a cron task to remove the deployment during hours not used? Maybe it’s not dynamic like app sleeping, but if you know you’re not frequently using a service, you could schedule it to be awake for certain hours in the day?
Yeah I have some backup options, but I was just really wanting to try to figure this out because it would be a nice feature to take advantage of, but I might have to move on and just remove deployments instead
😦
Thanks for the help guys!!
sure ^_^ have you found the reason? did you solve it?
Nooo, I still can't figure out where the inbound traffic is coming from so my apps won't go to sleep and stay asleep 😦
Oh that's so bad
quite off topic
Oh let me delete it
i would like to hear more about that though, please open a help thread, maybe with more information we could pinpoint a problem!
sure ^_^ I'll create a new thread tomorrow and let you know