App sleeping not working??

caylin
HOBBY

a year 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.

0 Replies

caylin
HOBBY

a year ago

cf56f7ac-b7df-4a38-abf6-b3de04633374


a year 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.


a year ago

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


caylin
HOBBY

a year 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


a year ago

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


a year ago

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


caylin
HOBBY

a year 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

a year 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 😥


a year ago

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


caylin
HOBBY

a year 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


a year ago

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


caylin
HOBBY

a year ago

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


caylin
HOBBY

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


a year ago

do you connect to mongo over the public network?


caylin
HOBBY

a year 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);
}```


a year ago

what is MONGODB_URI set to


caylin
HOBBY

a year ago

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


caylin
HOBBY

a year ago

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


a year ago

the public or private connection string?


caylin
HOBBY

a year ago

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


a year ago

well there you go


caylin
HOBBY

a year ago

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


a year ago

idle timeout


a year ago

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


caylin
HOBBY

a year 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
HOBBY

a year ago

Thanks for the help btw!


a year ago

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


caylin
HOBBY

a year ago

Database:


caylin
HOBBY

a year ago

Server:


caylin
HOBBY

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


a year ago

no idea but incoming traffic doesnt matter


a year ago


caylin
HOBBY

a year ago

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


a year ago

you have a point


caylin
HOBBY

a year ago

or is it only http requests that wake it?


a year ago

im sure you can wake it other ways too


caylin
HOBBY

a year ago

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


caylin
HOBBY

a year ago

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


a year ago

thats worded really badly


a year 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
HOBBY

a year ago

Ohhh I see


a year ago

aka not applicable to you at all


a year 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
HOBBY

a year ago

Okay that makes sense


caylin
HOBBY

a year 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
HOBBY

a year 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


a year ago

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


caylin
HOBBY

a year 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
HOBBY

a year ago

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


a year ago

fair enough


caylin
HOBBY

a year ago


caylin
HOBBY

a year ago

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


caylin
HOBBY

a year ago

This must be the incoming traffic still right?


a year ago

you can probably expand those logs


a year ago

I think mongo uses structured logging


caylin
HOBBY

a year ago


caylin
HOBBY

a year ago

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


caylin
HOBBY

a year ago


caylin
HOBBY

a year ago

this one just came through too


a year ago

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


a year ago

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


caylin
HOBBY

a year ago

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


a year ago

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


caylin
HOBBY

a year ago

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


a year ago

thats just how your app is connecting to the database


caylin
HOBBY

a year ago

ohhh


caylin
HOBBY

a year ago

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


caylin
HOBBY

a year ago

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


a year 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
HOBBY

a year 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


a year ago

that doesn’t necessarily cut off acesss


caylin
HOBBY

a year 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
HOBBY

a year ago

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


a year ago

me too


caylin
HOBBY

a year ago

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


caylin
HOBBY

a year 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


a year 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
HOBBY

a year ago

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


a year ago

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


a year 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
HOBBY

a year 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
HOBBY

a year ago

😦


caylin
HOBBY

a year ago

Thanks for the help guys!!


ab192130
HOBBY

a year ago

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


caylin
HOBBY

a year 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

a year ago

Oh that's so bad


ab192130
HOBBY

a year 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 🤔


a year ago

quite off topic


ab192130
HOBBY

a year ago

Oh let me delete it


a year 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

a year ago

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