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.
- deploy on PostgreSQL with src/deploy-postgresql.sql
- alter service-postgresql.conf if needed
- pip install -r requirements.txt
- cd src
- python service.py service-postgresql.conf
In order to parallelize it should be split in few layers:
- 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);
- event-queue layer (RabbitMQ);
- 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.
- 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