All Projects → bakwc → Pysyncobj

bakwc / Pysyncobj

Licence: mit
A library for replicating your python class between multiple servers, based on raft protocol

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pysyncobj

Distributed Consensus Reading List
A long list of academic papers on the topic of distributed consensus
Stars: ✭ 803 (+71.58%)
Mutual labels:  replication, distributed-systems, fault-tolerance
Lizardfs
LizardFS is an Open Source Distributed File System licensed under GPLv3.
Stars: ✭ 793 (+69.44%)
Mutual labels:  replication, distributed-systems, fault-tolerance
Copycat
A novel implementation of the Raft consensus algorithm
Stars: ✭ 551 (+17.74%)
Mutual labels:  replication, raft, distributed-systems
Nuraft
C++ implementation of Raft core logic as a replication library
Stars: ✭ 428 (-8.55%)
Mutual labels:  replication, raft, distributed-systems
epaxos
A pluggable implementation of the Egalitarian Paxos Consensus Protocol
Stars: ✭ 39 (-91.67%)
Mutual labels:  distributed-systems, replication
coolbeans
Coolbeans is a distributed work queue that implements the beanstalkd protocol.
Stars: ✭ 56 (-88.03%)
Mutual labels:  distributed-systems, raft
kraker-info
Microservices based project to extract the information from the user data from different sources.
Stars: ✭ 17 (-96.37%)
Mutual labels:  distributed-systems, fault-tolerance
Raftos
Asynchronous replication framework for distributed Python projects
Stars: ✭ 287 (-38.68%)
Mutual labels:  replication, raft
little-raft
The lightest distributed consensus library. Run your own replicated state machine! ❤️
Stars: ✭ 316 (-32.48%)
Mutual labels:  distributed-systems, raft
kerala
Distributed KV Streams
Stars: ✭ 16 (-96.58%)
Mutual labels:  distributed-systems, raft
Elasticell
Elastic Key-Value Storage With Strong Consistency and Reliability
Stars: ✭ 453 (-3.21%)
Mutual labels:  raft, distributed-systems
golearn
🔥 Golang basics and actual-combat (including: crawler, distributed-systems, data-analysis, redis, etcd, raft, crontab-task)
Stars: ✭ 36 (-92.31%)
Mutual labels:  distributed-systems, raft
MIT6.824-2021
4 labs + 2 challenges + 4 docs
Stars: ✭ 594 (+26.92%)
Mutual labels:  distributed-systems, raft
Kites
🪁 A consistency, partition tolerance completed distributed KV store, implementation of the Raft distributed consensus protocol and Kotlin.
Stars: ✭ 41 (-91.24%)
Mutual labels:  distributed-systems, raft
huffleraft
Replicated key-value store driven by the raft consensus protocol 🚵
Stars: ✭ 32 (-93.16%)
Mutual labels:  distributed-systems, raft
Distributedsystemnotes
Notes on Lindsey Kuper's lectures on Distributed Systems
Stars: ✭ 267 (-42.95%)
Mutual labels:  distributed-systems, fault-tolerance
Dragonboat
Dragonboat is a high performance multi-group Raft consensus library in pure Go.
Stars: ✭ 3,983 (+751.07%)
Mutual labels:  raft, distributed-systems
Cloudi
A Cloud at the lowest level!
Stars: ✭ 352 (-24.79%)
Mutual labels:  distributed-systems, fault-tolerance
Raft
An Elixir implementation of the raft consensus protocol
Stars: ✭ 369 (-21.15%)
Mutual labels:  raft, distributed-systems
slock
High-performance distributed sync service and atomic DB
Stars: ✭ 50 (-89.32%)
Mutual labels:  replication, raft

PySyncObj

Build Status Windows Build Status Coverage Status Release License gitter docs

PySyncObj is a python library for building fault-tolerant distributed systems. It provides the ability to replicate your application data between multiple servers. It has following features:

  • raft protocol for leader election and log replication
  • Log compaction - it use fork for copy-on-write while serializing data on disk
  • Dynamic membership changes - you can do it with syncobj_admin utility or directly from your code
  • Zero downtime deploy - no need to stop cluster to update nodes
  • In-memory and on-disk serialization - you can use in-memory mode for small data and on-disk for big one
  • Encryption - you can set password and use it in external network
  • Python2 and Python3 on linux, macos and windows - no dependencies required (only optional one, eg. cryptography)
  • Configurable event loop - it can works in separate thread with it's own event loop - or you can call onTick function inside your own one
  • Convenient interface - you can easily transform arbitrary class into a replicated one (see example below).

Content

Install

PySyncObj itself:

pip install pysyncobj

Cryptography for encryption (optional):

pip install cryptography

Usage

Consider you have a class that implements counter:

class MyCounter(object):
	def __init__(self):
		self.__counter = 0

	def incCounter(self):
		self.__counter += 1

	def getCounter(self):
		return self.__counter

So, to transform your class into a replicated one:

  • Inherit it from SyncObj
  • Initialize SyncObj with a self address and a list of partner addresses. Eg. if you have serverA, serverB and serverC and want to use 4321 port, you should use self address serverA:4321 with partners [serverB:4321, serverC:4321] for your application, running at serverA; self address serverB:4321 with partners [serverA:4321, serverC:4321] for your application at serverB; self address serverC:4321 with partners [serverA:4321, serverB:4321] for app at serverC.
  • Mark all your methods that modifies your class fields with @replicated decorator. So your final class will looks like:
class MyCounter(SyncObj):
	def __init__(self):
		super(MyCounter, self).__init__('serverA:4321', ['serverB:4321', 'serverC:4321'])
		self.__counter = 0

	@replicated
	def incCounter(self):
		self.__counter += 1

	def getCounter(self):
		return self.__counter

And thats all! Now you can call incCounter on serverA, and check counter value on serverB - they will be synchronized.

Batteries

If you just need some distributed data structures - try built-in "batteries". Few examples:

Counter & Dict

from pysyncobj import SyncObj
from pysyncobj.batteries import ReplCounter, ReplDict

counter1 = ReplCounter()
counter2 = ReplCounter()
dict1 = ReplDict()
syncObj = SyncObj('serverA:4321', ['serverB:4321', 'serverC:4321'], consumers=[counter1, counter2, dict1])

counter1.set(42, sync=True) # set initial value to 42, 'sync' means that operation is blocking
counter1.add(10, sync=True) # add 10 to counter value
counter2.inc(sync=True) # increment counter value by one
dict1.set('testKey1', 'testValue1', sync=True)
dict1['testKey2'] = 'testValue2' # this is basically the same as previous, but asynchronous (non-blocking)
print(counter1, counter2, dict1['testKey1'], dict1.get('testKey2'))

Lock

from pysyncobj import SyncObj
from pysyncobj.batteries import ReplLockManager

lockManager = ReplLockManager(autoUnlockTime=75) # Lock will be released if connection dropped for more than 75 seconds
syncObj = SyncObj('serverA:4321', ['serverB:4321', 'serverC:4321'], consumers=[lockManager])
if lockManager.tryAcquire('testLockName', sync=True):
  # do some actions
  lockManager.release('testLockName')

You can look at batteries implementation, examples and unit-tests for more use-cases. Also there is an API documentation. Feel free to create proposals and/or pull requests with new batteries, features, etc. Join our gitter chat if you have any questions.

Performance

15K rps on 3 nodes; 14K rps on 7 nodes; 22K rps on 10 byte requests; 5K rps on 20Kb requests;

Publications

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].