Skip to content
Responsiveness for discord bot
ccmdi
OP

2 years ago

hi, im developing a Discord bot and wanted to host it, so I decided on Railway. running it on local works great (at most a second delay) from receiving commands to execution. the bot requires some memory-intensive processing so I upgraded to hobby plan to get 8GB, but currently im experiencing serious delay when it runs on Railway — up to 10 seconds on maxed out specs, though i think its bandwidth related. its an important feature for the bot to respond relatively quickly. is there anything that can be done to reduce latency from user commands?

eb591fbe-8984-470f-9f2c-c9fca1d535b5

Closed

51 Replies

2 years ago

I've been running bots on Railway for 2 years and I've never had any issues with latency


2 years ago

Do you have a database on Railway that your bot is using?


ccmdi
OP

2 years ago

yep, Postgres


2 years ago

Can you make sure they're on the same region and that you're connecting to postgres through the private network?


ccmdi
OP

2 years ago

that would just be DATABASE_URL?


2 years ago

exactly, to be sure you can check if it uses a railway.internal domain


ccmdi
OP

2 years ago

right, i've been using that one


2 years ago

awesome, and the region?


ccmdi
OP

2 years ago

project and db are US West


2 years ago

on the exact same area in US-west?


ccmdi
OP

2 years ago

yea


2 years ago

they're both US West Oregon ?


2 years ago

<:sus_apple:1032821016319234068>


ccmdi
OP

2 years ago

yep


2 years ago

Alright, then your service's connection to the database is as fast as can be (low single digit ms range)

beyond optimizing that connection, there isn't anything else you can do to speed up things on Railway's side, the rest is your app

My suggestion would be to place more metrics in-app so you can figure out what exactly is slowing your app down, and you can work from there


2 years ago

this is one of my bot's running on Railway

1326714446055346187


ccmdi
OP

2 years ago

i had to migrate from SQLite to Postgres, besides that and the hardware I would expect them to behave the exact same


ccmdi
OP

2 years ago

can try some logging though ^


2 years ago

im kinda confused from reading, are you running part of the bot on your pc, or you are saying there is a 10 second delay from discord command to bot processing it on railway?


ccmdi
OP

2 years ago

10 second delay is only on railway, if i host it locally latency is minimal


2 years ago

ohhhh


2 years ago

what library are you using?


ccmdi
OP

2 years ago

discordpy


2 years ago

hmm, I was wondering if it was time server stuff, but prob not an issue in discordpy


2 years ago

do you get that delay on all commands? even a simple ping command?


2 years ago

good question


ccmdi
OP

2 years ago

seems its just the memory-intensive commands


2 years ago

hmm


ccmdi
OP

2 years ago

though it doesnt respond to some other ones <:clueless:1167482383084290078>


2 years ago

huh


2 years ago

just how great is your pc lmao


ccmdi
OP

2 years ago

not too great lol


2 years ago

yeah.... ok


ccmdi
OP

2 years ago

only 32gb vs 8gb but not making the difference in this case


2 years ago

agreed


2 years ago

what do these memory intensive commands do?


ccmdi
OP

2 years ago

make a bunch of web requests, stitch tiles together and render an image, do a projection and send it to the channel


2 years ago

im interested also in that some commands do not get a response


ccmdi
OP

2 years ago

probably a bug on my part


2 years ago

oh.


2 years ago

so it did not work fully on your pc


ccmdi
OP

2 years ago

i didnt do the postgres branch on my local


2 years ago

ah


ccmdi
OP

2 years ago

ill compare on my local now


ccmdi
OP

2 years ago

seems like a consistent 2-4s


ccmdi
OP

2 years ago

so at least partially my fault lol


2 years ago

hmmm


2 years ago

is the extra time just network request times?


ccmdi
OP

2 years ago

that would be my guess


ccmdi
OP

2 years ago

might just try some sqlite stuff


2 years ago

hmm


Welcome!

Sign in to your Railway account to join the conversation.

Loading...