stefanchrobot

stefanchrobot

I’ve been looking at my application in terms of resource usage. It’s a simple SQS consumer that calls some APIs and is under a very small load. BEAM constantly reports usage of around 70MB of memory:

I’m not sure what to think about it. Honestly, I expected a smaller footprint. I’m running with the default settings and simple MIX_ENV=prod mix run.

Is there an easy way to shave off some memory? Also, I’m wondering - why so many atoms are used?

Showing Posts 1 to 5

jeremyjh

jeremyjh

Each module, and every function in every module is an atom. If you are loading a few libraries hitting 22K isn’t too hard. I’m not sure what to think of the memory. Its not so bad compared to other high-level language VMs though is it? I’m sure Go or Rust would be a lot smaller but a better comparison is Ruby, Python or Java.

sribe

sribe

I seem to recall a minimal web/proxy thing I wrote taking about 24MB used… There is an awful lot of runtime data available in the BEAM. You can easily find out what processes have the largest heaps etc. I’ve used the base Erlang system info calls, but I bet somebody here can guide you to easier-to-use tools that will allow you to drill down and find out where the big uses are.

jeramyRR

jeramyRR

70 MBs seems a bit high for a small app. What all libs are you loading?

The image below shows a basic Phoenix app.

stefanchrobot

stefanchrobot OP

:+1: makes sense!

Here’s my app:

$ mix deps.tree
app
├── statix ~> 1.1 (Hex package)
├── gen_stage ~> 0.14.0 (Hex package)
├── jason ~> 1.1 (Hex package)
├── poison ~> 4.0 (Hex package)
├── junit_formatter ~> 3.0 (Hex package)
├── dialyxir ~> 0.4 (Hex package)
├── hackney ~> 1.9 (Hex package)
│   ├── certifi 2.5.1 (Hex package)
│   │   └── parse_trans ~>3.3 (Hex package)
│   ├── idna 6.0.0 (Hex package)
│   │   └── unicode_util_compat 0.4.1 (Hex package)
│   ├── metrics 1.0.1 (Hex package)
│   ├── mimerl ~>1.1 (Hex package)
│   └── ssl_verify_fun 1.1.4 (Hex package)
├── sweet_xml ~> 0.6 (Hex package)
├── ex_aws ~> 2.0 (Hex package)
│   ├── hackney 1.6.3 or 1.6.5 or 1.7.1 or 1.8.6 or ~> 1.9 (Hex package)
│   ├── poison >= 1.2.0 (Hex package)
│   └── sweet_xml ~> 0.6 (Hex package)
├── ex_aws_sqs ~> 2.0 (Hex package)
│   └── ex_aws ~> 2.0.0 (Hex package)
├── credo ~> 1.0 (Hex package)
│   ├── bunt ~> 0.2.0 (Hex package)
│   └── jason ~> 1.0 (Hex package)
└── tesla ~> 1.2.1 (Hex package)
    ├── hackney ~> 1.6 (Hex package)
    ├── jason >= 1.0.0 (Hex package)
    ├── mime ~> 1.0 (Hex package)
    └── poison >= 1.0.0 (Hex package)

credo, dialyxir and junit_formatter are :dev or :test only.

Would the size of the loaded code change if I built a release instead of running plain mix run?

jola

jola

If you do try building a release, I’m curious to see what the memory usage turns out to be. I made a quick comparison in a project of my own and also just a plain new phoenix project, in both cases memory use was much higher in the release. Why do releases use so much more memory than `mix run`? - #2 by michalmuskala

As I point out though, my comparison may be unfair, as not all code is necessarily loaded in the mix version when I checked memory use, while releases preload all modules. But you should be able to get an accurate comparison.

— All posts loaded —

Where Next? Top

Trending in Questions Top

water
I’m aware of 2 such projects, are there others? git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
bradley
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
Alvinkariuki
How Can I Optimise Compile Time Dependencies I have been building an elixir application for about 2 years now. Many modules and files ha...
New

Other Trending Topics Top

budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews