Increased Memory Usage in V2
faeyumbrea
PROOP

2 years ago

It appears as though the V2 runtime is causing an increase in memory usage for my project. I am unsure if this is due to it being a .net project, or if it is something V2 will generally struggle with.

Reference Points from the image are the newest 2 deploys. The first being on V2, and the second on legacy. The spikes in both are due to roll-over issues where the previous deployment didn't exit yet and should be ignored.

Most pressing I think is the almost 100MB difference in initial memory consumption, which is very odd considering this app always has the same initial allocation.

In a previous deployment that I since removed, I also saw the single-instance memory usage grow significantly higher than 200MB, which is the hard limit I set the app to with DOTNET_GCHeapHardLimit.

Solved

111 Replies

faeyumbrea
PROOP

2 years ago

fd3c34f8-2314-4d8d-8f79-2ed37386c50d


faeyumbrea
PROOP

2 years ago

I have also tested this locally using docker. The initial heap size should be around 100MB, not teetering near 200MB


2 years ago

So for clarity the more left side of the graph is the v2 runtime and the right portion of the graph is the legacy runtime?


faeyumbrea
PROOP

2 years ago

Correct


2 years ago

are you building with a dockerfile?


faeyumbrea
PROOP

2 years ago

yes


2 years ago

are you running it locally with docker or podman?


faeyumbrea
PROOP

2 years ago

dotnet 8 deployment with nixpacks currently does not work because the nixpkgs reference is too old


faeyumbrea
PROOP

2 years ago

I am running locally with Rancher Desktop, which uses moby as the runtime


2 years ago

legacy is docker and V2 is podman


2 years ago

so there definitely could be some discrepancies there, but if so, it could be out of railways control


faeyumbrea
PROOP

2 years ago

I see


2 years ago

I'll see if I can reproduce, and either way I'll bring this up to the team


faeyumbrea
PROOP

2 years ago

Deploying .net applications is a bit iffy anyway, I have to be able to rely on setting the GC heap limits or the app will grow to the container limit


faeyumbrea
PROOP

2 years ago

which on railway is 8GB


2 years ago

yeah same issue with Java apps too


faeyumbrea
PROOP

2 years ago

asp.net uses a GC that pefers allocating ram over doing GC and its currently very stubborn about it


faeyumbrea
PROOP

2 years ago

being able to set limits on container size would be a great feature


2 years ago

can you use a different GC or am I thinking of a different language?


faeyumbrea
PROOP

2 years ago

I have tried setting it to workstation gc and using the new DATAS dynamic gc


faeyumbrea
PROOP

2 years ago

but it seems to not make much of a difference


faeyumbrea
PROOP

2 years ago

this might be a bug i the docker base image though, I saw a few reports indicating this


2 years ago

what's the image based on? I've heard of people having better memory usage just by switching to an alpine image, but that was node so probably not applicable but maybe worth trying?


faeyumbrea
PROOP

2 years ago

I could try that, the regular dotnet images are all bullseye iirc


2 years ago

couldn't hurt, I've seen stranger things be a solution


2 years ago

I'll still be trying to reproduce and will report to the team


faeyumbrea
PROOP

2 years ago

ah, its bookworm, not bullseye, but still debian


2 years ago

haha same difference


2 years ago

legacy and v2 runtime both report the same mem, 499MB on legacy and 496MB on v2

1250947853736738800


faeyumbrea
PROOP

2 years ago

interesting, this definitely warrants more testing then


faeyumbrea
PROOP

2 years ago

oh speaking of nixpacks, not to hijack the issue but it still installs the preview version of dotnet 8.0 when using the c# provider


2 years ago

yeah that provider along with nixpacks in general needs some love


faeyumbrea
PROOP

2 years ago

while I don't mind writing dockerfiles (my day job is as a cloud consultant) nixpacks is one of my favorite features of railway


2 years ago

nixpacks is nice when it works the way you want it to, but it doesn't create the best dockerfiles or the smallest final images, so I've never used it for any of my projects


faeyumbrea
PROOP

2 years ago

that is true


faeyumbrea
PROOP

2 years ago

the dotnet file I am using is utilizing the two-stage-build pattern, so the output docker container is as small as can be


2 years ago

you can do something similar with nixpacks using the final image directive but it's still a pain compared to writing a Dockerfile to do it


faeyumbrea
PROOP

2 years ago

true, but for small hacked together weekend projects it is very nice to be able to just deploy them


2 years ago

I agree, hopefully one of these quarters they will set aside some time to nail down some of the outdated providers and the flaws with nixpacks


faeyumbrea
PROOP

2 years ago

It would be nice if the nixpkgs ref would get more regular updates. The current snapshot is from september :X



2 years ago

it's quite scary when they update that, we get a wave of build failed help threads


2 years ago

the repo has a bunch of test apps, but it's not enough


faeyumbrea
PROOP

2 years ago

I am guessing its a lot of apps that don't specify their target sdk version anywhere?


2 years ago

stuff like that, or I think last time I meant that nixpacks inadvertently dropped support for php 8.0


faeyumbrea
PROOP

2 years ago

Especially node, version pinning isn't exactly common practise there


2 years ago

I can testify to that


faeyumbrea
PROOP

2 years ago

dotnet has its global.json that is generated by the cli


faeyumbrea
PROOP

2 years ago

oh my, yeah php versions disappearing is not good


faeyumbrea
PROOP

2 years ago

for an interpreter this widely used they really love breaking changes


2 years ago

that one was because php 8.0 just wasn't a package in the archive version it was updated to


faeyumbrea
PROOP

2 years ago

I have quite a few stories from my previous job with a managed hosting company that do e-learning


faeyumbrea
PROOP

2 years ago

most e-learning software is really old, so its all written in php


2 years ago

anyone who wants older versions of php either use a Dockerfile or pin nixpacks to a really old version


faeyumbrea
PROOP

2 years ago

Adventures like "no, we can't update to Ubuntu 18.04 because [software] needs [old php version]" 2 months before the EOL of 18.04


2 years ago

the fun world of software development and backend maintenance


faeyumbrea
PROOP

2 years ago

its kinda awful hahaha


2 years ago

that's why I have only done personal projects haha


faeyumbrea
PROOP

2 years ago

it would have been fine if my ex-employer didn't also think docker was the plague


faeyumbrea
PROOP

2 years ago

everything had to be full vm boxes


2 years ago

sounds costly


faeyumbrea
PROOP

2 years ago

it really was


faeyumbrea
PROOP

2 years ago

just before I left they were starting to pivot to private-clouds using openstack


2 years ago

if only they knew about railway


faeyumbrea
PROOP

2 years ago

I heard some rumors that they are now migrating a lot of things to an HA K8S cluster


faeyumbrea
PROOP

2 years ago

IF ONLY!


faeyumbrea
PROOP

2 years ago

I did a redeploy with alpine under both legacy and v2 again


faeyumbrea
PROOP

2 years ago

1250955496165478400


faeyumbrea
PROOP

2 years ago

still seeing about 30MB in difference


faeyumbrea
PROOP

2 years ago

it's not as bad as the 90 I was getting before though


faeyumbrea
PROOP

2 years ago

oddly, in docker, the alpine image made almost no difference at all


faeyumbrea
PROOP

2 years ago

makes me think this could be a runtime oddity


faeyumbrea
PROOP

2 years ago

I'll keep an eye on the memory for a few hours and see if it obeys the GC limit I set now


2 years ago

sounds good, I've sent this thread in a thread I have with the team thats for the v2 dents


faeyumbrea
PROOP

2 years ago

fingers crossed, but I think you might be right with this being a podman issue


2 years ago

it might be


2 years ago

I've seen a user report increased network usage on the v2 runtime, but I also couldn't reproduce that


2 years ago

or maybe the v2 runtime now counts shm space as memory


faeyumbrea
PROOP

2 years ago

it could be, yeah


faeyumbrea
PROOP

2 years ago

if the ram reporting is done using the runtime's monitoring functions, the reported values could differ depending on implementation too


2 years ago

indeed


2 years ago

shm space is not counted as memory


faeyumbrea
PROOP

2 years ago

At least the deployment is now behaving on alpine


faeyumbrea
PROOP

2 years ago

The ram even went down! So gc is 100% running


2 years ago

gotta love alpine


faeyumbrea
PROOP

2 years ago

happy to report that the container's ram usage appears to be what it should be now


faeyumbrea
PROOP

2 years ago

although the metrics reporter seems to not quiiiite work yet


2 years ago

metrics reporter?


faeyumbrea
PROOP

2 years ago

the deployment is definitely there


faeyumbrea
PROOP

2 years ago

1251385149493477400


faeyumbrea
PROOP

2 years ago

but the last timestamp is from 4 hours ago


faeyumbrea
PROOP

2 years ago

on the 1d metric


faeyumbrea
PROOP

2 years ago

and the 1h metric does not exist


faeyumbrea
PROOP

2 years ago

this is on V2


faeyumbrea
PROOP

2 years ago

considering the deployment exists, this seems more like a UI issue than a backend issue though


2 years ago

what time is where you are?


faeyumbrea
PROOP

2 years ago

6am


faeyumbrea
PROOP

2 years ago

Someone should take a look at how my app can be running with no 1h metric available though


faeyumbrea
PROOP

2 years ago

The deployment is a few hours old at this point


2 years ago

your CEST right? can you send a link to your service?


faeyumbrea
PROOP

2 years ago

Yea


faeyumbrea
PROOP

2 years ago

It is still unfinished so it’s running at (removed)


2 years ago

i meant like



2 years ago

!t


2 years ago

This thread has been escalated to the Railway team.

Status changed to Awaiting Railway Response brody over 1 year ago


2 years ago

can you login in there for good measure?


faeyumbrea
PROOP

2 years ago

I have logged in


2 years ago

perfect!


2 years ago

Sorry trying to read through this but unsure exactly where you all landed. Is the issue that in the environment labeled V2, services deployed using the V2 runtime, metrics graphs indicate increased usage? (Similar to the other one we're looking into @ Brody?)


2 years ago

if I understand correctly, memory is fine now, but the graphs have the date scale wrong


Status changed to Solved Railway over 1 year ago


Railway
BOT

2 years ago

This thread has been marked as solved automatically due to a lack of recent activity. Please open a new thread if you require further assistance. Thank you!


Loading...