JILL24

JILL24

Sharding of ets table

suppose a case where single ets is storing users and users start to grow too much in ets table. now i want to shard ets table in the same node means local node.

is it possible? and if it is possible, how?

note - Don’t use 3rd party library. just custom built.

Most Liked

jhogberg

jhogberg

Erlang Core Team

I think you should take a step back and ask yourself why you’re having this problem to begin with.

Do you require that both reads and updates are executed sequentially?

If you don’t require that at all, then the server process is pointless and you’re much better off letting the clients access the table directly, which will drastically improve performance.

If you only require that updates run sequentially, then the server process is only necessary for updates and reads can access the table directly, which will greatly improve performance.

If you require that both reads and updates run sequentially, then I’d love to hear why. Either way you need to take a long hard look at your application’s architecture as routing this much traffic through a single process is not normal.

The concurrency options generally make the table faster for concurrent operations at the cost of making each individual operation slower. If there are no concurrent operations, such as in your case with a single server process being the only one to touch the table, then they make things slower for nothing.

LostKobrakai

LostKobrakai

Registry also uses sharded ets tables for scaling purposes.

hst337

hst337

ets sharding is used not to increase size, it is used to increase speed of parallel lookups/updates to reduce lock contention. Do not use ets sharding unless you have a reason to do so.

Last Post!

Nicoo

Nicoo

You received to much XY responses. Sounds like you just desperate to get the answer to your question.

One solution (maybe not ideal) is to make a logical separation.

Example:

Define a field “data_table” in the “user” table.
Let’s imagine that the table you want to shard is “user_data”.

You have 4 tables (shards) of “user_data”: user_data1, user_data2, user_data3, user_data4.
For each user, you can assign a shard to user.data_table field (user.data_table = "user_data1").

This approach will improve some cases, surely make others worse. It all depends on your case.
In a multi-tenant logic, it can do it.

This is not the ideal answer to your question but just to advance in the reflection for sharding

Where Next?

Popular in Discussions Top

scouten
I’m looking for a host for the server part of a small (personal) side project that I’m working on. It’s currently written in Node.js and ...
New
CharlesO
Erlang :list.nth simple, but 1 - based nth(1, [H|_]) -> H; nth(N, [_|T]) when N > 1 -> nth(N - 1, T). Elixir Enum.at … coo...
New
chulkilee
Here are the list of HTTP client libraries/wrappers, and some thoughts on HTTP client in general. I’d like to hear from others how they w...
New
AstonJ
If so I (and hopefully others!) might have some tips for you :slight_smile: But first, please say which area you’re finding most challen...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40042 209
New
lucaong
Hello Elixir and Nerves community, I have been working for a while on an open-source embedded key-value database for Elixir, that I call...
230 14350 124
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36654 110
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49084 226
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42533 114
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement