CloudPloy

Flask Application Hosting

Deploy Python Flask applications with databases, background tasks, and full production support. Simple, scalable, secure.

🐍

Python 3.12 Ready

Latest Python with all popular packages. Pip, Poetry, and virtual environment support. Run the exact Python version your app requires.

🖼️

Database Included

PostgreSQL, MySQL, Redis - all databases provisioned and managed. Your SQLAlchemy models connect without extra configuration.

⚡

WSGI/ASGI Support

Gunicorn, uWSGI, Uvicorn - production-ready application servers configured automatically. Multi-worker setup out of the box.

Why Deploy Flask on CloudPloy?

Flask Runs Best on Persistent Servers

Flask is designed for persistent server processes. When you deploy Flask to serverless platforms or run it as Lambda functions, you lose features that Flask was built for: in-memory caching between requests, long-running database connection pools, streaming responses, and WebSocket support via Flask-SocketIO.

CloudPloy runs your Flask app under Gunicorn with multiple worker processes, keeping connections warm and caches hot between requests. This is how Flask was intended to be deployed - as a proper WSGI application behind a production-grade server, not chopped into stateless function invocations.

Celery workers for background tasks run as separate persistent processes on the same server. Your Redis broker connects over a local socket. There is no cold start penalty, no function timeout cutting off long-running tasks, and no additional infrastructure to manage.

Python Ecosystem Without Restrictions

Serverless Python hosting imposes strict limits on package sizes and system-level dependencies. TensorFlow, OpenCV, and many scientific computing libraries exceed the package size limits imposed by Lambda and similar services, requiring complex workarounds like Lambda Layers or container images.

CloudPloy gives you a full Linux server. Install any Python package via pip. Install system dependencies via apt. Compile native extensions. Run CUDA workloads if your server has GPU support. There are no package size limits because you are deploying to a real server, not a constrained runtime environment.

SSH access is available on every plan. When your Celery task fails silently or your SQLAlchemy connection pool exhausts under load, SSH into the server, attach to the running process, and diagnose the problem directly. No more guessing from sanitized logs.

Complete Flask Ecosystem Support

📦 Extensions

  • • Flask-SQLAlchemy
  • • Flask-RESTful / Flask-RESTX
  • • Flask-Login
  • • Flask-Migrate
  • • Flask-WTF

🔒 Security

  • • Flask-Security-Too
  • • Flask-JWT-Extended
  • • Flask-CORS
  • • Flask-Limiter
  • • Flask-Talisman

⚙️ Task Queues

  • • Celery
  • • RQ (Redis Queue)
  • • Dramatiq
  • • APScheduler
  • • Huey

📊 Monitoring

  • • Sentry SDK
  • • Prometheus + Flask
  • • Flask-Admin
  • • Loguru
  • • Flower (Celery monitor)

Deploy Flask in 3 Simple Steps

1

Push Your Flask App

Connect your Git repository with your Flask application. Include a requirements.txt or pyproject.toml so CloudPloy knows which packages to install.

# requirements.txt
Flask==3.0.0
gunicorn==21.2.0
psycopg2-binary==2.9.9
SQLAlchemy==2.0.0
celery[redis]==5.3.6
2

Auto-Configure

CloudPloy detects Flask, installs dependencies, and sets up your production environment with Gunicorn configured for optimal performance.

✓ Flask app detected
✓ Database connected
✓ Gunicorn configured (4 workers)
✓ SSL certificate issued
3

Deploy & Scale

Your Flask app is live with SSL, monitoring, and auto-scaling. Database migrations run automatically as part of the deploy hook.

🚀 https://your-api.cloudploy.com

Production Best Practices for Flask on CloudPloy

Gunicorn Configuration

The number of Gunicorn workers should match your server's CPU core count. A common starting point is 2 * CPU_cores + 1. For a 2-core server, 5 workers is a reasonable starting point. Configure this in a gunicorn.conf.py file:

# gunicorn.conf.py
workers = 5
worker_class = 'sync'
worker_connections = 1000
timeout = 120
keepalive = 5
max_requests = 1000
max_requests_jitter = 50
preload_app = True

Use preload_app = True to load your Flask application once in the master process, then fork workers. This reduces memory usage significantly for large applications and speeds up worker restarts during deployments.

Database Migration Strategy

Use Flask-Migrate (Alembic under the hood) for schema migrations. Add a post-deploy hook in CloudPloy to run migrations automatically after each deployment:

# Deploy hook (runs after code update)
flask db upgrade

# Always create migrations locally, never on server
flask db migrate -m "add user table"
flask db upgrade

For production safety, always run migrations before restarting Gunicorn workers. CloudPloy's deploy sequence handles this: run the migration hook, verify it completes successfully, then perform the rolling worker restart. If the migration fails, the deploy stops and the old code keeps running.

Flask Application Examples

REST API with SQLAlchemy and Migrations

from flask import Flask, jsonify, request
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
import os

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL']
app.config['SQLALCHEMY_POOL_SIZE'] = 10
app.config['SQLALCHEMY_POOL_TIMEOUT'] = 30

db = SQLAlchemy(app)
migrate = Migrate(app, db)

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)

    def to_dict(self):
        return {'id': self.id, 'name': self.name, 'email': self.email}

@app.route('/api/users', methods=['GET'])
def get_users():
    users = User.query.order_by(User.id.desc()).all()
    return jsonify([u.to_dict() for u in users])

@app.route('/api/users/<int:user_id>', methods=['GET'])
def get_user(user_id):
    user = User.query.get_or_404(user_id)
    return jsonify(user.to_dict())

Background Tasks with Celery and Redis

from flask import Flask, jsonify, request
from celery import Celery
import os

app = Flask(__name__)
app.config['CELERY_BROKER_URL'] = os.environ['REDIS_URL']
app.config['CELERY_RESULT_BACKEND'] = os.environ['REDIS_URL']

celery = Celery(app.name, broker=app.config['CELERY_BROKER_URL'])
celery.conf.update(app.config)

@celery.task(bind=True, max_retries=3)
def process_report(self, report_id):
    try:
        # Long-running task - no timeout on CloudPloy
        data = fetch_large_dataset(report_id)
        result = generate_report(data)
        save_report(report_id, result)
        return {'status': 'complete', 'report_id': report_id}
    except Exception as exc:
        raise self.retry(exc=exc, countdown=60)

@app.route('/reports', methods=['POST'])
def create_report():
    task = process_report.delay(request.json['report_id'])
    return jsonify({'task_id': task.id}), 202

What You Can Build with Flask

🔌 REST APIs

Build scalable REST APIs with authentication, rate limiting, and auto-generated documentation using Flask-RESTX or Flasgger.

🤖 ML Model Serving

Deploy machine learning models as Flask APIs. Load TensorFlow or PyTorch models into memory once at startup and serve predictions without cold start delays.

📊 Data Dashboards

Interactive dashboards with real-time data visualization using Plotly Dash (which is built on Flask), backed by live database queries.

🔄 Microservices

Build individual Flask microservices for specific functions - auth, payments, notifications - each deployed independently on the same server.

🌐 Web Applications

Full-featured web apps with Jinja2 templates, forms, and user authentication using Flask-Login and Flask-WTF for CSRF protection.

⚡ WebSocket Apps

Real-time applications with Flask-SocketIO for live chat, notifications, and collaborative editing - persistent connections with no timeout cuts.

Frequently Asked Questions

Which Python versions does CloudPloy support?

CloudPloy supports Python 3.10, 3.11, 3.12, and newer versions as they become available. Specify your required version using a .python-version file in your repository root, or use the runtime selector in the CloudPloy dashboard. Virtual environments are created automatically during the build process.

How does CloudPloy handle Flask database connections in production?

CloudPloy provisions a managed PostgreSQL or MySQL database and injects the connection string as an environment variable. Use SQLAlchemy with connection pooling enabled (the default) and set SQLALCHEMY_POOL_RECYCLE to 3600 seconds to avoid idle connection timeouts. The database runs on the same server as your Flask app, so connections use a local socket with sub-millisecond latency.

Can I run Celery workers alongside Flask on CloudPloy?

Yes. CloudPloy lets you run multiple processes per application. Configure your Flask app as the primary web process and add a Celery worker process in the process manager. Both processes run on the same server and share the same Redis broker (provisioned from the database panel). The Flower monitoring dashboard can run as a third process on a separate port.

Does CloudPloy support Flask blueprints and large application factories?

Yes. CloudPloy runs your Flask app however you structure it. The application factory pattern with blueprints works exactly the same in production as it does locally. Set your FLASK_APP environment variable to point to your factory function (for example, myapp:create_app) and Gunicorn will call it correctly at startup.

How are Flask database migrations handled during deployments?

You can add a deploy hook command in CloudPloy that runs before the server restarts. Set it to flask db upgrade to run Alembic migrations automatically on each deploy. If the migration fails, the deploy halts and your running application is not affected. This gives you safe zero-downtime deployments even when schema changes are involved.

Can I use Flask with async (asyncio) on CloudPloy?

Yes. Flask 2.0+ supports async view functions natively. For full async performance, consider using Uvicorn as your ASGI server instead of Gunicorn. CloudPloy supports both - configure the start command to use uvicorn app:asgi_app --workers 4 for async Flask apps, or use Hypercorn which supports both WSGI and ASGI.

Full Python Ecosystem Available

📊 Data Science

  • • NumPy / Pandas
  • • SciPy / Statsmodels
  • • Matplotlib / Plotly
  • • Jupyter (as a process)

🤖 Machine Learning

  • • TensorFlow / Keras
  • • PyTorch
  • • scikit-learn
  • • Hugging Face Transformers

🔧 Development Tools

  • • pytest / coverage
  • • Black / Ruff
  • • mypy / Pyright
  • • Poetry / pip-tools

Deploy Your Flask Application Today

Production-ready Python hosting with databases, Celery workers, and SSH access - no cold starts, no function timeouts.

Free forever plan • Python 3.12 • Database included • Celery workers supported