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
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
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
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 😥
a year ago
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
a year ago
it doesnt have to be http requests, could be anything like next telemetry reporting, port lookups, icmp, ntp, etc
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?
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
a year ago
the public or private connection string?
a year ago
well there you go
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
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?
a year ago
you would also not pay any database <--> service egress when using the private network
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
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
a year ago
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
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"
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
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
a year ago
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
a year ago
fair enough
The database still has these logs coming in even though I'm not actively doing anything
a year ago
you can probably expand those logs
a year ago
I think mongo uses structured logging
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
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
a year ago
thats just how your app is connecting to the database
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??
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
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
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??
a year ago
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
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
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?
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
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 😦
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
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!