ZastrixArundell

ZastrixArundell

Should I use Redis or a global GenServer for data between applications?

I think the title says it all, but let me write a bit of an explanation.

Say I have an app A which does some work and it hosted on one machine. App B is a phoenix application which is the user dashboard, etc. and is ran on a totally different server. And I want app B to access some data which is stored in app A’s GenServer. Should I use clustering here (if possible, I think it is) or create an element in Redis which is connected to the GenServer.

I’ve no experience with clustering so I don’t know if it’s good for me to use a GenServer to share data accross or use Redis. (Also if it’s possible to cluster 2 different applications)

Most Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

This feels like an XY problem to me. What kind of information does each application have, and where does each application store that information for its own purposes today?

dimitarvp

dimitarvp

As @benwilson512 says, you are describing to us the problems with one potential solution of your original problem – without telling us what that original problem is.

What are you looking to solve exactly? Redis is an amazing piece of software but global state in general should be avoided as much as possible (easy to say from an academic point of view of course; but it’s a good principle to remember).

ZastrixArundell

ZastrixArundell

Okay. In that case I’m going to be giving information of what I actually want to create:

The worker/app A is a discord music bot. It will listen to message events off from Discords’ API and, with the correct input from the user, store specified links in a playlist. Currently the playlist is saved via a GenServer.

I will be making a Phoenix application which will give the user the ability to show the playlist in a nice web UI.

I don’t need any long-lasting persistence, i.e. that the playlist needs to be permanently stored.

Edit:

I think it should be noted that I plan to cluster the worker app.

pablodavila

pablodavila

Couldn’t this just be a monolith? What are you trying to achieve by clustering?

pablodavila

pablodavila

I’ll preface this by saying that I don’t a ton of experience and I’m going off what I’ve seen on the forum and elsewhere. If I were you I’d just put it all in a single node and collect some metrics on that; the streaming workload might be heavy but the web workload should have a minimal impact on that. Remember that you can also easily scale vertically and it’s way easier than scaling horizontally. This would also let you organize all your modules, functions and the structure of your app in general; afterwards you can split it in order to experiment with clusters.

Keep in mind that I, too, haven’t clustered any apps but it seems to me like Redis would be a better option in this case so you only focus on sharing a decoupled datastore and have a bit more fun while splitting the app.

Where Next?

Popular in Questions 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
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
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
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
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

Other popular topics Top

bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
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
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
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
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
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
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
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

We're in Beta

About us Mission Statement