Responsiveness for discord bot
ccmdi
FREEOP

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

51 Replies

dev
MODERATOR

a year ago

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


dev
MODERATOR

a year ago

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


ccmdi
FREEOP

a year ago

yep, Postgres


dev
MODERATOR

a year ago

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


ccmdi
FREEOP

a year ago

that would just be DATABASE_URL?


dev
MODERATOR

a year ago

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


ccmdi
FREEOP

a year ago

right, i've been using that one


dev
MODERATOR

a year ago

awesome, and the region?


ccmdi
FREEOP

a year ago

project and db are US West


dev
MODERATOR

a year ago

on the exact same area in US-west?


ccmdi
FREEOP

a year ago

yea


dev
MODERATOR

a year ago

they're both US West Oregon ?


dev
MODERATOR

a year ago

<:sus_apple:1032821016319234068>


ccmdi
FREEOP

a year ago

yep


dev
MODERATOR

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


dev
MODERATOR

a year ago

this is one of my bot's running on Railway

1326714446055346200


ccmdi
FREEOP

a year ago

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


ccmdi
FREEOP

a year ago

can try some logging though ^


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
FREEOP

a year ago

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


ohhhh


what library are you using?


ccmdi
FREEOP

a year ago

discordpy


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


dev
MODERATOR

a year ago

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


good question


ccmdi
FREEOP

a year ago

seems its just the memory-intensive commands



ccmdi
FREEOP

a year ago

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



just how great is your pc lmao


ccmdi
FREEOP

a year ago

not too great lol


yeah…. ok


ccmdi
FREEOP

a year ago

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


agreed


dev
MODERATOR

a year ago

what do these memory intensive commands do?


ccmdi
FREEOP

a year ago

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


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


ccmdi
FREEOP

a year ago

probably a bug on my part



so it did not work fully on your pc


ccmdi
FREEOP

a year ago

i didnt do the postgres branch on my local



ccmdi
FREEOP

a year ago

ill compare on my local now


ccmdi
FREEOP

a year ago

seems like a consistent 2-4s


ccmdi
FREEOP

a year ago

so at least partially my fault lol


hmmm


is the extra time just network request times?


ccmdi
FREEOP

a year ago

that would be my guess


ccmdi
FREEOP

a year ago

might just try some sqlite stuff



Loading...