Wednesday, May 27, 2015

Asynchronous Python in Web Applications

Asynchronous or non-blocking IO allows worker to process other requests before current request has finished. That is possible in case a processing of current web request is related to an operation that is IO bound.


What is important to understand about applicability of async pattern for IO bound operations, they must:
  1. Utilize the same event loop, in this case worker's event loop can switch to next in the queue (otherwise it is blocked).
  2. Have long latency (otherwise you are wasting event loop queue for short requests).
If operation is not IO bound it is considered blocking.

Saturday, April 4, 2015

wheezy template: static website generator

Sometimes you need a quick way to generate a static web site and put it up on a server. Here is how you can generate a static website with wheezy.template. Let's suppose the following structure of the site:
 `- index.html
  - main.html
  `- master.html
   `- script.html
    - widget.html

Wednesday, October 29, 2014

wheezy web: RESTful API Design

In this article we are going to explore a simple RESTful API created with wheezy.web framework. The demo implements a CRUD for tasks. Includes entity validation, content caching with dependencies and functional test cases. The source code is structured with well defined actors (you can read more about it here).


The following convention is used with respect to operation, HTTP method (verb) and URL:
List:   GET    /api/v1/tasks
Add:    POST   /api/v1/tasks
Get:    GET    /api/v1/task/{task_id}
Update: PUT    /api/v1/task/{task_id}
Remove: DELETE /api/v1/task/{task_id}
The task entity consists of the following attributes: task_id, title and status. The source code is available here. Please download before proceeding any further.

Monday, August 4, 2014

wheezy web: deploy nginx + uwsgi + memcached

wheezy.web is a lightweight, high performance, high concurrency WSGI web framework with the key features to build modern, efficient web. Here we will deploy quick start with nginx, uwsgi and memcached to clean debian stable installation.

Saturday, March 15, 2014

memcached statistics status

Here is a "top" emulator for memcached statistics:
watch -n 5 "echo stats | socat unix-connect:/var/tmp/memcached.sock -"
The screen will be refreshed every 5 seconds and display results of memcached stats command.