Giter Club home page Giter Club logo

wcpy's Introduction

Here is project to study distributed systems.

Schema

There is 3 types of processes:

  • main process, which receives POST requests with input data and sends it for processing in workers. Workers respond with frequencies hash map, which is added by main process to redis database
  • broker process. Intermediary between main process and workers. Broker process is required if we'll need to add more clients, e.g. for input from DB.
  • worker process. Receives text and responds with frequencies map.

Requirements

  • Python 3.5
  • Docker and docker-compose
  • Redis server
  • libzmq installed

Installation in local virtualenv

Run following commands to get working copy of project:

git clone https://github.com/Riliam/wcpy.git
cd wcpy
pyvenv venv
source venv/bin/activate
pip install -e .

Now executable wcpy in $PATH should appear. It is created using Click toolkit. wcpy --help will show available commands.

How to run project

  1. Start Redis server. For example, using Docker:

     docker run --name wordcount -d -p 6379:6379 redis:3.0
    
  2. Start 1 main process (options to change hosts or ports are availabe, see --help):

     wcpy main_run
    
  3. Start 1 broker process (options available):

     wcpy broker_run
    
  4. Start 1 or more worker processes:

     wcpy worker_run
    
  5. Main process runs HTTP server on default port 8080, and accepts POST request on url /add-frequencies with key text. For example, using httpie:

     http -f POST localhost:8080/add-frequencies text="a b c d"
    

    or curl:

     curl --data "text=a b c d"  localhost:8080/add-frequencies
    
  6. Top 10 frequent words will show in HTTP response as well as in server console output.

Alse, wcpy spam and wcpy spam --random-strings commands available, to send input to main process.

docker-compose.yml

Given docker-compose installed, run:

docker build -t local/wcpy .
docker-compose up

Docker-compose exposes 8080 port, so wcpy spam or curl/httpie are required to send input data.

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.