On Fri, Apr 21, 2017 at 2:45 PM, Curt Siffert <[email protected]> wrote:

> I've considered using scalacache since it has the familiar model of
> caching method calls by parameter. But I'm not sure it's really idiomatic
> for akka-streams (which I've just started using) or akka. Should I instead
> consider using akka persistent actors (one per service lookup I guess) or
> dumping Redis entirely and using akka distributed data?
>

Personally, I'd likely use Akka Cluster Sharding for this -- assuming each
request can be summarized in a way that fits as an entity identifier, it
seems like a good fit.  In this model, the sharded entity would serve as a
read-through cache for the external service: your stream would go to the
sharded Actor -- if it's the first request, the Actor would make the
external request, otherwise it would already know about the value and
return it.  Cluster Sharded Actors are a lot like an in-memory cache, and I
use them for exactly this in a number of cases.

I'd probably only bother with Akka Persistence (I assume you're thinking of
building this on top of Redis) if the number of distinct request types is
too large to typically fit in memory (so the Sharded Actors would need to
sometimes get flushed), and too expensive/slow to want to ever re-run a
request externally.  Might be worthwhile, might not; it depends on the
external constraints.

If the number of distinct request types is relatively *small*, I might go
for Distributed Data.  But keep in mind that all of those values are being
gossipped around the network, so while this is likely a good solution for
hundreds-to-thousands of distinct requests, I probably wouldn't use it for
millions.

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to