Responsiveness for discord bot
ccmdi
FREEOP

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
FREEOP

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
FREEOP

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
FREEOP

2 years ago

right, i've been using that one


2 years ago

awesome, and the region?


ccmdi
FREEOP

2 years ago

project and db are US West


2 years ago

on the exact same area in US-west?


ccmdi
FREEOP

2 years ago

yea


2 years ago

they're both US West Oregon ?


2 years ago

<:sus_apple:1032821016319234068>


ccmdi
FREEOP

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
FREEOP

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
FREEOP

2 years 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

2 years ago

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


ohhhh


what library are you using?


ccmdi
FREEOP

2 years ago

discordpy


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?


good question


ccmdi
FREEOP

2 years ago

seems its just the memory-intensive commands


hmm


ccmdi
FREEOP

2 years ago

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


huh


just how great is your pc lmao


ccmdi
FREEOP

2 years ago

not too great lol


yeah.... ok


ccmdi
FREEOP

2 years ago

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


agreed


2 years ago

what do these memory intensive commands do?


ccmdi
FREEOP

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


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


ccmdi
FREEOP

2 years ago

probably a bug on my part


oh.


so it did not work fully on your pc


ccmdi
FREEOP

2 years ago

i didnt do the postgres branch on my local



ccmdi
FREEOP

2 years ago

ill compare on my local now


ccmdi
FREEOP

2 years ago

seems like a consistent 2-4s


ccmdi
FREEOP

2 years ago

so at least partially my fault lol


hmmm


is the extra time just network request times?


ccmdi
FREEOP

2 years ago

that would be my guess


ccmdi
FREEOP

2 years ago

might just try some sqlite stuff


hmm


Welcome!

Sign in to your Railway account to join the conversation.

Loading...