App sleeping not working??
caylin
HOBBYOP

2 years ago

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.

91 Replies

caylin
HOBBYOP

2 years ago

cf56f7ac-b7df-4a38-abf6-b3de04633374


macwilko
HOBBY

2 years ago

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.


macwilko
HOBBY

2 years ago

you could try using cloudflare and enabling some of the bot filters. That might reduce some of the hits you get


caylin
HOBBYOP

2 years ago

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


macwilko
HOBBY

2 years ago

Yes it’s pretty common, all my projects get inbound traffic from bots.


macwilko
HOBBY

2 years ago

Do you log the requests? If you do you can see what is happening


caylin
HOBBYOP

2 years ago

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


ab192130
HOBBY

2 years ago

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 😥


brody
EMPLOYEE

2 years ago

there's honestly not much railway nor the community can do for you besides provide the advice that Mac has


caylin
HOBBYOP

2 years ago

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


brody
EMPLOYEE

2 years ago

it doesnt have to be http requests, could be anything like next telemetry reporting, port lookups, icmp, ntp, etc


caylin
HOBBYOP

2 years ago

Is there a good way to see exactly what it is if it's not http requests??


caylin
HOBBYOP

2 years ago

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??


brody
EMPLOYEE

2 years ago

do you connect to mongo over the public network?


caylin
HOBBYOP

2 years ago

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:

```const mongoose = require('mongoose');
mongoose.set('strictQuery', false);

const mongoDB = process.env.MONGODBURI || process.env.devdb_url;

main().catch((err) => console.log(err));
async function main() {
await mongoose.connect(mongoDB);
}```


brody
EMPLOYEE

2 years ago

what is MONGODB_URI set to


caylin
HOBBYOP

2 years ago

It's set to the connection string for the database in railway


caylin
HOBBYOP

2 years ago

mongoDB is part of the project in railway i'm not using it externally


brody
EMPLOYEE

2 years ago

the public or private connection string?


caylin
HOBBYOP

2 years ago

it's not the private one so i'm assuming it must be public


brody
EMPLOYEE

2 years ago

well there you go


caylin
HOBBYOP

2 years ago

What exactly does that mean? Why would that be causing the database to attempt to connect constantly?


brody
EMPLOYEE

2 years ago

idle timeout


brody
EMPLOYEE

2 years ago

either way, your app is connecting to something publicly, that would prevent it from sleeping


caylin
HOBBYOP

2 years ago

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?


caylin
HOBBYOP

2 years ago

Thanks for the help btw!


brody
EMPLOYEE

2 years ago

you would also not pay any database <--> service egress when using the private network


caylin
HOBBYOP

2 years ago

Database:


caylin
HOBBYOP

2 years ago

Server:


caylin
HOBBYOP

2 years ago

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?


brody
EMPLOYEE

2 years ago

no idea but incoming traffic doesnt matter


brody
EMPLOYEE

2 years ago


caylin
HOBBYOP

2 years ago

doesn't incoming traffic wake an app from sleep?? so it would also cause it to not really stay asleep for long?


brody
EMPLOYEE

2 years ago

you have a point


caylin
HOBBYOP

2 years ago

or is it only http requests that wake it?


brody
EMPLOYEE

2 years ago

im sure you can wake it other ways too


caylin
HOBBYOP

2 years ago

this is also on the app sleeping page, so I guess it won't even work with private networking


caylin
HOBBYOP

2 years ago

which makes me wonder how people use it with public networking??


brody
EMPLOYEE

2 years ago

thats worded really badly


brody
EMPLOYEE

2 years ago

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"


caylin
HOBBYOP

2 years ago

Ohhh I see


brody
EMPLOYEE

2 years ago

aka not applicable to you at all


brody
EMPLOYEE

2 years ago

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


caylin
HOBBYOP

2 years ago

Okay that makes sense


caylin
HOBBYOP

2 years ago

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


caylin
HOBBYOP

2 years ago

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


brody
EMPLOYEE

2 years ago

the service in your screenshot, wouldn't it only cost 50 cents a month?


caylin
HOBBYOP

2 years ago

it's the memory that's been driving the cost up for me, so that's why i want to utilize app sleeping


caylin
HOBBYOP

2 years ago

i have a few projects i want to utilize app sleeping on bc the memory costs add up between them


brody
EMPLOYEE

2 years ago

fair enough


caylin
HOBBYOP

2 years ago


caylin
HOBBYOP

2 years ago

The database still has these logs coming in even though I'm not actively doing anything


caylin
HOBBYOP

2 years ago

This must be the incoming traffic still right?


brody
EMPLOYEE

2 years ago

you can probably expand those logs


brody
EMPLOYEE

2 years ago

I think mongo uses structured logging


caylin
HOBBYOP

2 years ago


caylin
HOBBYOP

2 years ago

I'm looking at mongodb docs right now trying to figure it out


caylin
HOBBYOP

2 years ago


caylin
HOBBYOP

2 years ago

this one just came through too


brody
EMPLOYEE

2 years ago

that's a local ipv4 address meaning it's a connection from the public network


brody
EMPLOYEE

2 years ago

but what your database is doing wouldn't prevent the app from sleeping


caylin
HOBBYOP

2 years ago

Is it possible for that to still get through if i'm using private networking now??


brody
EMPLOYEE

2 years ago

i dont think you have went and disabled the public network on the database, so yes


caylin
HOBBYOP

2 years ago

Ohhh I thought I just had to switch the connection string I was using


brody
EMPLOYEE

2 years ago

thats just how your app is connecting to the database


caylin
HOBBYOP

2 years ago

ohhh


caylin
HOBBYOP

2 years ago

i disabled public networking ont he database and I haven't received anymore logs but it's still showing inbound traffic hmmm


caylin
HOBBYOP

2 years ago

could it somehow be flowing to the database from the inbound traffic showing on the server too??


brody
EMPLOYEE

2 years ago

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


caylin
HOBBYOP

2 years ago

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


brody
EMPLOYEE

2 years ago

that doesn’t necessarily cut off acesss


caylin
HOBBYOP

2 years ago

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??


caylin
HOBBYOP

2 years ago

hmmm, yeah I'm a little lost on what to look at from here lol


brody
EMPLOYEE

2 years ago

me too


caylin
HOBBYOP

2 years ago

I wonder if more people will start having this issue as app sleeping becomes more popular


caylin
HOBBYOP

2 years ago

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


brody
EMPLOYEE

2 years ago

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


caylin
HOBBYOP

2 years ago

Yeahhh, does railway not have more insightful data that would show where my network usage is coming from at least??


brody
EMPLOYEE

2 years ago

they would have every kind of log imaginable, but thats not something they can just expose to the end user


macwilko
HOBBY

2 years ago

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?


caylin
HOBBYOP

2 years ago

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


caylin
HOBBYOP

2 years ago

😦


caylin
HOBBYOP

2 years ago

Thanks for the help guys!!


ab192130
HOBBY

2 years ago

sure ^_^ have you found the reason? did you solve it?


caylin
HOBBYOP

2 years ago

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 😦


ab192130
HOBBY

2 years ago

Oh that's so bad


ab192130
HOBBY

2 years ago

My client that consumes our API said that responses are way more slower. Don't know why.

Heroku has 1gb RAM. But with 8gb RAM and 8 vCPU railway is slower. Interesting 🤔


brody
EMPLOYEE

2 years ago

quite off topic


ab192130
HOBBY

2 years ago

Oh let me delete it


brody
EMPLOYEE

2 years ago

i would like to hear more about that though, please open a help thread, maybe with more information we could pinpoint a problem!


ab192130
HOBBY

2 years ago

sure ^_^ I'll create a new thread tomorrow and let you know


Loading...