How much Rust need resource for web app

hi.

i saw many benchmark in youtube take from rust
and in result rust memory usage is always under ~20MB
for 13K rps

when i used Erlang we always bought system with
Ram = ( CPU number * 2 ),

in this rust project we use machine with 5 core.
but how many RAM need ??

we just have large json we stored in heap (String type) per request

and another question is , is Rust Stack-overflow safe ??
if our data is medium size we can store freely in Stack ??

This depends on what your application is doing. If you are going to solve a very expensive computation that takes 5 minutes and 10 GB of memory for each request, then you are going to need a lot of memory and compute for even a very small RPS. On the other hand, if you don't do very much per request, the situation is very different.

Also, ram = 2*cpu number doesn't make any sense.

And no, Rust is not safe from stack overflows. And what do you mean by storing it on the stack? Having a local String variable wont store it on the stack, so how do you intend to do it? And what do you mean by medium size?

2 Likes

thanks, yes i know, my means for each request
with params, we decision response with json (like bellow)
and after responsed, it drop from heap,
and our computation dont use any awaiting code to let other task run,
because itself very fast decision and response a json then,
other part of calculation very low size data
like 3 enum,

serde_json::to_string(r#"
                    {
                        "rep": "۱۲-۶",
                        "set": "۳",
                        "intensity": "۶۰−۸۰٪"
                        "rest_interval": "۲-۵ ثانیه",
                        "execution" :  "از شروع حرکت تا تحت فشار قرار گرفتن ماهیچه ۲ ثانیه طول بکشد ـ یک وقفه ـ ۴ ثانیه تا حالت ابتدایی طول بکشد ـ یک وقفه ـ‌تکرار"
                        "explain": "پس از انجام هر ست وزنه را بیشتر و تعداد را کمتر کنید ـ حد فشار باید بین ۶۰−۸۰٪ باشد",

                        "upper": [
                            "shoulder_press.jpg",
                            "bent_over_row.png",
                            "standing_dumbbell_curl.png",
                            "triceps_dip.png",
                            "pushup.gif",
                            "russian_twist.jpg"
                        ],
                        "lower": [
                            "back_squat.png",
                            "leg_press_machine.png",
                            "hack_squat.jpg",
                            "calf_raise_machine.jpg",
                            "hamstring_curl.jpeg",
                            "hyperextension.jpg"
                        ]
                    
                    }"#).unwrap()

The only way to really know how many resources your application will need is to try it out and see.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.