R
Railway

✋|help

access to resource inside replica

Qquan9/11/2023
hi,

when we setup an instance to have 2 replicas, how do we get the resource related to 1 of the rep, hm I can't find the info from the docs though

for a simple scenario, we have a /get-users to returns a list of in-memory users array in one instance, and /add-user to add an entry to the array

so hitting the add endpoint one time, and get just returns the values of one random replica, either an empty array, or array of 1 val added previously
IImLunaHey9/11/2023
You’ll want to use a database if you’re running multiple replicas of a service.
BBrody9/11/2023
that's 2 for 2 on the use a database solution
IImLunaHey9/11/2023
If you’re expecting to be able to hit a certain replica you’re misunderstanding what replicas are.
Qquan9/11/2023
ok,

yea we are using sse, we store the response obj from client for sending the event-stream over

I can't find the info yet but I think we can't save that into a db...

but thanks for the info though
IImLunaHey9/11/2023
Why not? 🤔
Sounds like a good use case for redis.
BBrody9/11/2023
I also think it's worth asking, are you sure you need any replicas?
IImLunaHey9/11/2023
Redis pubsub with channels based on the users connection ID would likely be fine for this.
Qquan9/11/2023
yea, i can't run any benchmark right now, but I just need to have a rep ready for there are many connections,

we used short polling previously and on peak we had 5-6k ppl concurrently
BBrody9/11/2023
are you a part of a railway team?
IImLunaHey9/11/2023
Even with that amount why do you think you need a replica? I’ve had multiple projects with 50k clients on a single instance.
Replicas are for scaling load. If your single service can keep up with the load a replica isn’t gonna really do much but add complexity.
Qquan9/11/2023
oh, is it on a normal 8gb ram instance for 50k clients,

I can hop to a team but was just using the hobby plan initially
i meant i can turn to the team eventually
IImLunaHey9/11/2023
Depends on the load. In the case of the 50k clients we were using a 1GB digital ocean box.

People way too often see a big number and instantly think they need to scale without actually seeing if they’re hitting any kind of limit.
If you’re doing this all in memory and move to using a database you may find you don’t need the replica after all since the memory footprint could very likely drop down to almost nothing.
Qquan9/11/2023
i see, thanks for info. let me try the benchmark for now

ah i think the res we store in memory is a stream object, i remember we were having issue serialize the object on db query, to use that obj to stream the info back from nodejs => client for server sent event

really appreciate
IImLunaHey9/11/2023
What’re you sending to the client that’s a stream?
If it’s a file then that’s not memory intensive. If it’s something from another client then look at pub/sub.
Qquan9/11/2023
ah ok
IImLunaHey9/11/2023
just having a client connected uses very few resources, copying a stream to a connection is also really cheap in terms of resources so unless you're doing a bunch of computational work you'll likely see a big decrease in memory usage once this is all moved to a db.
Qquan9/11/2023
ok yea its not having any big computation, we have other servers already doing the math, we just have this server alone to send / notify data back to client when data is published from a redis when a channel / topic matches
IImLunaHey9/11/2023
yeah in that case you shouldnt be needing more than a gig or so of memory if it's all done correctly.

Looking for more? Join the community!

Recommended Posts
Communicate between services with private networkProject ID: 3f51dcb4-6905-4a13-be75-4c6063e4324a I am trying to set up Railway to communicate betweWeb Server Not WorkingI just started a small simple web server. I generated a custom domain for now, and when trying to achttp://0.0.0.0:8000 to urlI am using a Django REST framework. When I query the URL at 0.0.0.0:8000 I can get a response, but aOpenSearch deploymentHi everyone. I require assistance with deploying an instance of OpenSearch since I get an error durUnable to connect with private networkHey guys, I'm a bit unsure on how to use the internal network. I have a .net api that has a privaterclone on railway to transfer data from one cloud to an other.Hello, I'm creating an app the requires to transfer data from one cloud storage (like onedrive to aBun 1.0 on railwayI am spinning up a simple bun app with 1 file in it. But for some reason all of my builds are failinSocket cannot be archivedWhen building the railway project I get a message saying that: /Users/x/Library/Application SupportBUN 1.0 + AstroHas anyone tried to deploy a Bun app yet? I am getting this error. ERROR: failed to solve: processDjango Railway admin consoleHi! I've had a really good time using Railway thus far, sea-change from setting up an EC2 instance Trouble sending emails via SMTPprojectId: `bb66f5c0-53f9-4e9f-b11f-5965f5d6ec74` serviceId: `b3029692-b78a-4487-bcb0-44e001afecb8` Cannot have a TCP proxy and a domainWhen trying to create a service with a proxy, I'm getting this error. Can I not have a TCP proxy serChange region for Postgres DatabaseHey ! Congratulations for the launch of deployment region ! Now, how can I migrate my db to another Connection Pooling or PgBouncer for Postgres Instances?Hello! Anyone know if the Railway Postgres instance has any sort of connection pooling or pgBouncer?webhook to rebuild serviceHi I have one project: Mongo, PayloadCMS + storage, Nextjs I want to trigger nextjs rebuild after aI paid 40 dollars in subscription fees but its still dont pay my debt for credits.deploy prisma/client not foundhey, when I deploy the prisma client in node_modules is not found because its not generating, I haveCan you explain how usage is estimatedI have an account with a hobby plan subscription, I have a discord bot running on it and a MySQL DB Trying to save a fileTrying to save a file in media/ where can i save files ? PermissionError: [Errno 13] Permission dHelp setup a monorepo - Angular / ExpressHi! Hope everyone is doing well :). I am trying to deploy my Angular application on railway, but it