Deploying uSurvey requires the setup of a few supporting software for the application to be up and running. Details about the application architecture and deployment considerations are covered in this document.
The diagram below depicts the basic architecture of uSurvey. While requests can be sent directly to uSurvey Application servers, we recommend you route this through a web server like Nginx so that static resources can be served more efficiently and any additional layer of performance tuning or request routing can be applied there.
The uSurvey solution is composed of the following software components:
- Application database is Postgres.
- Gunicorn is used as application server for ODK collect requests.
- Daphne is used as app server for web requests and to support server side notifications on uSurvey
- Redis Server is used as application cache, for background tasks and as channel backend for the ASGI interface server.
- Application framework itself is django
- For web server, Nginx is the recommended choice. A sample configuration has been added in the project folder (nginx.snippet file).
This section discusses deployment considerations for uSurvey. For information on how to install uSurvey on a machine, see the installation instruction
For development purpose, please see following considerations:
uSurvey has been tested on Ubuntu and OS X. However it should run on most Linux machines (since there are no distribution specific dependency).
16GB RAM, 2.5GHz 4+ core processors and 200GB disk space should suffice for a typical setup (though actual sizing depends on projected traffic).
Postgres and redis-server needs to be installed and should be running (all can run on same machine, but you'll get better experience with higher RAM and CPU specs in that case)
It helps to install python-dev, libxml2-dev, libxslt1-dev, zlib1g-dev and libffi-dev (for a debian based system, the command would be sudo apt-get install python-dev libxml2-dev libxslt1-dev zlib1g-dev libffi-dev)
uSurvey has been tested on python2.7 and is compatible with django 1.8 and django 1.9 as of this time of writing.
Required python libraries are contained in the pip-requires.txt file found within the project directory.
For step by step guide on installation and related setup scripts, see the installation instruction
For a production setup, uSurvey can be deployed as a stand alone instance or in a clustered environment for high availability and distributed load. uSurvey also performs well either on a virtual machine or on physical hardware (Although there are benefits to running uSurvey on a virtual machine since system resource can be upgraded when needed).
Recommendations on Infrastructure Sizing
Sizing considerations for infrastructure would largely depend on the expected traffic on the system. However by using a virtual machine per setup and possibly using a load balanced cluster, it is easy to scale up the system to handle any load.
For a typical production setup for a self sufficient server instance capable of handling a million hits per day, uSurvey requires:
- A Linux machine (tested on Ubuntu 12+ and Mac Os X)
- 8GB RAM, 2.6GHz Octa-core Xeon Processor, 80GB disk space
- 1 or more Redis servers either running on same machine or on a separately managed cluster
- Linux machine (tested on Ubuntu 12+ and Mac Os X)
- 8GB RAM, 2.4GHz Octa-core Xeon Processor, 200GB disk space (though you might need to maintain a archiving policy depending on frequency of data collection)
- Postgres database
High Availability Considerations
With the already highlighted recommendations on sizing, it is easy to plan for a high availability setup. For a simple HA setup, you might consider the architecture below:
Although the redis cluster has been separated in the design, there is no reason why they cannot all be distributed within the two uSurvey machines so avoid the need for extra infrastructure.
Key components here are:
- 1 Load balancer expected to distribute requests evenly across all available uSurvey servers
- 2 Web Servers both on Host standby
- 2 Postgres servers running in Master-Slave configuration
- 2 Redis server per server instance (though 1 per instance is equally usable)
While we have ensured to make uSurvey documentation as detailed as possible, it is advisable to engage uSurvey experts to ensure best experience during the run of your surveys.
As an option, three models exist for hosting uSurvey:
- Local instance deployed and managed on your servers.
- Dedicated hosting deployed and managed in the cloud.
- Shared hosting where your instance would coexist with others (although your data would be collected separately).