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
Also Liked
dom
Have you looked into how Ecto manages database connection pools? DBConnection — db_connection v2.10.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
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 ![]()
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 ^^
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









