scottmessinger

scottmessinger

We just put it into production (Bandit 1.2.2) and are also seeing increased memory usage (about 50% more). We upgraded several libraries, so I don’t want to definitively say it was from Bandit, but it does seem likely.

Side note: I think it’s incredibly impressive for mtrudel to build the whole thing and have it be drop in compatible. Very cool library. That said, we might switch back to cowboy if we can’t resolve the memory issue.

Showing Posts 1 to 10

jjcarstens

jjcarstens

Nerves Core Team

We put this in NervesHub and were having issues with websockets in our setup at scale which unlimitedly led to reverting to cowboy (Big lengthy breakdown in that PR as well)

However, just today we found one of the default options in ThousandIsland was to set linger: {true, 30} which would hold sockets and increase memory load. That was fixed today in :thousand_island 1.3.3, we deployed and it was all fixed! :tada: It would be worth updating that to see if you still have issues

Also, we set thousand_island: [transport_ports: [hibernate_after: 15_000]] in the endpoint which dropped the memory usage significantly as well.

14
Post #1
hubertlepicki

hubertlepicki

We rolled it back to Cowboy too. I like the idea but the nature of the project is such that we are getting a lot of requests that are being cancelled before they finish, and Bandid did not interrupt these at all. I suspect this was contributing to the increased load on the servers and increased memory usage, but it’s probably also the architecture that relies on OTP. Cowboy uses their own, simplified primitives for concurrency implementation, precisely because they were able to made them more efficient.

mtrudel

mtrudel

Creator of Bandit

Is this serving primarily HTTP or WS?

If WebSockets, as @jjcarstens sez a few replies down, I’d look at adding hibernate_after.

mtrudel

mtrudel

Creator of Bandit

I haven’t forgotten about you @hubertlepicki! I actually thought of a possible quick win for this; are you able to deploy a branch for testing?

scottmessinger

scottmessinger OP

It’s mainly WS but there was an error when I added hibernate_after. It seemed like it wasn’t an allowed option, likely because I didn’t change the default TCP adapter.

mtrudel

mtrudel

Creator of Bandit

Yep, sorry. hibernate_after is specific to :ssl; there’s no equivalent for :gen_tcp.

That’s curious that you’re seeing increased memory usage; Bandit’s WS layer is really quite thin (it’s a small bit of mostly bounded state on top of a GenServer). I wonder if it’s lagging process closes, and if Thousand Island 1.3.3 would help?

dimitarvp

dimitarvp

I am curious if somebody noticed that increased memory usage in an API project without views / templates / components etc.? And without LiveView / WebSockets?

scottmessinger

scottmessinger OP

I upgraded to Thousand Island 1.3.3 based on this thread, but still saw the high memory usage. I just switched back over to Cowboy and should have better comparison numbers tomorrow morning, but it seems like Cowboy is 1/2 the memory usage of Bandit.

Bandit is great and I’m excited to see these issues all get resolved in time – it’s really impressive work!

tj0

tj0

How is everyone measuring memory usage?

  • Is this resident/active memory only from the OS for beam?
  • Is this summing the memory of the processes in observer?
dimitarvp

dimitarvp

Also :erlang.memory() – the numbers returned are in bytes.

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews