smanza

smanza

ETS for TCP connections

Hello.

I saw on many posts and implementations for TCP connection management managed using GenServer or GenStatem, which is great with all the message passing, reactive, etc…
However, it can have strong risk of bottlenecks and overloading of the mailbox;

I ran some benchmarks, and tested an implementation of a TCP client using ETS to manage the socket.
Even if it’s not use message passing and synchronous reading of the socket, it still way faster, and even more when we add load or parallelization. So I don’t get timeouts easily.
It seems also a win/win as there is no need or less for process pooling, which tends to reduce the overhead.

What do you think about managing TCP connection by ETS ?

Thanks

Marked As Solved

smanza

smanza

I tried this approach as well, but no better than ETS as socket holder.

Also Liked

dom

dom

Have you looked into how Ecto manages database connection pools? DBConnection — db_connection v2.4.1

Each connection is a process, but once you checkout a connection, you can use the socket directly, without going through the process that owns it. I’d be curious if this library work for your use case or if you have different constraints.

Matsa59

Matsa59

Hello

I’m not sure to understand what/how/why you use ETS for TCP connection but have take a look on Registry ? Pretty sure it could help you a lot :wink:

I don’t know how you manage the TCP state in ETS (what happen if a TCP tunel is closed etc). In registry, you’ll follow the erlang mind of wrap everything in a process to let it crash.

Edit : I’m interesting to see some code if you can ^^

Where Next?

Popular in Questions Top

lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement