Sharing memory amongst hypnotoad workers

109 views
Skip to first unread message

Veesh Goldman

unread,
May 16, 2019, 2:24:34 AM5/16/19
to mojol...@googlegroups.com
What are my options if I need all of my workers to share some bit of dynamic data? Let's say there's some counter that needs to be incremented every time something happens, but is only relevant while the app is running. Do I need to use a DB for that, or Redis or memcached, or is there something built in to help with that.
I'm assuming that the memory isn't shared because the process forks to make the workers.
Thanks

Илья Рассадин

unread,
May 16, 2019, 2:38:33 AM5/16/19
to mojol...@googlegroups.com

Hi!

As you said, you can use any type of external database.

If you're looking for something more simple - try Cache::FastMMap.

The only way to do that without external modules (just perl core + Mojolicious) I can think of is a file, but you need to use some locking mechanism like flock.

If you can use external modules - it's better to do that. If you need persistent storage - using external database like Redis is probably the most appropriate solution.

--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious...@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/CAO-W_8CrrP-DXxPP_TXxP7wf-dQY1e7nezqSgFHe8BTo6_853Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Dan Book

unread,
May 16, 2019, 10:16:00 AM5/16/19
to mojol...@googlegroups.com
Note SQLite with Mojo::SQLite is an option for an external database that doesn't require setting up any other server, if you won't have heavy load.

-Dan

Reply all
Reply to author
Forward
0 new messages