Git Product home page Git Product logo

twisted-rest-example's Introduction

twisted-rest-example

This is a combination of Python2.7, Twisted, AngularJS (+Restangular), PostgreSQL and REST interface. Main target is to have a base for concurrent, extensible REST server intended for IO-bound applications.

How to install and launch

  1. deploy on PostgreSQL with src/deploy-postgresql.sql
  2. alter service-postgresql.conf if needed
  3. pip install -r requirements.txt
  4. cd src
  5. python service.py service-postgresql.conf

Scaling

In order to parallelize it should be split in few layers:

  1. web-request layer which would receive incoming requests and dispatch them into event queue, such as RabbitMQ, Redis or Celery. There should be a function to group requests and send dependent ones to single process in layer 3. This layer can be based on existing code, by using controllers (classes which form REST URLs);
  2. event-queue layer (RabbitMQ);
  3. an array of Twisted processes which would process requests. This would be based on existing code with Model class in the center.

Parallelization would be needed only to utilize all CPUs in high-load scenarios, though.

TODO

  • to generalize Twisted Resource framework and have declarative list of REST endpoints instead of classes (which would also allow to query API for available methods)
  • paging could be generalized as well, and include also count of pages
  • if event queue is present, probably it would be better to separate logics of postgresql_conn.py behind it, thus transactions would be more concurrent
  • there can be rolled back transactions due to data changed by other transaction; this can be filtered out and handled with repeats

twisted-rest-example's People

Contributors

paulsj-80 avatar

Watchers

 avatar

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.