Skip to content

AlarrionovTV/Ractor.CLR

 
 

Repository files navigation

Ractor

**Ractor** (Redis Actor, also see [this](http://en.wikipedia.org/wiki/The_Diamond_Age)) is a distributed actor system with CLR/JVM interop and dead simple API for POCOs cache/persistence. Its API is inspired by F#'s [MailboxProcessor](http://msdn.microsoft.com/en-us/library/ee370357.aspx), [Fsharp.Actor](https://github.com/colinbull/Fsharp.Actor) and Akka(.NET) libraries. The main difference is that in Ractor actors are virtual and exist is Redis per se as lists of messages, while a number of ephemeral workers (actors' "incarnations") take messages from Redis, process them and post results back.

Benchmarks (e.g. 1) show that Redis is as performant as old popular message queues and even newer ones, like ZMQ. Existing distributed actor systems use many to many connections, a design that at the first glance removes a single point of failure. But a closer look reveals that such design introduces multiple points of failure because data is stored in some random nodes and at each point in time some node acts as a central one. If that node fails the system will have to elect another lead node, but the messages will be lost.

Ractor was build with AWS infrastructure in mind. In Amazon cloud, it is easy to create one central Redis cluster in multiple availability zones with multiple replicas. This is the most reliable setup one could get, and it is available in minutes for cheap price. With this reliable central node one could then use autoscale group and even add spot instances to the system. Random shutdowns of any worker nodes will not affect the system in any way. This setup gives an elastic, easy to maintain and (automatically) scalable to a large size system of distributed actors.

A recent pre-release of project Orleans is conceptually the closest thing to Ractor. The Orleans technical report from Microsoft nicely describes the concepts of virtual actors, perpetual existence, automatic instantiation, location transparency, automatic scale out. This report could serve as a partial documentation for concepts (rather than implementation), and probably Orleans' implementation is better for you than Ractor if you are on Azure. When/if Orleans code is open-sourced, Ractor will try to get the best from it, while still enjoying the awesomeness of Redis cluster instead of proprietary many-to-many networking mechanisms. In the meantime, the existence of Orleans validates the virtual actors approach.

Ractor.Persistence is a collection of APIs for POCOs and blobs persistence and a strongly typed Redis client based on excellent Stackexchange.Redis library. The typed Redis client has strong opinion about keys schema inside Redis and uses a concept of root/owner objects to store dependent objects/collections. POCO/database persistor is implemented on top of Entity Framework 6 (with automatic migrations enabled for non-destructive schema changes). Blob persistor saves large data objects to files or S3.

Process-oriented programming

Ractor uses process-oriented programming paradigm - it separates the concerns of data structures and the concurrent processes that act upon them. Data structures reside in Redis cluster and persistent storage (RDBMS/S3/etc) which logically extend single-box memory model to distributed scenario. Ractor actors are the concurrent processes that act upon the data.

Slides for library intro at HS (Ractor was previously known as Fredis)

Slide 2 Slide 3 Slide 4 Slide 5 Slide 6 Slide 7 Slide 8 Slide 9 Slide 10 Slide 11 Slide 12 Slide 13

Install & Usage

PM> Install-Package Ractor
PM> Install-Package Ractor.Persistence
PM> Install-Package Ractor.Persistence.AWS

Docs & test are work in progress...

License

(c) Victor Baybekov 2015

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

This software is distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

About

Redis based distributed actors + Dead simple API for distributed POCOs persistence

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 70.5%
  • F# 29.3%
  • Other 0.2%