Python Cloud Hosting
The platform provides an out-of-box integration of the scalable Apache application server dedicated specially for the Python-based applications 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 platform to provide the required level of Python cloud hosting. Use the table of content below to find required information within the guide quicker:
- Python Environment Hosting
- Python Versioning
- Python Application Deployment
- Python Packages/Modules Management
- Domains Management
- Automatic Vertical Scaling
- Manual Horizontal Scaling
- Automatic Horizontal Scaling
- Database Connection to PHP Application
Python Environment Hosting
To start hosting your Python application at the platform, 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.
Notes:
- 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 (at the time of this writing), the following Python versions are supported:
- 3.6.15
- 3.7.16
- 3.8.16
- 3.9.16
- 3.10.9
- 3.11.1
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 platform and can be performed using one of the following flows:
- from remote VCS repository (e.g. GitHub)
- via application archive uploaded by external URL or from the local machine
Git flow provides a possibility of sequential or simultaneous deploy, as well as automatic redeployment from the repository if new code changes appear.
Refer to the following guides for the detailed overview of the deployment process and the provided additional options:
Check examples of the Python-based application hosting on the platform:
Python Packages/Modules Management
In order to successfully deploy and run a Python application, some additional modules or other packages may be required to be installed. It is a common practice to run Python web applications in isolated virtual environments, for example using the virtual environment tool, which allows managing projects independently and without the administrator privileges.
1. Connect to the Python environment via SSH (using either a local or built-in Web SSH client) to create and start a new virtual environment. Run the following commands:
|
|
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} - installs a necessary module
- pip uninstall {packageName} - removes previously installed module
- pip install -upgrade {packageName} - updates the specified module to its latest version
- pip install -r requirements.txt - installs all the modules, listed in the requirements.txt file
- pip list - shows the set of already installed modules
Domains Management
If needed, the default domain name of your Python application can be replaced with a custom one via:
- CNAME redirect if using Shared Load Balancer; is recommended for dev and test environments
- DNS A Record if using public IP; can handle high traffic load and is suitable for production environments
In addition, the platform allows switching traffic between two environments quickly and without downtime (e.g. to seamlessly redirect customers 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 the platform 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 128 MiB of RAM and 400 MHz of CPU) for your Python application server. Everything else will be handled by the platform automatically.
Refer to the automatic vertical scaling guide for additional details.
Manual Horizontal Scaling
Horizontal scaling of the Python 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 of the new nodes from the base image template
- Stateful - sequentially copies file system of the master container into the new nodes
Automatic Horizontal Scaling
Navigate to the environment Settings > 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, the rest actions are automated. You’ll be informed about any changes with email notifications if the appropriate option is enabled.
Database Connection to Python Application
A set of scalable and fully manageable database servers is available within the platform for you to easily install and use for the Python environment. To establish the connection, adjust your application following the instruction based on the database you require:
Besides, hosting at the platform allows using other built-in tools and features, for example:
- Custom or Built-In 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
Explore high-quality Python hosting with the PaaS.