Giter VIP home page Giter VIP logo

turbo-guacamole-py's Introduction

turbo-guacamole-py

Project Overview

This project is inspired by turbo-guacamole but written in python for a proof of concept. Turbo Guacamole is a tool that will allow distributed applications to store cache locally for quick access while keeping data consistent across distributed systems.

turbo-guacamole-py is a set of python tools which allow distributed applications to cache data locally(i.e. in-memory) and that data be in sync with other applications that use the same data. One use case is a distributed micro-service application with more than one instance running which needs to utilized cached data. If each instance has its own localized cache with no knowledge of each other the caches can get out of sync and contain incorrect data. turbo-guacamole allows all instances to be able to use data close to the application for fast access and have the data be correct.

Architecture

There are two components in the architecture:

  1. Client - library which keeps the cached data local to the running process allowing it to be accessed and ensuring the data is consistent with other associated caches

  2. Server - a long running process which manages the data within its own process. This serves as the source of truth to the data and ensures that clients which are associated have the same data.

flowchart TD
    Client-A
    Client-B
    Server
    Client-A <--Data Updates--> Server
    Client-B <--Data Updates--> Server
Loading

There can be many clients within a system, where each client is an instance of the cache all of which are in sync. The role of a client is to keep a copy of the data which is being managed within the server. This allows the user to access the data quickly without having to worry about the data being out-of-date

The role of the server is to be the central authority for the data. The server ensures that the data is correct and to communicate changes between clients to ensure that each client has a correct copy of the data.

Example Scenario

An instance of Turbo Guacamole is running in server mode. The server is listening for incoming requests from clients. When a new connection request is accepted it is upgraded to a web-socket and the connection remains open to either receive updates from the client or push updates to the client.

An instance of Turbo Guacamole in client mode connects to the server. After the web-socket connection is established, the server sends all the data it has to the client. The client then populates its cache. At this point the client and server are in sync. The user(running application) decides to add a value to its local cache. The client sends the data to the server and adds it to its cache(not necessarily in that order). At this point the server and client are in sync. A client instance is started and connects to the server, upon startup the server sends all its data to the new client and the new client stores it in its cache. At this point the server and two clients are in sync. User interacting with client #1 updates its cache(creates new data , or updates/deletes existing data). The client sends the update to the server and the server updates its cache, as well as sends the message to client #2. Client #2 updates its cache according to the message and the clients and server are in sync.

Additional Thoughts

  1. The server can store the information in a format that is different from the clients since it does not need to access the data and use it programmatically like a client would. For example, a user might want to pull a Person class out of the cache to perform some logic. On the other hand the server only holds the data to communicate it out to clients. Therefore, it can hold data in a simpler format and does not need to deserialize the data, which would save on processing.

  2. Clients should deserialize the data from the server and hold objects in its cache for quick retrieval and processing

  3. Not really sure on the communication mechinism, but something that is persistent and bi-directional would be great.

  4. The server should have some APIs so the user can choose to view data in the cache as well as make changes(i.e. remove, expire, or enter data) which will be reflected across to all clients.

Setup

  1. Install Python Virtual Environment:
python -m venv venv
  1. Start Virtual Environment:
.\venv\Scripts\activate
  1. Install Dependencies:
pip install -r requirements.txt
  1. Start Server (from root of project):
python start_server.py
  1. (In new terminal) - Start Client (from root of project):
python start_client.py

turbo-guacamole-py's People

Contributors

bryangators avatar anthonymbonafide avatar

Stargazers

 avatar

Watchers

 avatar

turbo-guacamole-py's Issues

Add CI

Story

When merging to main or specified branch we need to have the test suite run to ensure project still runs as intended.

Acceptance criteria

A fully functioning action workflow that runs tests in project when merging to main. The tests failing should prevent a successful merge.

Add Server/Client

Add initial Websocket Client and Server.

Story
I need a client and a server that will connect persistently and have bidirectional communication. The client will store in-memory cache that will be validated by the server. The server will be responsible for cache invalidation.

Description
Create a server that runs indefinitely accepting a pool of clients. The server will send/receive messages to and from the clients about cached data. Its main job is to keep all the clients up to date with valid data in their cache. The server will be a websocket.

Create a client that will have a persistent connection to the server via websocket. The client will have a local in-memory cache that the client validates with the server. The cache object will be implemented with a common api allowing the client to perform common operations on the cached data.

Future iterations of will add functionality and handle race conditions where data could be modified simultaneously.

Acceptance Criteria

  • Server script that can be started with command line with optional flags for domain, port and other common configuration options that could be needed.
  • Client object that connects to the server via web-socket. Will expose caching api operations. Client will constantly poll the server to validate the cache as well as communicate any changes to data such as common crud operations for the server to update other caches.
  • Tests for client server connections, communication and updates to data. Test coverage for each unit of code in the client and server.
  • Client/server communicate with RESP communication protocol.

Add initial Cache Data Structure

Story

As a maintainer
I want an initial cache data structure with some functions that I can use
So that I can start to add functionality over time

Description

Create a class or interface which will encapsulate the foundation of the cache which will grow and be used by the rest of the system. We only need this to be minimal in functionality for now as the structure will allow us to add features later on.

Acceptance Criteria

  • New class or interface is defined with the common APIs a user would be expected to use in order to interact with the cache
  • Tests covering the high level expected functionality.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.