Basic Docker Compose template application with Flask, Celery, Redis, MySQL, SocketIO, Nginx and Gunicorn

Nginx / Gunicorn / Flask 🐍 / Celery / SocketIO / MySQL / Redis / Docker 🐳 sample application

Basic Docker Compose template application for orchestating Flask with a Celery queue task, Redis message broker, MySQL database and support for SocketIO protocol.

Deployed with Nginx server and Gunicorn WSGI.

Flower supervision of Celery workers is also available. SocketIO is implemented through Flask-SocketIO.

Note that this application is almost production-ready. To see a production-ready application that follows this template check out CONTRABASS-webservices.

This template is intended for asynchronous tasks, periodical tasks and apps that require asynchronous communication through WebSockets-like protocols. Note that this makes an ideal backend for long-time execution web apps.

Notice that this application is horizontally scalable as it allows replication through multiple nginx, gunicorn, and celery workers.

Requirements

Run

First setup variables on .docker.env. Assuming you have Docker and docker-compose installed, run on terminal:

docker-compose up

In order to bring it down run:

docker-compose down

Go too:

http://127.0.0.1/hello/MyApplicationExample

Flower management page

Test

pytest -v

Maintainers

@alexOarga


Author: alexOarga
Source Code: https://github.com/alexOarga/docker-nginx-flask-celery-mysql-redis
License: MIT License

#flask #celery #redis #mysql #socketio #nginx #gunicorn #docker 

What is GEEK

Buddha Community

Basic Docker Compose template application with Flask, Celery, Redis, MySQL, SocketIO, Nginx and Gunicorn

Basic Docker Compose template application with Flask, Celery, Redis, MySQL, SocketIO, Nginx and Gunicorn

Nginx / Gunicorn / Flask 🐍 / Celery / SocketIO / MySQL / Redis / Docker 🐳 sample application

Basic Docker Compose template application for orchestating Flask with a Celery queue task, Redis message broker, MySQL database and support for SocketIO protocol.

Deployed with Nginx server and Gunicorn WSGI.

Flower supervision of Celery workers is also available. SocketIO is implemented through Flask-SocketIO.

Note that this application is almost production-ready. To see a production-ready application that follows this template check out CONTRABASS-webservices.

This template is intended for asynchronous tasks, periodical tasks and apps that require asynchronous communication through WebSockets-like protocols. Note that this makes an ideal backend for long-time execution web apps.

Notice that this application is horizontally scalable as it allows replication through multiple nginx, gunicorn, and celery workers.

Requirements

Run

First setup variables on .docker.env. Assuming you have Docker and docker-compose installed, run on terminal:

docker-compose up

In order to bring it down run:

docker-compose down

Go too:

http://127.0.0.1/hello/MyApplicationExample

Flower management page

Test

pytest -v

Maintainers

@alexOarga


Author: alexOarga
Source Code: https://github.com/alexOarga/docker-nginx-flask-celery-mysql-redis
License: MIT License

#flask #celery #redis #mysql #socketio #nginx #gunicorn #docker 

Joe  Hoppe

Joe Hoppe

1595905879

Best MySQL DigitalOcean Performance – ScaleGrid vs. DigitalOcean Managed Databases

HTML to Markdown

MySQL is the all-time number one open source database in the world, and a staple in RDBMS space. DigitalOcean is quickly building its reputation as the developers cloud by providing an affordable, flexible and easy to use cloud platform for developers to work with. MySQL on DigitalOcean is a natural fit, but what’s the best way to deploy your cloud database? In this post, we are going to compare the top two providers, DigitalOcean Managed Databases for MySQL vs. ScaleGrid MySQL hosting on DigitalOcean.

At a glance – TLDR
ScaleGrid Blog - At a glance overview - 1st pointCompare Throughput
ScaleGrid averages almost 40% higher throughput over DigitalOcean for MySQL, with up to 46% higher throughput in write-intensive workloads. Read now

ScaleGrid Blog - At a glance overview - 2nd pointCompare Latency
On average, ScaleGrid achieves almost 30% lower latency over DigitalOcean for the same deployment configurations. Read now

ScaleGrid Blog - At a glance overview - 3rd pointCompare Pricing
ScaleGrid provides 30% more storage on average vs. DigitalOcean for MySQL at the same affordable price. Read now

MySQL DigitalOcean Performance Benchmark
In this benchmark, we compare equivalent plan sizes between ScaleGrid MySQL on DigitalOcean and DigitalOcean Managed Databases for MySQL. We are going to use a common, popular plan size using the below configurations for this performance benchmark:

Comparison Overview
ScaleGridDigitalOceanInstance TypeMedium: 4 vCPUsMedium: 4 vCPUsMySQL Version8.0.208.0.20RAM8GB8GBSSD140GB115GBDeployment TypeStandaloneStandaloneRegionSF03SF03SupportIncludedBusiness-level support included with account sizes over $500/monthMonthly Price$120$120

As you can see above, ScaleGrid and DigitalOcean offer the same plan configurations across this plan size, apart from SSD where ScaleGrid provides over 20% more storage for the same price.

To ensure the most accurate results in our performance tests, we run the benchmark four times for each comparison to find the average performance across throughput and latency over read-intensive workloads, balanced workloads, and write-intensive workloads.

Throughput
In this benchmark, we measure MySQL throughput in terms of queries per second (QPS) to measure our query efficiency. To quickly summarize the results, we display read-intensive, write-intensive and balanced workload averages below for 150 threads for ScaleGrid vs. DigitalOcean MySQL:

ScaleGrid MySQL vs DigitalOcean Managed Databases - Throughput Performance Graph

For the common 150 thread comparison, ScaleGrid averages almost 40% higher throughput over DigitalOcean for MySQL, with up to 46% higher throughput in write-intensive workloads.

#cloud #database #developer #digital ocean #mysql #performance #scalegrid #95th percentile latency #balanced workloads #developers cloud #digitalocean droplet #digitalocean managed databases #digitalocean performance #digitalocean pricing #higher throughput #latency benchmark #lower latency #mysql benchmark setup #mysql client threads #mysql configuration #mysql digitalocean #mysql latency #mysql on digitalocean #mysql throughput #performance benchmark #queries per second #read-intensive #scalegrid mysql #scalegrid vs. digitalocean #throughput benchmark #write-intensive

Cayla  Erdman

Cayla Erdman

1603072320

Dockerized 🐳 Flask-Celery-RabbitMQ-Redis Application

This explains how to configure Flask, Celery, RabbitMQ and Redis, together with Docker to build a web service that dynamically uploads the content and loads this content when it is ready to be displayed. We’ll focus mainly on Celery and the services that surround it. Docker is a bit more straightforward.

Project Structure

The finished project structure will be as follows:

β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ README.md
β”œβ”€β”€ app
β”‚ β”œβ”€β”€ app.py
β”‚ β”œβ”€β”€ tasks.py
β”‚ └── templates
β”‚ β”œβ”€β”€ download.html
β”‚ └── index.html
β”œβ”€β”€ scripts
β”‚ β”œβ”€β”€ run_celery.sh
β”‚ └── run_web.sh
└── requirements.txt

Creating the Flask application 🌢

First, we create a folder for our app. For this example, our folder is called app. Within this folder, create an app.py file and an empty folder named templates where our HTML templates will be stored.

For our app, we first include some basic Flask libraries and create an instance of the app:

from io import BytesIO

from flask import Flask, request
from flask import render_template, make_response
APP = Flask(__name__)

We define three routes for Flask to implement: a landing page, a secondary page that embeds and image, and a route for the image itself. Our image route crops an image dynamically. For this example, it crops an image using pillow, and some delays are also included so that the time taken to create the image is more apparent.

@APP.route(β€˜/’)

def index():
   return render_template(β€˜index.html’)
@APP.route(β€˜/image_page’)
def image_page():
   job = tasks.get_data_from_strava.delay()
   return render_template(β€˜home.html’)
@APP.route('/result.png')
def result():
   '''
   Pull our generated .png binary from redis and return it
   '''
   jobid = request.values.get('jobid')
   if jobid:
      job = tasks.get_job(jobid)
      png_output = job.get()
      png_output="../"+png_output
      return png_output
   else:
      return 404

#rabbitmq #celery #flask #docker #redis

Ryleigh  Walker

Ryleigh Walker

1594274220

Serving Flask Applications with Gunicorn and Nginx Reverse Proxy

In this article, I will be implementing a simple flask application. I will be setting up a Gunicorn application server and will be

#flask #serving #applications #gunicorn #nginx #reverse

Live: Python - Docker e Docker Compose - Projeto Flask extensions

Neste episΓ³dio colocamos o serviΓ§o #python para rodar com #Docker e Docker compose e o prΓ³ximo passo serΓ‘ a #api Multistreaming with https://restream.io/?ref…

#python #docker compose #docker #projeto flask #flask