Python Cloud Hosting with Jelastic PaaS

55

3608-2-python-logoJelastic PaaS provides an out-the-of-box integration of the scalable Apache application server for Python-based application cloud hosting. It is already optimized and prepared for immediate management, allowing to dive right into development without bothering about numerous orchestration tasks, i.e., making the hosting process maximally convenient for developers.

Through this article, you’ll get acquainted with the main tools and features available on the Jelastic PaaS platform to provide the required level of Python cloud hosting.

Python Environment Creation

To start hosting your Python application at Jelastic PaaS, you need to create the appropriate environment via the powerful topology wizard (accessible through the New Environment button at the dashboard’s top panel).

Switch to the Python language tab and select the desired engine version. Apache Python application server is automatically added in a bundle with the mod_wsgi module. Specify resource limits and nodes count, as well as add extra software stacks or options (e.g., Public IPs) if required.

3608-1-create-python-environment

Note: Each instance is a fully independent isolated container. Instances of the same layer are automatically distributed across available hosts ensuring high availability.

Python Versioning

Currently, the following Python versions are supported:

  • Python 2.7.15;
  • Python 3.4.9;
  • Python 3.5.6;
  • Python 3.6.7;
  • Python 3.7.1.

3608-1-python-versions
You can select the required version of Python directly from the topology wizard during the creation of a new environment, as well as adjust it for already existing ones using container redeployment.

Python Application Deployment

Deployment to the managed application servers (Apache Python) is automated by the Jelastic PaaS platform and can be performed using one of the following flows:

  • Remote VCS repository (e.g., GitHub);
  • Application archive uploaded by an external URL or from a local machine.

3608-1-python-application-deployment

The Git flow provides a possibility of sequential or simultaneous deployment, as well as automatic re-deployment from the repository if new code changes appear.

Refer to the following guides for a detailed overview of the deployment process and the provided additional options:

Check the examples of Python-based application cloud hosting at Jelastic PaaS:

Python Packages and Modules Management

In order to successfully deploy and run a Python application, some additional modules or other packages may be required to be installed. Herewith, it is a common practice to run Python applications in isolated virtual environments, e.g., using the virtual environment tool which allows managing projects independently and without administrator privileges.

1. To create and start a new virtual environment, go to Settings > SSH > Web SSH and run the following commands:

virtualenv {appName}

source {appName}/bin/activate

3608-1-python-modules

2. The management of the required software packages is commonly provided by pip, a popular Python package management system for the PiPI repository. Below, some of the most common commands are listed:

  • pip install {packageName} – to install a necessary module;
  • pip uninstall {packageName} – to remove previously installed module;
  • pip install -upgrade {packageName} – to update the specified module to the latest version;
  • pip install -r requirements.txt – to install all the modules, listed in the requirements.txt file;
  • pip list – to see the list of already installed modules.
Tip: In case of the preconfigured application packages (archives), all the dependencies are provided via the requirements.txt file, which is read during the deployment process to install the listed Python modules automatically. Also, it should contain the wsgi.py file with the entry point script for running an application inside a virtual environment using the mod_wsgi for Apache.

Domains Management

If needed, the default domain name of your Python application can be replaced with a custom domain name via:

  • DNS CNAME redirect – if using Shared Load Balancer and is recommended for development and test environments;
  • DNS A Record – if using Public IP, can handle high traffic load and is suitable for production environments.

3608-1-custom-domain-for-python-application

In addition, Jelastic PaaS allows to switch traffic between two environments quickly and without downtime (e.g., to seamlessly redirect users to the newer application version) using the swap domains functionality or with the help of the SwapExtIps API/CLI method.

Automatic Vertical Scaling

Automatic vertical scaling implemented by Jelastic PaaS provides the exact amount of resources (RAM and CPU) that your application currently requires. As a result, you don’t need to waste your time continuously making load-related adjustments. And in combination with the Pay-as-You-Use pricing model, it ensures you never overpay for unused resources.

Just set the upper cloudlets limit (each one equals to 128 MB of RAM and 400 MHz of CPU) for your Python application server and everything else will be handled by the Jelastic PaaS platform automatically.

3608-1-automatic-vertical-scaling-for-python-application

Manual Horizontal Scaling

Horizontal scaling of the Python application servers is no different from scaling any other instance at the platform – just specify the required number of nodes with the +/ buttons in the central part of the topology wizard. If needed, choose the preferred scaling mode:

  • Stateless – simultaneously creates all new nodes from the base image template;
  • Stateful – sequentially copies file system of the master container into new nodes.

3806-1-horizontal-scaling-apache-python

Tip: For proper request distribution, a load balancer instance is automatically added to the environment upon Python application server scaling. Refer to the horizontal scaling documentation for more specifications.

Automatic Horizontal Scaling

Navigate to the environment Settings > Monitoring > Auto Horizontal Scaling section to set up custom triggers, which allow automatically increase/decrease the number of nodes due to the application load. Just choose a resource type to be monitored (CPU, RAM, Network, Disk) and the exact condition of scaling, and all necessary actions are executed automatically. You will be informed about any scaling changes with email notifications once this option is activated.

3806-1-automatic-horizontal-scaling-of-python-application

Database Connection to Python Application

A set of scalable and fully manageable database servers are available within Jelastic PaaS to easily install and use for a Python environment. To establish a database connection, adjust your application following the instructions based on the database you require:

Besides, cloud hosting at Jelastic PaaS allows using other built-in tools and features, for example:

  • Custom or Jelastic PaaS SSL;
  • Public IPv4 and IPv6;
  • A wide range of managed software stacks;
  • Container firewalls, endpoints, and environment isolation;
  • User-friendly UI and direct Web SSH access for management;
  • Open API and Cloud Scripting for automation;
  • Pay as you use pricing model;
  • Collaboration functionality for teamwork;
  • Multi-cloud distribution.

Try advanced trouble-free Python cloud hosting right now at our Jelastic PaaS platform.

SOURCEJelastic, Inc.